generated from hulk/gd32e23x_template
Organize files
This commit is contained in:
32
src/led.c
Normal file
32
src/led.c
Normal file
@@ -0,0 +1,32 @@
|
||||
//
|
||||
// Created by dell on 24-12-20.
|
||||
//
|
||||
|
||||
#include "led.h"
|
||||
|
||||
void led_config(void) {
|
||||
rcu_periph_clock_enable(LED_RCU);
|
||||
|
||||
gpio_mode_set(LED_PORT, GPIO_MODE_OUTPUT, GPIO_PUPD_NONE, LED_PIN);
|
||||
gpio_output_options_set(LED_PORT, GPIO_OTYPE_PP, GPIO_OSPEED_50MHZ, LED_PIN);
|
||||
gpio_bit_write(LED_PORT, LED_PIN, SET);
|
||||
|
||||
rcu_periph_clock_enable(LED_TIMER_RCU);
|
||||
timer_deinit(LED_TIMER);
|
||||
|
||||
timer_parameter_struct timer_initpara;
|
||||
timer_struct_para_init(&timer_initpara);
|
||||
timer_initpara.prescaler = 799;
|
||||
timer_initpara.alignedmode = TIMER_COUNTER_EDGE;
|
||||
timer_initpara.counterdirection = TIMER_COUNTER_UP;
|
||||
timer_initpara.period = 999;
|
||||
timer_initpara.clockdivision = TIMER_CKDIV_DIV1;
|
||||
timer_init(LED_TIMER, &timer_initpara);
|
||||
|
||||
timer_auto_reload_shadow_enable(LED_TIMER);
|
||||
timer_interrupt_enable(LED_TIMER, TIMER_INT_UP);
|
||||
|
||||
timer_enable(LED_TIMER);
|
||||
|
||||
nvic_irq_enable(LED_IRQ, 2);
|
||||
}
|
Reference in New Issue
Block a user