wc bldc control board blink
This commit is contained in:
parent
4e5944699b
commit
ba3209550e
@ -18,6 +18,7 @@ set(TARGET_C_SRC
|
||||
${CMAKE_SOURCE_DIR}/src/main.c
|
||||
${CMAKE_SOURCE_DIR}/src/gd32e23x_it.c
|
||||
${CMAKE_SOURCE_DIR}/src/systick.c
|
||||
${CMAKE_SOURCE_DIR}/src/wc_bldc_control.c
|
||||
)
|
||||
|
||||
add_executable(gd32e23_template ${TARGET_C_SRC})
|
||||
|
@ -35,7 +35,4 @@ OF SUCH DAMAGE.
|
||||
#ifndef MAIN_H
|
||||
#define MAIN_H
|
||||
|
||||
/* led spark function */
|
||||
void led_spark(void);
|
||||
|
||||
#endif /* MAIN_H */
|
||||
|
10
inc/wc_bldc_control.h
Normal file
10
inc/wc_bldc_control.h
Normal file
@ -0,0 +1,10 @@
|
||||
//
|
||||
// Created by dell on 24-9-20.
|
||||
//
|
||||
|
||||
#ifndef WC_BLDC_CONTROL_H
|
||||
#define WC_BLDC_CONTROL_H
|
||||
|
||||
void led_blink_config(void);
|
||||
|
||||
#endif //WC_BLDC_CONTROL_H
|
@ -96,7 +96,6 @@ void PendSV_Handler(void)
|
||||
*/
|
||||
void SysTick_Handler(void)
|
||||
{
|
||||
delay_decrement();
|
||||
}
|
||||
|
||||
void TIMER13_IRQHandler(void)
|
||||
|
39
src/main.c
39
src/main.c
@ -5,44 +5,14 @@
|
||||
\version 2024-02-22, V2.1.0, firmware for GD32E23x
|
||||
*/
|
||||
|
||||
#include "main.h"
|
||||
#include <stdio.h>
|
||||
#include "gd32e23x.h"
|
||||
#include "systick.h"
|
||||
#include <stdio.h>
|
||||
#include "main.h"
|
||||
|
||||
#include "gd32e23x_libopt.h"
|
||||
|
||||
/*!
|
||||
\brief LED blink function with tmer13
|
||||
\param[in] none
|
||||
\param[out] none
|
||||
\retval none
|
||||
*/
|
||||
void led_config(void)
|
||||
{
|
||||
rcu_periph_clock_enable(RCU_GPIOB);
|
||||
|
||||
gpio_mode_set(GPIOB, GPIO_MODE_OUTPUT, GPIO_PUPD_NONE, GPIO_PIN_1);
|
||||
gpio_output_options_set(GPIOB, GPIO_OTYPE_OD, GPIO_OSPEED_50MHZ, GPIO_PIN_1);
|
||||
gpio_bit_write(GPIOB, GPIO_PIN_1, SET);
|
||||
|
||||
rcu_periph_clock_enable(RCU_TIMER13);
|
||||
timer_deinit(RCU_TIMER13);
|
||||
|
||||
timer_parameter_struct timer_initpara;
|
||||
timer_struct_para_init(&timer_initpara);
|
||||
timer_initpara.prescaler =7199;
|
||||
timer_initpara.alignedmode =TIMER_COUNTER_EDGE;
|
||||
timer_initpara.counterdirection =TIMER_COUNTER_UP;
|
||||
timer_initpara.period =999;
|
||||
timer_initpara.clockdivision =TIMER_CKDIV_DIV1;
|
||||
timer_init(TIMER13, &timer_initpara);
|
||||
|
||||
timer_auto_reload_shadow_enable(TIMER13);
|
||||
timer_interrupt_enable(TIMER13, TIMER_INT_UP);
|
||||
nvic_irq_enable(TIMER13_IRQn, 0);
|
||||
timer_enable(TIMER13);
|
||||
}
|
||||
#include "wc_bldc_control.h"
|
||||
|
||||
/*!
|
||||
\brief main function
|
||||
@ -56,7 +26,8 @@ int main(void)
|
||||
/* configure systick */
|
||||
systick_config();
|
||||
|
||||
led_config();
|
||||
// led_config();
|
||||
led_blink_config();
|
||||
|
||||
while(1){
|
||||
|
||||
|
37
src/wc_bldc_control.c
Normal file
37
src/wc_bldc_control.c
Normal file
@ -0,0 +1,37 @@
|
||||
//
|
||||
// Created by dell on 24-9-20.
|
||||
//
|
||||
|
||||
#include "wc_bldc_control.h"
|
||||
#include "gd32e23x.h"
|
||||
|
||||
/*!
|
||||
\brief led blink configuration
|
||||
\param[in] none
|
||||
\param[out] none
|
||||
\retval none
|
||||
*/
|
||||
void led_blink_config(void){
|
||||
rcu_periph_clock_enable(RCU_GPIOB);
|
||||
|
||||
gpio_mode_set(GPIOB, GPIO_MODE_OUTPUT, GPIO_PUPD_NONE, GPIO_PIN_1);
|
||||
gpio_output_options_set(GPIOB, GPIO_OTYPE_OD, GPIO_OSPEED_50MHZ, GPIO_PIN_1);
|
||||
gpio_bit_write(GPIOB, GPIO_PIN_1, SET);
|
||||
|
||||
rcu_periph_clock_enable(RCU_TIMER13);
|
||||
timer_deinit(RCU_TIMER13);
|
||||
|
||||
timer_parameter_struct timer_initpara;
|
||||
timer_struct_para_init(&timer_initpara);
|
||||
timer_initpara.prescaler =7199;
|
||||
timer_initpara.alignedmode =TIMER_COUNTER_EDGE;
|
||||
timer_initpara.counterdirection =TIMER_COUNTER_UP;
|
||||
timer_initpara.period =999;
|
||||
timer_initpara.clockdivision =TIMER_CKDIV_DIV1;
|
||||
timer_init(TIMER13, &timer_initpara);
|
||||
|
||||
timer_auto_reload_shadow_enable(TIMER13);
|
||||
timer_interrupt_enable(TIMER13, TIMER_INT_UP);
|
||||
nvic_irq_enable(TIMER13_IRQn, 0);
|
||||
timer_enable(TIMER13);
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user