A31G11x F/W Packages  2.5.0
ABOV Cortex-M0+ Core based MCUs Integrated Driver
A31G11x_hal_timer2n.h
Go to the documentation of this file.
1 /***************************************************************************//****************************************************************************/
34 
35 #ifndef _TIMER2n_H_
36 #define _TIMER2n_H_
37 
38 #include "A31G11x.h"
39 #include "A31G11x_hal_aa_types.h"
40 
41 #ifdef __cplusplus
42 extern "C" {
43 #endif
44 
45 //******************************************************************************
46 // Constant
47 //******************************************************************************
48 
49 //--------------------------------------
50 // TIMER2n Control Register definitions
51 //--------------------------------------
52 
54 #define TIMER2n_CR_MODE_MASK (0x3)
55 
57 #define TIMER2n_CR_CLK_MASK (TIMER2n_CR_T2nCLK_Msk)
58 
60 #define TIMER2n_CR_ECE_MASK (TIMER2n_CR_T2nECE_Msk)
61 
63 #define TIMER2n_CR_CAPSEL_MASK (0x03 << 9)
64 
66 #define TIMER2n_CR_OPOL_MASK (TIMER2n_CR_T2nOPOL_Msk)
67 
69 #define TIMER2n_CR_CPOL_MASK (TIMER2n_CR_T2nCPOL_Msk)
70 
72 #define TIMER2n_CR_MIEN_MASK (TIMER2n_CR_T2nMIEN_Msk)
73 
75 #define TIMER2n_CR_CIEN_MASK (TIMER2n_CR_T2nCIEN_Msk)
76 
78 #define TIMER2n_CR_PAU_MASK (TIMER2n_CR_T2nPAU_Msk)
79 
81 #define TIMER2n_CR_MATCH_FLAG (1 << 3)
82 #define TIMER2n_CR_CAPTURE_FLAG (1 << 2)
83 
85 #define TIMER2n_CR_CLEAR_MATCHINT (0x01 << TIMER2n_CR_T2nMIFLAG_Pos)
86 #define TIMER2n_CR_CLEAR_CAPTUREINT (0x01 << TIMER2n_CR_T2nCIFLAG_Pos)
87 #define TIMER2n_CR_CLEAR_CNT_PRED (0x01 << TIMER2n_CR_T2nCLR_Pos)
88 
90 #define TIMER2n_ADR_MASK 0xFFFFFFFF
91 
93 #define TIMER2n_BDR_MASK 0xFFFFFFFF
94 
96 #define TIMER2n_PREDR_MASK (0xFFF << 0)
97 
99 #define TIMER2n_ENABLE (1)
100 #define TIMER2n_DISABLE (0)
101 
103 #define TIMER2n_CLEAR (1)
104 
105 //******************************************************************************
106 // Type
107 //******************************************************************************
108 
109 //==============================================================================
110 // Enumeration
111 //==============================================================================
112 
114 typedef enum
115 {
121 
123 typedef enum
124 {
130 
132 typedef enum
133 {
137 
139 typedef enum
140 {
144 
146 typedef enum
147 {
152 
154 typedef enum
155 {
159 
161 typedef enum
162 {
166 
167 //==============================================================================
168 // Structure
169 //==============================================================================
170 
172 typedef struct
173 {
174  uint32_t ADR;
175  uint32_t BDR;
176  uint8_t TCLK_SEL;
180  uint16_t Prescaler;
183  uint8_t CkSel;
187  uint8_t ExtCkEdge;
191  uint8_t StartLevel;
195  uint8_t CapEdge;
201 
203 typedef struct
204 {
205  uint32_t ADR;
206  uint32_t BDR;
207  uint8_t TCLK_SEL;
211  uint16_t Prescaler;
214  uint8_t CkSel;
218  uint8_t ExtCkEdge;
222  uint8_t StartLevel;
226  uint8_t CapEdge;
232 
234 typedef struct
235 {
236  uint8_t TCLK_SEL;
240  uint16_t Prescaler;
243  uint8_t ClrMode;
249  uint8_t CkSel;
257  uint8_t CAPCkSel;
262  uint8_t Reserved[2];
264 
265 //******************************************************************************
266 // Macro
267 //******************************************************************************
268 
269 /*-------------------------------------------------------------------------*//*-------------------------------------------------------------------------*/
275 #define TIMER2n_ClrCnt( TIMER2x ) (TIMER2x->CR_b.T2nCLR = 1)
276 
277 /*-------------------------------------------------------------------------*//*-------------------------------------------------------------------------*/
283 #define TIMER2n_GetCnt( TIMER2x ) (TIMER2x->CNT)
284 
285 /*-------------------------------------------------------------------------*//*-------------------------------------------------------------------------*/
293 #define TIMER2n_SetAData( TIMER2x, u32AData ) (TIMER2x->ADR = u32AData)
294 
295 /*-------------------------------------------------------------------------*//*-------------------------------------------------------------------------*/
303 #define TIMER2n_SetBData( TIMER2x, u32BData ) (TIMER2x->BDR = u32BData)
304 
306 #define TIMER2n_CR_CLK_SET( n ) (n << TIMER2n_CR_T2nCLK_Pos)
307 
309 #define TIMER2n_CR_ECE_SET( n ) (n << TIMER2n_CR_T2nECE_Pos)
310 
312 #define TIMER2n_CR_CAPSEL_SET( n ) (n << 9)
313 
315 #define TIMER2n_CR_OPOL_SET( n ) (n << TIMER2n_CR_T2nOPOL_Pos)
316 
318 #define TIMER2n_CR_CPOL_SET( n ) (n << TIMER2n_CR_T2nCPOL_Pos)
319 
321 #define TIMER2n_CR_MIEN_SET( n ) (n << TIMER2n_CR_T2nMIEN_Pos)
322 
324 #define TIMER2n_CR_CIEN_SET( n ) (n << TIMER2n_CR_T2nCIEN_Pos)
325 
327 #define TIMER2n_CR_PAU_SET( n ) (n << TIMER2n_CR_T2nPAU_Pos)
328 
329 #define TIMER2n_PREDR_SET( n ) (n << 0)
330 
331 //******************************************************************************
332 // Function
333 //******************************************************************************
334 
335 HAL_Status_Type HAL_TIMER2n_Init( TIMER2n_Type* TIMER2x, TIMER2n_MODE_OPT TimerCounterMode, void* TIMER2n_Config );
336 HAL_Status_Type HAL_TIMER2n_DeInit( TIMER2n_Type* TIMER2x );
337 
338 HAL_Status_Type HAL_TIMER2n_ConfigInterrupt( TIMER2n_Type* TIMER2x, TIMER2n_INT_Type TIMER2n_IntCfg, FunctionalState NewState );
339 HAL_Status_Type HAL_TIMER2n_Cmd( TIMER2n_Type* TIMER2x, FunctionalState NewState );
340 HAL_Status_Type HAL_TIMER2n_ClearCounter( TIMER2n_Type* TIMER2x );
341 HAL_Status_Type HAL_TIMER2n_UpdateCountValue( TIMER2n_Type* TIMER2x, uint8_t CountCh, uint16_t Value );
342 HAL_Status_Type HAL_TIMER2n_ClearStatus( TIMER2n_Type* TIMER2x, uint8_t value );
343 uint8_t HAL_TIMER2n_GetStatus( TIMER2n_Type* TIMER2x );
344 
345 uint32_t HAL_TIMER2n_GetCaptureData( TIMER2n_Type* TIMER2x );
346 
347 #ifdef __cplusplus
348 }
349 #endif
350 
351 #endif /* _TIMER2n_H_ */
352 
HAL_Status_Type
TIMER2n_INT_Type
HAL_Status_Type HAL_TIMER2n_DeInit(TIMER2n_Type *TIMER2x)
Close Timer/Counter device.
TIMER2n_STARTLVL_OPT
struct TIMER2n_PWMCFG_Type TIMER2n_ONESHOTCFG_Type
Contains the ABOV typedefs for C standard types. It is intended to be used in ISO C conforming develo...
TIMER2n_CKSEL_MODE_OPT
uint8_t HAL_TIMER2n_GetStatus(TIMER2n_Type *TIMER2x)
Get Timer Status.
TIMER2n_CAP_CKSEL_OPT
FunctionalState
HAL_Status_Type HAL_TIMER2n_Cmd(TIMER2n_Type *TIMER2x, FunctionalState NewState)
Start/Stop Timer/Counter device.
HAL_Status_Type HAL_TIMER2n_ClearCounter(TIMER2n_Type *TIMER2x)
Clear Timer/Counter device,.
TIMER2n_MASTER_CKSEL_OPT
uint32_t HAL_TIMER2n_GetCaptureData(TIMER2n_Type *TIMER2x)
Read value of capture register in timer/counter device.
HAL_Status_Type HAL_TIMER2n_ClearStatus(TIMER2n_Type *TIMER2x, uint8_t value)
Clear Timer Status.
HAL_Status_Type HAL_TIMER2n_Init(TIMER2n_Type *TIMER2x, TIMER2n_MODE_OPT TimerCounterMode, void *TIMER2n_Config)
Initialize the TIMER2n peripheral with the specified parameters.
HAL_Status_Type HAL_TIMER2n_ConfigInterrupt(TIMER2n_Type *TIMER2x, TIMER2n_INT_Type TIMER2n_IntCfg, FunctionalState NewState)
Configure the peripheral interrupt.
HAL_Status_Type HAL_TIMER2n_UpdateCountValue(TIMER2n_Type *TIMER2x, uint8_t CountCh, uint16_t Value)
Update value.
TIMER2n_CLR_MODE_OPT
TIMER2n_MODE_OPT