1 /**
2   ******************************************************************************
3   * @file    lib_tmr.h
4   * @author  Application Team
5   * @version V1.1.0
6   * @date    2019-10-28
7   * @brief   Timer library.
8   ******************************************************************************
9   * @attention
10   *
11   ******************************************************************************
12   */
13 #ifndef __LIB_TMR_H
14 #define __LIB_TMR_H
15 
16 #ifdef __cplusplus
17  extern "C" {
18 #endif
19 
20 #include "target.h"
21 
22 typedef struct
23 {
24   uint32_t Period;
25   uint32_t ClockSource;
26   uint32_t EXTGT;
27 } TMR_InitType;
28 //ClockSource
29 #define TMR_CLKSRC_INTERNAL     0
30 #define TMR_CLKSRC_EXTERNAL     TMR_CTRL_EXTCLK
31 //ClockGate
32 #define TMR_EXTGT_DISABLE       0
33 #define TMR_EXTGT_ENABLE        TMR_CTRL_EXTEN
34 
35 /* Private macros ------------------------------------------------------------*/
36 #define  IS_TMR_CLKSRC(__CLKSRC__)  (((__CLKSRC__) == TMR_CLKSRC_INTERNAL) || ((__CLKSRC__) == TMR_CLKSRC_EXTERNAL))
37 
38 #define  IS_TMR_EXTGT(__EXTGT__)  (((__EXTGT__) == TMR_EXTGT_DISABLE) || ((__EXTGT__) == TMR_EXTGT_ENABLE))
39 
40 /****************************** TMR Instances *********************************/
41 #define IS_TMR_ALL_INSTANCE(INSTANCE) (((INSTANCE) == TMR0) || \
42                                        ((INSTANCE) == TMR1) || \
43                                        ((INSTANCE) == TMR2) || \
44                                        ((INSTANCE) == TMR3))
45 
46 /* Exported Functions ------------------------------------------------------- */
47 /* Timer Exported Functions Group1:
48                                     (De)Initialization  ----------------------*/
49 void TMR_DeInit(TMR_Type *TMRx);
50 void TMR_Init(TMR_Type *TMRx, TMR_InitType *InitStruct);
51 void TMR_StructInit(TMR_InitType *InitStruct);
52 /* Timer Exported Functions Group2:
53                                     Interrupt (flag) -------------------------*/
54 void TMR_INTConfig(TMR_Type *TMRx, uint32_t NewState);
55 uint8_t TMR_GetINTStatus(TMR_Type *TMRx);
56 void TMR_ClearINTStatus(TMR_Type *TMRx);
57 /* Timer Exported Functions Group3:
58                                     MISC Configuration -----------------------*/
59 void TMR_Cmd(TMR_Type *TMRx, uint32_t NewState);
60 uint32_t TMR_GetCurrentValue(TMR_Type *TMRx);
61 
62 #ifdef __cplusplus
63 }
64 #endif
65 
66 #endif  /* __LIB_TMR_H */
67 
68 /*********************************** END OF FILE ******************************/
69