/******************************************************************** Copyright (c) 2021 Xiangyu Medical Co.,Ltd. All rights reserved. FileName : timer.h Author : zhangdawei Version : V1.0 Date : Note : History : ********************************************************************/ #ifndef TIMER_H__ #define TIMER_H__ /* Includes ------------------------------------------------------*/ #include "app_timer.h" /* Public define -------------------------------------------------*/ #define RAMP_TIM_TIME ( 1000 ) /* 呼吸灯的步长 */ #define M_STEP ( 100 ) /* 频率对应的周期值 */ #define CYCLE_CALUE ( 1000 ) #define SIQU ( 200 ) /* Public typedef ------------------------------------------------*/ /*通道状态*/ typedef enum { IdleState = 0, // 空闲态 StimState, // 刺激态 StimAdjState // 刺激调节态 }ChannelState_e; typedef enum { E_RMS_STOP = 0x00, E_RMS_START = 0x01, E_RMS_PAUSE = 0x02, E_RMS_CONTINUE = 0x03, E_STIM_STOP = 0x04, E_STIM_START = 0x05, E_STIM_PAUSE = 0x06, E_STIM_CONTINUE = 0x07 }E_WORK_STATE; /* LED状态 */ typedef enum { Disconnect_Highbattery = 0, //未连接有电 Disconnect_Lowbattery, // 未连接低电 Connect_Lowbattery, // 连接低电 Connect_Highbattery, // 连接有电 Null }LedModeInfo_e; /* 斜坡状态 */ typedef enum { RampIdle = 0, RampUp, RampDown, RampSmooth, RampBreak }RampState_e; /* 通道工作状态 */ typedef enum { Close, Open, Pause, Continue, Ready }ChannelWorkState_e; /* 刺激参数信息结构体 */ typedef struct { uint16_t usRampUpTime; // 上坡时间 单位为ms uint16_t usRampDownTime; // 下坡时间 uint16_t usSmoothTime; // 平坡时间 uint16_t usBreakTime; // 休息时间 uint16_t usFreqBuf; // 频率 ChannelWorkState_e ChannelWorkState; // 通道当前工作状态 uint32_t usWidth; // 脉冲宽度 uint32_t usCycle; // 脉冲周期 RampState_e Ramp_e; // 斜坡状态 uint8_t ucCurrent; // 标称电流值 uint16_t usCcrValue; // 标称的CCR值 }StimStateInfo_t; /* Public constants ----------------------------------------------*/ /* Public variables ----------------------------------------------*/ extern StimStateInfo_t ChannelStimStateInfo_t; extern uint8_t PwmLedInit_Flag; extern bool LongPressEvent; extern bool BeepBeepOpenFlag; /* Public function prototypes ------------------------------------*/ void AppTimersInit(void); void ApplicationTimersStart(void); void PwmDACInit(void); void PwmDACStop(void); void PwmLedUnInit(void); void PwmSubtractStop(void); void GpioteInit(void); void PPIPwmInit(void); void SetCurrent(uint16_t CcrIn); void OutputCurrentCtrl(void); void BlinkTwice(void); void pwm0_common_init(void); void SetPWMValues(uint16_t tempvalue); void pwm2common_init(void); void PwmDACPlay(void); void pwm2_play(void); void pwm0_play(void); #endif /*************************** END OF FILE ***************************/