Implemented some PWM.

Signed-off-by: Yilin Sun <imi415@imi.moe>
This commit is contained in:
Yilin Sun 2023-03-24 18:46:34 +08:00
parent b2c618db86
commit eeb7b3fc6f
3 changed files with 36 additions and 1 deletions

View File

@ -67,6 +67,7 @@ set(TARGET_SOURCES
"src/app_syscalls.c"
"src/mrb_machine_impl/mrb_machine_adc_impl.c"
"src/mrb_machine_impl/mrb_machine_gpio_impl.c"
"src/mrb_machine_impl/mrb_machine_pwm_impl.c"
"src/main.c"
)

@ -1 +1 @@
Subproject commit 1c6b50af4e36a96beca732cab5f1029c3138db75
Subproject commit ef83164ddba5403ec1e8eff4c102af907353bc95

View File

@ -0,0 +1,34 @@
#include <stdio.h>
/* Board */
#include "board.h"
/* SDK drivers */
#include "fsl_ctimer.h"
#include "fsl_gpio.h"
#include "fsl_iocon.h"
/* Gem private */
#include "machine-pwm/src/pwm.h"
#define PWM_IMPL_CT_ID (x)((x >> 2) & 0x07)
static const uint32_t pwm_channel_map[5][4] = {
{0x00000000UL, 0x00000000UL, 0x00000000UL, 0x00000000UL}, // CTIMER0
{0x00000000UL, 0x00000000UL, 0x00000000UL, 0x00000000UL}, // CTIMER1
{0x00000000UL, 0x00000000UL, 0x00000000UL, 0x00000000UL}, // CTIMER2
{0x00000000UL, 0x00000000UL, 0x00000000UL, 0x00000000UL}, // CTIMER3
{0x00000000UL, 0x00000000UL, 0x00000000UL, 0x00000000UL}, // CTIMER4
};
int mrb_machine_pwm_impl_config_set(uint32_t channel, machine_pwm_config_t *config) {
printf("Init pin: %ld, freq: %ld, duty: %d\n", channel, config->freq, config->duty);
return 0;
}
int mrb_machine_pwm_impl_config_get(uint32_t channel, machine_pwm_config_t *config) {
config->freq = 1000;
config->duty = 32768;
config->enabled = true;
return 0;
}