lib_tmr.h 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /**
  2. ******************************************************************************
  3. * @file lib_tmr.h
  4. * @author Application Team
  5. * @version V4.4.0
  6. * @date 2018-09-27
  7. * @brief Timer library.
  8. ******************************************************************************
  9. * @attention
  10. *
  11. ******************************************************************************
  12. */
  13. #ifndef __LIB_TMR_H
  14. #define __LIB_TMR_H
  15. #ifdef __cplusplus
  16. extern "C" {
  17. #endif
  18. #include "target.h"
  19. typedef struct
  20. {
  21. uint32_t Period;
  22. uint32_t ClockSource;
  23. uint32_t EXTGT;
  24. } TMR_InitType;
  25. //ClockSource
  26. #define TMR_CLKSRC_INTERNAL 0
  27. #define TMR_CLKSRC_EXTERNAL TMR_CTRL_EXTCLK
  28. //ClockGate
  29. #define TMR_EXTGT_DISABLE 0
  30. #define TMR_EXTGT_ENABLE TMR_CTRL_EXTEN
  31. /* Private macros ------------------------------------------------------------*/
  32. #define IS_TMR_CLKSRC(__CLKSRC__) (((__CLKSRC__) == TMR_CLKSRC_INTERNAL) || ((__CLKSRC__) == TMR_CLKSRC_EXTERNAL))
  33. #define IS_TMR_EXTGT(__EXTGT__) (((__EXTGT__) == TMR_EXTGT_DISABLE) || ((__EXTGT__) == TMR_EXTGT_ENABLE))
  34. /* Exported Functions ------------------------------------------------------- */
  35. /* Timer Exported Functions Group1:
  36. (De)Initialization ----------------------*/
  37. void TMR_DeInit(TMR_TypeDef *TMRx);
  38. void TMR_Init(TMR_TypeDef *TMRx, TMR_InitType *InitStruct);
  39. void TMR_StructInit(TMR_InitType *InitStruct);
  40. /* Timer Exported Functions Group2:
  41. Interrupt (flag) -------------------------*/
  42. void TMR_INTConfig(TMR_TypeDef *TMRx, uint32_t NewState);
  43. uint8_t TMR_GetINTStatus(TMR_TypeDef *TMRx);
  44. void TMR_ClearINTStatus(TMR_TypeDef *TMRx);
  45. /* Timer Exported Functions Group3:
  46. MISC Configuration -----------------------*/
  47. void TMR_Cmd(TMR_TypeDef *TMRx, uint32_t NewState);
  48. uint32_t TMR_GetCurrentValue(TMR_TypeDef *TMRx);
  49. #ifdef __cplusplus
  50. }
  51. #endif
  52. #endif /* __LIB_TMR_H */
  53. /*********************************** END OF FILE ******************************/