GD32L233xxxx 使用 LRTIMER 生成 PWM

最近使用GD32L233xxxx开发项目,使用 LRTIMER 生成 PWM的方法,以类的形式总结如下:

LRTIMER  PWM basic functions as follow:


static void pwm_rcu_init() {
	rcu_periph_clock_enable(RCU_PMU);
	rcu_periph_clock_enable(RCU_GPIOD);
	
	rcu_osci_on(pwm_dev.pwm_clk);
	rcu_osci_stab_wait(pwm_dev.pwm_clk);
	rcu_lptimer_clock_config(pwm_dev.pwm_src_clk);
	rcu_periph_clock_enable(RCU_LPTIMER);
}

static void pwm_gpio_init() {
	gpio_mode_set(pwm_dev.pwm_port, GPIO_MODE_AF, GPIO_PUPD_NONE, pwm_dev.pwm_pin);
	gpio_output_options_set(pwm_dev.pwm_port, GPIO_OTYPE_PP, GPIO_OSPEED_50MHZ, pwm_dev.pwm_pin);
	gpio_af_set(pwm_dev.pwm_port, GPIO_AF_2, pwm_dev.pwm_pin);
}

static void pwm_nvic_init() {
	nvic_irq_enable(pwm_dev.pwm_irq, pwm_dev.pwm_priority);
	exti_init(pwm_dev.pwm_exti_line, EXTI_INTERRUPT, EXTI_TRIG_RISING);
	exti_interrupt_flag_clear(pwm_dev.pwm_exti_line);
}

static void pwm_timer_init() {
	lptimer_parameter_struct	lptimer_struct;
	
	lptimer_deinit();
	lptimer_s

你可能感兴趣的:(MCU_32-Advanced,GD32L233xxxx,LPTIMER,PWM)