1 #ifndef __SWM320_TIMR_H__ 2 #define __SWM320_TIMR_H__ 3 4 #define TIMR_MODE_TIMER 0 5 #define TIMR_MODE_COUNTER 1 6 7 void TIMR_Init(TIMR_TypeDef * TIMRx, uint32_t mode, uint32_t period, uint32_t int_en); //定时器/计数器初始化 8 void TIMR_Start(TIMR_TypeDef * TIMRx); //启动定时器,从初始值开始计时/计数 9 void TIMR_Stop(TIMR_TypeDef * TIMRx); //停止定时器 10 void TIMR_Halt(TIMR_TypeDef * TIMRx); //暂停定时器,计数值保持不变 11 void TIMR_Resume(TIMR_TypeDef * TIMRx); //恢复定时器,从暂停处继续计数 12 13 void TIMR_SetPeriod(TIMR_TypeDef * TIMRx, uint32_t period); //设置定时/计数周期 14 uint32_t TIMR_GetPeriod(TIMR_TypeDef * TIMRx); //获取定时/计数周期 15 uint32_t TIMR_GetCurValue(TIMR_TypeDef * TIMRx); //获取当前计数值 16 17 void TIMR_INTEn(TIMR_TypeDef * TIMRx); //使能中断 18 void TIMR_INTDis(TIMR_TypeDef * TIMRx); //禁能中断 19 void TIMR_INTClr(TIMR_TypeDef * TIMRx); //清除中断标志 20 uint32_t TIMR_INTStat(TIMR_TypeDef * TIMRx); //获取中断状态 21 22 23 24 #define PULSE_LOW 0 25 #define PULSE_HIGH 1 26 27 void Pulse_Init(uint32_t pulse, uint32_t int_en); 28 void Pulse_Start(void); 29 uint32_t Pulse_Done(void); 30 31 32 #endif //__SWM320_TIMR_H__ 33