SWM341_timr.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. #ifndef __SWM341_TIMR_H__
  2. #define __SWM341_TIMR_H__
  3. #define TIMR_MODE_TIMER ((0 << 2) | 0)
  4. #define TIMR_MODE_IC ((1 << 2) | 0) //输入捕获
  5. #define TIMR_MODE_OC ((2 << 2) | 0) //输出比较
  6. #define TIMR_MODE_COUNTER ((0 << 2) | 2) //计数上升沿
  7. void TIMR_Init(TIMR_TypeDef * TIMRx, uint32_t mode, uint16_t prediv, 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. uint32_t TIMR_GetCurValue(TIMR_TypeDef * TIMRx); //获取当前计数值
  13. void TIMR_INTEn(TIMR_TypeDef * TIMRx); //使能中断
  14. void TIMR_INTDis(TIMR_TypeDef * TIMRx); //禁能中断
  15. void TIMR_INTClr(TIMR_TypeDef * TIMRx); //清除中断标志
  16. uint32_t TIMR_INTStat(TIMR_TypeDef * TIMRx); //获取中断状态
  17. void TIMR_OC_Init(TIMR_TypeDef * TIMRx, uint32_t match, uint32_t match_int_en, uint32_t init_lvl);
  18. void TIMR_OC_OutputEn(TIMR_TypeDef * TIMRx);
  19. void TIMR_OC_OutputDis(TIMR_TypeDef * TIMRx, uint32_t level);
  20. void TIMR_OC_SetMatch(TIMR_TypeDef * TIMRx, uint32_t match);
  21. uint32_t TIMR_OC_GetMatch(TIMR_TypeDef * TIMRx);
  22. void TIMR_OC_INTEn(TIMR_TypeDef * TIMRx);
  23. void TIMR_OC_INTDis(TIMR_TypeDef * TIMRx);
  24. void TIMR_OC_INTClr(TIMR_TypeDef * TIMRx);
  25. uint32_t TIMR_OC_INTStat(TIMR_TypeDef * TIMRx);
  26. void TIMR_IC_Init(TIMR_TypeDef * TIMRx, uint32_t captureH_int_en, uint32_t captureL_int_en);
  27. void TIMR_IC_Start(TIMR_TypeDef * TIMRx);
  28. void TIMR_IC_Start_Multi(uint32_t timr0, uint32_t timr1, uint32_t timr2, uint32_t timr3);
  29. void TIMR_IC_Stop(TIMR_TypeDef * TIMRx);
  30. uint32_t TIMR_IC_GetCaptureH(TIMR_TypeDef * TIMRx);
  31. uint32_t TIMR_IC_GetCaptureL(TIMR_TypeDef * TIMRx);
  32. void TIMR_IC_CaptureH_INTEn(TIMR_TypeDef * TIMRx);
  33. void TIMR_IC_CaptureH_INTDis(TIMR_TypeDef * TIMRx);
  34. void TIMR_IC_CaptureH_INTClr(TIMR_TypeDef * TIMRx);
  35. uint32_t TIMR_IC_CaptureH_INTStat(TIMR_TypeDef * TIMRx);
  36. void TIMR_IC_CaptureL_INTEn(TIMR_TypeDef * TIMRx);
  37. void TIMR_IC_CaptureL_INTDis(TIMR_TypeDef * TIMRx);
  38. void TIMR_IC_CaptureL_INTClr(TIMR_TypeDef * TIMRx);
  39. uint32_t TIMR_IC_CaptureL_INTStat(TIMR_TypeDef * TIMRx);
  40. void TIMR_IC_CaptureOV_INTEn(TIMR_TypeDef * TIMRx);
  41. void TIMR_IC_CaptureOV_INTDis(TIMR_TypeDef * TIMRx);
  42. void TIMR_IC_CaptureOV_INTClr(TIMR_TypeDef * TIMRx);
  43. uint32_t TIMR_IC_CaptureOV_INTStat(TIMR_TypeDef * TIMRx);
  44. #endif //__SWM341_TIMR_H__