wc bldc control board blink

This commit is contained in:
yelvlab 2024-09-21 01:05:29 +08:00
parent 4e5944699b
commit ba3209550e
6 changed files with 53 additions and 38 deletions

View File

@ -18,6 +18,7 @@ set(TARGET_C_SRC
${CMAKE_SOURCE_DIR}/src/main.c ${CMAKE_SOURCE_DIR}/src/main.c
${CMAKE_SOURCE_DIR}/src/gd32e23x_it.c ${CMAKE_SOURCE_DIR}/src/gd32e23x_it.c
${CMAKE_SOURCE_DIR}/src/systick.c ${CMAKE_SOURCE_DIR}/src/systick.c
${CMAKE_SOURCE_DIR}/src/wc_bldc_control.c
) )
add_executable(gd32e23_template ${TARGET_C_SRC}) add_executable(gd32e23_template ${TARGET_C_SRC})

View File

@ -35,7 +35,4 @@ OF SUCH DAMAGE.
#ifndef MAIN_H #ifndef MAIN_H
#define MAIN_H #define MAIN_H
/* led spark function */
void led_spark(void);
#endif /* MAIN_H */ #endif /* MAIN_H */

10
inc/wc_bldc_control.h Normal file
View 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

View File

@ -96,7 +96,6 @@ void PendSV_Handler(void)
*/ */
void SysTick_Handler(void) void SysTick_Handler(void)
{ {
delay_decrement();
} }
void TIMER13_IRQHandler(void) void TIMER13_IRQHandler(void)

View File

@ -5,44 +5,14 @@
\version 2024-02-22, V2.1.0, firmware for GD32E23x \version 2024-02-22, V2.1.0, firmware for GD32E23x
*/ */
#include "main.h"
#include <stdio.h>
#include "gd32e23x.h" #include "gd32e23x.h"
#include "systick.h" #include "systick.h"
#include <stdio.h>
#include "main.h"
#include "gd32e23x_libopt.h" #include "gd32e23x_libopt.h"
/*! #include "wc_bldc_control.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);
}
/*! /*!
\brief main function \brief main function
@ -56,7 +26,8 @@ int main(void)
/* configure systick */ /* configure systick */
systick_config(); systick_config();
led_config(); // led_config();
led_blink_config();
while(1){ while(1){

37
src/wc_bldc_control.c Normal file
View 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);
}