Electricity/FWLIB/include/ENS1_TIMER.h

75 lines
3.9 KiB
C
Raw Normal View History

#ifndef ENS1_TIMER_H
#define ENS1_TIMER_H
#include "CMSDK_CM0.h"
#include "my_header.h"
extern uint8_t ems_control_count; // 电刺激控制计数器
extern uint8_t ems_state ; // 电刺激状态0=关闭1=开启
2025-09-30 14:07:39 +08:00
extern uint8_t led_state;
// 时间管理标志位结构体
typedef struct {
uint8_t T_1ms; // 1ms周期标志
uint8_t T_2ms; // 2ms周期标志
uint8_t T_6ms; // 6ms周期标志
uint8_t T_10ms; // 10ms周期标志
uint8_t T_20ms; // 20ms周期标志
uint8_t T_100ms; // 100ms周期标志
uint8_t T_1s; // 1s周期标志
} Time_Flag_TypeDef;
// 时间管理计数器结构体
typedef struct {
uint8_t t_1ms; // 1ms计数器
uint8_t t_2ms; // 2ms计数器
uint8_t t_6ms; // 6ms计数器
uint8_t t_10ms; // 10ms计数器
uint8_t t_20ms; // 20ms计数器
uint8_t t_100ms; // 100ms计数器
uint16_t t_1s; // 1s计数器
} Time_Counter_TypeDef;
typedef enum {TOTAL_TIME_MODE = 0 , TRIGGER_TIME_MODE=1}TIME_COUNT_MODE; //ѡ<><D1A1>Ϊ<EFBFBD><CEAA>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD>Ч<EFBFBD><D0A7><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>
extern void TIMER0_Init(uint32_t Int_Period);
extern void TIMER1_Init(uint32_t Int_Period);
extern volatile uint32_t CHANNEL_TIME_COUNT[4];
extern volatile uint32_t TRIGGER_TIME_COUNT[4];
extern volatile uint32_t TOTAL_TIME_THRESHOLD_VALUE[4];
extern volatile uint32_t TRIGGER_TIME_THRESHOLD_VALUE[4];
extern volatile uint8_t TRIGGER_TIME_COUNT_FLAG;
extern void CMSDK_timer_EnableIRQ(CMSDK_TIMER_TypeDef *CMSDK_TIMER);
extern void CMSDK_timer_DisableIRQ(CMSDK_TIMER_TypeDef *CMSDK_TIMER);
extern void CMSDK_timer_StartTimer(CMSDK_TIMER_TypeDef *CMSDK_TIMER);
extern void CMSDK_timer_StopTimer(CMSDK_TIMER_TypeDef *CMSDK_TIMER);
extern uint32_t CMSDK_timer_GetValue(CMSDK_TIMER_TypeDef *CMSDK_TIMER);
extern void CMSDK_timer_SetValue(CMSDK_TIMER_TypeDef *CMSDK_TIMER, uint32_t value);
extern uint32_t CMSDK_timer_GetReload(CMSDK_TIMER_TypeDef *CMSDK_TIMER);
extern void CMSDK_timer_SetReload(CMSDK_TIMER_TypeDef *CMSDK_TIMER, uint32_t value);
extern void CMSDK_timer_ClearIRQ(CMSDK_TIMER_TypeDef *CMSDK_TIMER);
extern uint32_t CMSDK_timer_StatusIRQ(CMSDK_TIMER_TypeDef *CMSDK_TIMER);
extern void CMSDK_timer_Init(CMSDK_TIMER_TypeDef *CMSDK_TIMER, uint32_t reload, uint8_t irq_en);
extern void CMSDK_timer_Init_ExtClock(CMSDK_TIMER_TypeDef *CMSDK_TIMER, uint32_t reload,uint32_t irq_en);
extern void CMSDK_timer_Init_ExtEnable(CMSDK_TIMER_TypeDef *CMSDK_TIMER, uint32_t reload,uint32_t irq_en);
extern void CMSDK_dualtimer_start(CMSDK_DUALTIMER_TypeDef *CMSDK_DUALTIMERx);
extern void CMSDK_dualtimer_stop(CMSDK_DUALTIMER_TypeDef *CMSDK_DUALTIMERx);
extern void CMSDK_dualtimer_irq_clear(CMSDK_DUALTIMER_TypeDef *CMSDK_DUALTIMERx);
extern void CMSDK_dualtimer_setup_freerunning(CMSDK_DUALTIMER_TypeDef *CMSDK_DUALTIMERx,
unsigned int cycle, unsigned int prescale,
unsigned int interrupt, unsigned int size);
extern void CMSDK_dualtimer_setup_periodic(CMSDK_DUALTIMER_TypeDef *CMSDK_DUALTIMERx,
unsigned int cycle, unsigned int prescale,
unsigned int interrupt, unsigned int size);
extern void CMSDK_dualtimer_setup_oneshot(CMSDK_DUALTIMER_TypeDef *CMSDK_DUALTIMERx,
unsigned int cycle, unsigned int prescale,
unsigned int interrupt, unsigned int size);
extern void CMSDK_RTC_Init_Calender(uint16_t prescaler, uint8_t data_mode, uint8_t hour_mode, uint32_t init_time, uint32_t init_date);
extern void CMSDK_RTC_Config_Alarm(uint16_t prescaler, uint8_t data_mode, uint8_t hour_mode, uint32_t init_time, uint32_t init_date, uint32_t alarm_time, uint32_t alarm_date) ;
extern void CMSDK_RTC_Config_PeriodWake(uint8_t clock_sel, uint16_t prescaler, uint16_t period_time);
extern void Fuse_result(void);
// 时间管理函数声明
extern void Time_Manager_Init(void);
extern void Time_Manager_Process(void);
extern Time_Flag_TypeDef* Time_Manager_GetFlags(void);
extern void Time_Manager_ClearFlags(void);
extern void Time_Manager_Reset(void);
#endif