1 #ifndef __SWM341_TIMR_H__ 2 #define __SWM341_TIMR_H__ 3 4 #define TIMR_MODE_TIMER ((0 << 2) | 0) 5 #define TIMR_MODE_IC ((1 << 2) | 0) //输入捕获 6 #define TIMR_MODE_OC ((2 << 2) | 0) //输出比较 7 #define TIMR_MODE_COUNTER ((0 << 2) | 2) //计数上升沿 8 9 10 void TIMR_Init(TIMR_TypeDef * TIMRx, uint32_t mode, uint16_t prediv, uint32_t period, uint32_t int_en); //定时器/计数器初始化 11 void TIMR_Start(TIMR_TypeDef * TIMRx); //启动定时器,从初始值开始计时/计数 12 void TIMR_Stop(TIMR_TypeDef * TIMRx); //停止定时器 13 void TIMR_Halt(TIMR_TypeDef * TIMRx); //暂停定时器,计数值保持不变 14 void TIMR_Resume(TIMR_TypeDef * TIMRx); //恢复定时器,从暂停处继续计数 15 16 uint32_t TIMR_GetCurValue(TIMR_TypeDef * TIMRx); //获取当前计数值 17 18 void TIMR_INTEn(TIMR_TypeDef * TIMRx); //使能中断 19 void TIMR_INTDis(TIMR_TypeDef * TIMRx); //禁能中断 20 void TIMR_INTClr(TIMR_TypeDef * TIMRx); //清除中断标志 21 uint32_t TIMR_INTStat(TIMR_TypeDef * TIMRx); //获取中断状态 22 23 24 void TIMR_OC_Init(TIMR_TypeDef * TIMRx, uint32_t match, uint32_t match_int_en, uint32_t init_lvl); 25 26 void TIMR_OC_OutputEn(TIMR_TypeDef * TIMRx); 27 void TIMR_OC_OutputDis(TIMR_TypeDef * TIMRx, uint32_t level); 28 29 void TIMR_OC_SetMatch(TIMR_TypeDef * TIMRx, uint32_t match); 30 uint32_t TIMR_OC_GetMatch(TIMR_TypeDef * TIMRx); 31 32 void TIMR_OC_INTEn(TIMR_TypeDef * TIMRx); 33 void TIMR_OC_INTDis(TIMR_TypeDef * TIMRx); 34 void TIMR_OC_INTClr(TIMR_TypeDef * TIMRx); 35 uint32_t TIMR_OC_INTStat(TIMR_TypeDef * TIMRx); 36 37 38 void TIMR_IC_Init(TIMR_TypeDef * TIMRx, uint32_t captureH_int_en, uint32_t captureL_int_en); 39 void TIMR_IC_Start(TIMR_TypeDef * TIMRx); 40 void TIMR_IC_Start_Multi(uint32_t timr0, uint32_t timr1, uint32_t timr2, uint32_t timr3); 41 void TIMR_IC_Stop(TIMR_TypeDef * TIMRx); 42 43 uint32_t TIMR_IC_GetCaptureH(TIMR_TypeDef * TIMRx); 44 uint32_t TIMR_IC_GetCaptureL(TIMR_TypeDef * TIMRx); 45 46 void TIMR_IC_CaptureH_INTEn(TIMR_TypeDef * TIMRx); 47 void TIMR_IC_CaptureH_INTDis(TIMR_TypeDef * TIMRx); 48 void TIMR_IC_CaptureH_INTClr(TIMR_TypeDef * TIMRx); 49 uint32_t TIMR_IC_CaptureH_INTStat(TIMR_TypeDef * TIMRx); 50 void TIMR_IC_CaptureL_INTEn(TIMR_TypeDef * TIMRx); 51 void TIMR_IC_CaptureL_INTDis(TIMR_TypeDef * TIMRx); 52 void TIMR_IC_CaptureL_INTClr(TIMR_TypeDef * TIMRx); 53 uint32_t TIMR_IC_CaptureL_INTStat(TIMR_TypeDef * TIMRx); 54 void TIMR_IC_CaptureOV_INTEn(TIMR_TypeDef * TIMRx); 55 void TIMR_IC_CaptureOV_INTDis(TIMR_TypeDef * TIMRx); 56 void TIMR_IC_CaptureOV_INTClr(TIMR_TypeDef * TIMRx); 57 uint32_t TIMR_IC_CaptureOV_INTStat(TIMR_TypeDef * TIMRx); 58 59 60 #endif //__SWM341_TIMR_H__ 61