Initial commit: CCU621_M firmware project with BLE debug link support.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,57 @@
|
||||
#include "tim/app_tim.h"
|
||||
#include "bms/bms_interface.h"
|
||||
#include "gd32h7xx.h"
|
||||
#include "sys_drv_init.h"
|
||||
|
||||
void v_app_tim_init(void)
|
||||
{
|
||||
timer_parameter_struct timer_initpara;
|
||||
|
||||
/* TIMER7: generate update interrupt periodically. */
|
||||
rcu_periph_clock_enable(RCU_TIMER7);
|
||||
timer_deinit(TIMER7);
|
||||
timer_struct_para_init(&timer_initpara);
|
||||
|
||||
timer_initpara.prescaler = 23999U;
|
||||
timer_initpara.alignedmode = TIMER_COUNTER_EDGE;
|
||||
timer_initpara.counterdirection = TIMER_COUNTER_UP;
|
||||
timer_initpara.period = 9U;
|
||||
timer_initpara.clockdivision = TIMER_CKDIV_DIV1;
|
||||
timer_initpara.repetitioncounter = 0U;
|
||||
timer_init(TIMER7, &timer_initpara);
|
||||
|
||||
timer_interrupt_flag_clear(TIMER7, TIMER_INT_FLAG_UP);
|
||||
timer_interrupt_enable(TIMER7, TIMER_INT_UP);
|
||||
timer_enable(TIMER7);
|
||||
}
|
||||
|
||||
void v_app_tim_irq_handler(void)
|
||||
{
|
||||
if (RESET != timer_interrupt_flag_get(TIMER7, TIMER_INT_FLAG_UP))
|
||||
{
|
||||
timer_interrupt_flag_clear(TIMER7, TIMER_INT_FLAG_UP);
|
||||
v_app_tim_tick_1ms();
|
||||
}
|
||||
}
|
||||
|
||||
void v_app_tim_tick_1ms(void)
|
||||
{
|
||||
static U16_T cnt = 0U;
|
||||
|
||||
cnt++;
|
||||
|
||||
/* Run LED heartbeat from timer context (independent from IdleHook). */
|
||||
if ((cnt % 500U) == 0U)
|
||||
{
|
||||
RUN_LED_TOGGLE();
|
||||
WATCKDOG_TOGGLE();
|
||||
}
|
||||
|
||||
if ((cnt % 10U) == 0U)
|
||||
{
|
||||
v_bms_add_timer(); /* 10ms */
|
||||
}
|
||||
|
||||
v_delay_set_tymer_val(); /* bms timeout counter */
|
||||
}
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
#ifndef APP_TIM_H
|
||||
#define APP_TIM_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
void v_app_tim_init(void);
|
||||
void v_app_tim_irq_handler(void);
|
||||
void v_app_tim_tick_1ms(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* APP_TIM_H */
|
||||
|
||||
Reference in New Issue
Block a user