]> git.sur5r.net Git - freertos/blob - FreeRTOS/Demo/CORTEX_MPU_M23_Nuvoton_NuMaker_PFM_M2351_IAR_GCC/Nuvoton_Code/StdDriver/inc/timer.h
Add Cortex M23 GCC and IAR ports. Add demo projects for Nuvoton NuMaker-PFM-2351.
[freertos] / FreeRTOS / Demo / CORTEX_MPU_M23_Nuvoton_NuMaker_PFM_M2351_IAR_GCC / Nuvoton_Code / StdDriver / inc / timer.h
1 /**************************************************************************//**\r
2  * @file     timer.h\r
3  * @version  V3.00\r
4  * @brief    Timer Controller(Timer) driver header file\r
5  *\r
6  * @copyright (C) 2017 Nuvoton Technology Corp. All rights reserved.\r
7  *****************************************************************************/\r
8 #ifndef __TIMER_H__\r
9 #define __TIMER_H__\r
10 \r
11 #ifdef __cplusplus\r
12 extern "C"\r
13 {\r
14 #endif\r
15 \r
16 \r
17 /** @addtogroup Standard_Driver Standard Driver\r
18   @{\r
19 */\r
20 \r
21 /** @addtogroup TIMER_Driver TIMER Driver\r
22   @{\r
23 */\r
24 \r
25 /** @addtogroup TIMER_EXPORTED_CONSTANTS TIMER Exported Constants\r
26   @{\r
27 */\r
28 /*---------------------------------------------------------------------------------------------------------*/\r
29 /*  TIMER Operation Mode, External Counter and Capture Mode Constant Definitions                           */\r
30 /*---------------------------------------------------------------------------------------------------------*/\r
31 #define TIMER_ONESHOT_MODE                      (0UL << TIMER_CTL_OPMODE_Pos)      /*!< Timer working in one-shot mode \hideinitializer */\r
32 #define TIMER_PERIODIC_MODE                     (1UL << TIMER_CTL_OPMODE_Pos)      /*!< Timer working in periodic mode \hideinitializer */\r
33 #define TIMER_TOGGLE_MODE                       (2UL << TIMER_CTL_OPMODE_Pos)      /*!< Timer working in toggle-output mode \hideinitializer */\r
34 #define TIMER_CONTINUOUS_MODE                   (3UL << TIMER_CTL_OPMODE_Pos)      /*!< Timer working in continuous counting mode \hideinitializer */\r
35 #define TIMER_TOUT_PIN_FROM_TMX                 (0UL << TIMER_CTL_TGLPINSEL_Pos)   /*!< Timer toggle-output pin is from TMx pin \hideinitializer */\r
36 #define TIMER_TOUT_PIN_FROM_TMX_EXT             (1UL << TIMER_CTL_TGLPINSEL_Pos)   /*!< Timer toggle-output pin is from TMx_EXT pin \hideinitializer */\r
37 \r
38 #define TIMER_COUNTER_EVENT_FALLING             (0UL << TIMER_EXTCTL_CNTPHASE_Pos) /*!< Counter increase on falling edge detection \hideinitializer */\r
39 #define TIMER_COUNTER_EVENT_RISING              (1UL << TIMER_EXTCTL_CNTPHASE_Pos) /*!< Counter increase on rising edge detection \hideinitializer */\r
40 #define TIMER_CAPTURE_FREE_COUNTING_MODE        (0UL << TIMER_EXTCTL_CAPFUNCS_Pos) /*!< Timer capture event to get timer counter value \hideinitializer */\r
41 #define TIMER_CAPTURE_COUNTER_RESET_MODE        (1UL << TIMER_EXTCTL_CAPFUNCS_Pos) /*!< Timer capture event to reset timer counter \hideinitializer */\r
42 \r
43 #define TIMER_CAPTURE_EVENT_FALLING             (0UL << TIMER_EXTCTL_CAPEDGE_Pos)  /*!< Falling edge detection to trigger capture event \hideinitializer */\r
44 #define TIMER_CAPTURE_EVENT_RISING              (1UL << TIMER_EXTCTL_CAPEDGE_Pos)  /*!< Rising edge detection to trigger capture event \hideinitializer */\r
45 #define TIMER_CAPTURE_EVENT_FALLING_RISING      (2UL << TIMER_EXTCTL_CAPEDGE_Pos)  /*!< Both falling and rising edge detection to trigger capture event, and first event at falling edge \hideinitializer */\r
46 #define TIMER_CAPTURE_EVENT_RISING_FALLING      (3UL << TIMER_EXTCTL_CAPEDGE_Pos)  /*!< Both rising and falling edge detection to trigger capture event, and first event at rising edge \hideinitializer */\r
47 #define TIMER_CAPTURE_EVENT_GET_LOW_PERIOD      (6UL << TIMER_EXTCTL_CAPEDGE_Pos)  /*!< First capture event is at falling edge, follows are at at rising edge \hideinitializer */\r
48 #define TIMER_CAPTURE_EVENT_GET_HIGH_PERIOD     (7UL << TIMER_EXTCTL_CAPEDGE_Pos)  /*!< First capture event is at rising edge, follows are at at falling edge \hideinitializer */\r
49 \r
50 #define TIMER_TRGSRC_TIMEOUT_EVENT              (0UL << TIMER_TRGCTL_TRGSSEL_Pos) /*!< Select internal trigger source from timer time-out event \hideinitializer */\r
51 #define TIMER_TRGSRC_CAPTURE_EVENT              (1UL << TIMER_TRGCTL_TRGSSEL_Pos) /*!< Select internal trigger source from timer capture event \hideinitializer */\r
52 #define TIMER_TRG_TO_EPWM                       (TIMER_TRGCTL_TRGEPWM_Msk)        /*!< Each timer event as EPWM counter clock source \hideinitializer */\r
53 #define TIMER_TRG_TO_EADC                       (TIMER_TRGCTL_TRGEADC_Msk)        /*!< Each timer event to start ADC conversion \hideinitializer */\r
54 #define TIMER_TRG_TO_DAC                        (TIMER_TRGCTL_TRGDAC_Msk)         /*!< Each timer event to start DAC conversion \hideinitializer */\r
55 #define TIMER_TRG_TO_PDMA                       (TIMER_TRGCTL_TRGPDMA_Msk)        /*!< Each timer event to trigger PDMA transfer \hideinitializer */\r
56 \r
57 /*@}*/ /* end of group TIMER_EXPORTED_CONSTANTS */\r
58 \r
59 \r
60 /** @addtogroup TIMER_EXPORTED_FUNCTIONS TIMER Exported Functions\r
61   @{\r
62 */\r
63 \r
64 /**\r
65   * @brief      Set Timer Compared Value\r
66   *\r
67   * @param[in]  timer       The pointer of the specified Timer module. It could be TIMER0, TIMER1, TIMER2, TIMER3.\r
68   * @param[in]  u32Value    Timer compare value. Valid values are between 2 to 0xFFFFFF.\r
69   *\r
70   * @return     None\r
71   *\r
72   * @details    This macro is used to set timer compared value to adjust timer time-out interval.\r
73   * @note       1. Never write 0x0 or 0x1 in this field, or the core will run into unknown state. \n\r
74   *             2. If update timer compared value in continuous counting mode, timer counter value will keep counting continuously. \n\r
75   *                But if timer is operating at other modes, the timer up counter will restart counting and start from 0.\r
76   * \hideinitializer\r
77   */\r
78 #define TIMER_SET_CMP_VALUE(timer, u32Value)        ((timer)->CMP = (u32Value))\r
79 \r
80 /**\r
81   * @brief      Set Timer Prescale Value\r
82   *\r
83   * @param[in]  timer       The pointer of the specified Timer module. It could be TIMER0, TIMER1, TIMER2, TIMER3.\r
84   * @param[in]  u32Value    Timer prescale value. Valid values are between 0 to 0xFF.\r
85   *\r
86   * @return     None\r
87   *\r
88   * @details    This macro is used to set timer prescale value and timer source clock will be divided by (prescale + 1) \n\r
89   *             before it is fed into timer.\r
90   * \hideinitializer\r
91   */\r
92 #define TIMER_SET_PRESCALE_VALUE(timer, u32Value)   ((timer)->CTL = ((timer)->CTL & ~TIMER_CTL_PSC_Msk) | (u32Value))\r
93 \r
94 /**\r
95   * @brief      Check specify Timer Status\r
96   *\r
97   * @param[in]  timer       The pointer of the specified Timer module. It could be TIMER0, TIMER1, TIMER2, TIMER3.\r
98   *\r
99   * @retval     0   Timer 24-bit up counter is inactive\r
100   * @retval     1   Timer 24-bit up counter is active\r
101   *\r
102   * @details    This macro is used to check if specify Timer counter is inactive or active.\r
103   * \hideinitializer\r
104   */\r
105 #define TIMER_IS_ACTIVE(timer)                      (((timer)->CTL & TIMER_CTL_ACTSTS_Msk)? 1 : 0)\r
106 \r
107 /**\r
108   * @brief      Select Toggle-output Pin\r
109   *\r
110   * @param[in]  timer       The pointer of the specified Timer module. It could be TIMER0, TIMER1, TIMER2, TIMER3.\r
111   * @param[in]  u32ToutSel  Toggle-output pin selection, valid values are:\r
112   *                         - \ref TIMER_TOUT_PIN_FROM_TMX\r
113   *                         - \ref TIMER_TOUT_PIN_FROM_TMX_EXT\r
114   *\r
115   * @return     None\r
116   *\r
117   * @details    This macro is used to select timer toggle-output pin is output on TMx or TMx_EXT pin.\r
118   * \hideinitializer\r
119   */\r
120 #define TIMER_SELECT_TOUT_PIN(timer, u32ToutSel)    ((timer)->CTL = ((timer)->CTL & ~TIMER_CTL_TGLPINSEL_Msk) | (u32ToutSel))\r
121 \r
122 \r
123 /*---------------------------------------------------------------------------------------------------------*/\r
124 /* static inline functions                                                                                 */\r
125 /*---------------------------------------------------------------------------------------------------------*/\r
126 /* Declare these inline functions here to avoid MISRA C 2004 rule 8.1 error */\r
127 __STATIC_INLINE void TIMER_Start(TIMER_T *timer);\r
128 __STATIC_INLINE void TIMER_Stop(TIMER_T *timer);\r
129 __STATIC_INLINE void TIMER_EnableWakeup(TIMER_T *timer);\r
130 __STATIC_INLINE void TIMER_DisableWakeup(TIMER_T *timer);\r
131 __STATIC_INLINE void TIMER_StartCapture(TIMER_T *timer);\r
132 __STATIC_INLINE void TIMER_StopCapture(TIMER_T *timer);\r
133 __STATIC_INLINE void TIMER_EnableCaptureDebounce(TIMER_T *timer);\r
134 __STATIC_INLINE void TIMER_DisableCaptureDebounce(TIMER_T *timer);\r
135 __STATIC_INLINE void TIMER_EnableEventCounterDebounce(TIMER_T *timer);\r
136 __STATIC_INLINE void TIMER_DisableEventCounterDebounce(TIMER_T *timer);\r
137 __STATIC_INLINE void TIMER_EnableInt(TIMER_T *timer);\r
138 __STATIC_INLINE void TIMER_DisableInt(TIMER_T *timer);\r
139 __STATIC_INLINE void TIMER_EnableCaptureInt(TIMER_T *timer);\r
140 __STATIC_INLINE void TIMER_DisableCaptureInt(TIMER_T *timer);\r
141 __STATIC_INLINE uint32_t TIMER_GetIntFlag(TIMER_T *timer);\r
142 __STATIC_INLINE void TIMER_ClearIntFlag(TIMER_T *timer);\r
143 __STATIC_INLINE uint32_t TIMER_GetCaptureIntFlag(TIMER_T *timer);\r
144 __STATIC_INLINE void TIMER_ClearCaptureIntFlag(TIMER_T *timer);\r
145 __STATIC_INLINE uint32_t TIMER_GetWakeupFlag(TIMER_T *timer);\r
146 __STATIC_INLINE void TIMER_ClearWakeupFlag(TIMER_T *timer);\r
147 __STATIC_INLINE uint32_t TIMER_GetCaptureData(TIMER_T *timer);\r
148 __STATIC_INLINE uint32_t TIMER_GetCounter(TIMER_T *timer);\r
149 __STATIC_INLINE void TIMER_ResetCounter(TIMER_T *timer);\r
150 \r
151 \r
152 /**\r
153   * @brief      Start Timer Counting\r
154   *\r
155   * @param[in]  timer       The pointer of the specified Timer module. It could be TIMER0, TIMER1, TIMER2, TIMER3.\r
156   *\r
157   * @return     None\r
158   *\r
159   * @details    This function is used to start Timer counting.\r
160   */\r
161 __STATIC_INLINE void TIMER_Start(TIMER_T *timer)\r
162 {\r
163     timer->CTL |= TIMER_CTL_CNTEN_Msk;\r
164 }\r
165 \r
166 /**\r
167   * @brief      Stop Timer Counting\r
168   *\r
169   * @param[in]  timer       The pointer of the specified Timer module. It could be TIMER0, TIMER1, TIMER2, TIMER3.\r
170   *\r
171   * @return     None\r
172   *\r
173   * @details    This function is used to stop/suspend Timer counting.\r
174   */\r
175 __STATIC_INLINE void TIMER_Stop(TIMER_T *timer)\r
176 {\r
177     timer->CTL &= ~TIMER_CTL_CNTEN_Msk;\r
178 }\r
179 \r
180 /**\r
181   * @brief      Enable Timer Interrupt Wake-up Function\r
182   *\r
183   * @param[in]  timer       The pointer of the specified Timer module. It could be TIMER0, TIMER1, TIMER2, TIMER3.\r
184   *\r
185   * @return     None\r
186   *\r
187   * @details    This function is used to enable the timer interrupt wake-up function and interrupt source could be time-out interrupt, \n\r
188   *             counter event interrupt or capture trigger interrupt.\r
189   * @note       To wake the system from Power-down mode, timer clock source must be ether LXT or LIRC.\r
190   */\r
191 __STATIC_INLINE void TIMER_EnableWakeup(TIMER_T *timer)\r
192 {\r
193     timer->CTL |= TIMER_CTL_WKEN_Msk;\r
194 }\r
195 \r
196 /**\r
197   * @brief      Disable Timer Wake-up Function\r
198   *\r
199   * @param[in]  timer       The pointer of the specified Timer module. It could be TIMER0, TIMER1, TIMER2, TIMER3.\r
200   *\r
201   * @return     None\r
202   *\r
203   * @details    This function is used to disable the timer interrupt wake-up function.\r
204   */\r
205 __STATIC_INLINE void TIMER_DisableWakeup(TIMER_T *timer)\r
206 {\r
207     timer->CTL &= ~TIMER_CTL_WKEN_Msk;\r
208 }\r
209 \r
210 /**\r
211   * @brief      Start Timer Capture Function\r
212   *\r
213   * @param[in]  timer       The pointer of the specified Timer module. It could be TIMER0, TIMER1, TIMER2, TIMER3.\r
214   *\r
215   * @return     None\r
216   *\r
217   * @details    This function is used to start Timer capture function.\r
218   */\r
219 __STATIC_INLINE void TIMER_StartCapture(TIMER_T *timer)\r
220 {\r
221     timer->EXTCTL |= TIMER_EXTCTL_CAPEN_Msk;\r
222 }\r
223 \r
224 /**\r
225   * @brief      Stop Timer Capture Function\r
226   *\r
227   * @param[in]  timer       The pointer of the specified Timer module. It could be TIMER0, TIMER1, TIMER2, TIMER3.\r
228   *\r
229   * @return     None\r
230   *\r
231   * @details    This function is used to stop Timer capture function.\r
232   */\r
233 __STATIC_INLINE void TIMER_StopCapture(TIMER_T *timer)\r
234 {\r
235     timer->EXTCTL &= ~TIMER_EXTCTL_CAPEN_Msk;\r
236 }\r
237 \r
238 /**\r
239   * @brief      Enable Capture Pin De-bounce\r
240   *\r
241   * @param[in]  timer       The pointer of the specified Timer module. It could be TIMER0, TIMER1, TIMER2, TIMER3.\r
242   *\r
243   * @return     None\r
244   *\r
245   * @details    This function is used to enable the detect de-bounce function of capture pin.\r
246   */\r
247 __STATIC_INLINE void TIMER_EnableCaptureDebounce(TIMER_T *timer)\r
248 {\r
249     timer->EXTCTL |= TIMER_EXTCTL_CAPDBEN_Msk;\r
250 }\r
251 \r
252 /**\r
253   * @brief      Disable Capture Pin De-bounce\r
254   *\r
255   * @param[in]  timer       The pointer of the specified Timer module. It could be TIMER0, TIMER1, TIMER2, TIMER3.\r
256   *\r
257   * @return     None\r
258   *\r
259   * @details    This function is used to disable the detect de-bounce function of capture pin.\r
260   */\r
261 __STATIC_INLINE void TIMER_DisableCaptureDebounce(TIMER_T *timer)\r
262 {\r
263     timer->EXTCTL &= ~TIMER_EXTCTL_CAPDBEN_Msk;\r
264 }\r
265 \r
266 /**\r
267   * @brief      Enable Counter Pin De-bounce\r
268   *\r
269   * @param[in]  timer       The pointer of the specified Timer module. It could be TIMER0, TIMER1, TIMER2, TIMER3.\r
270   *\r
271   * @return     None\r
272   *\r
273   * @details    This function is used to enable the detect de-bounce function of counter pin.\r
274   */\r
275 __STATIC_INLINE void TIMER_EnableEventCounterDebounce(TIMER_T *timer)\r
276 {\r
277     timer->EXTCTL |= TIMER_EXTCTL_CNTDBEN_Msk;\r
278 }\r
279 \r
280 /**\r
281   * @brief      Disable Counter Pin De-bounce\r
282   *\r
283   * @param[in]  timer       The pointer of the specified Timer module. It could be TIMER0, TIMER1, TIMER2, TIMER3.\r
284   *\r
285   * @return     None\r
286   *\r
287   * @details    This function is used to disable the detect de-bounce function of counter pin.\r
288   */\r
289 __STATIC_INLINE void TIMER_DisableEventCounterDebounce(TIMER_T *timer)\r
290 {\r
291     timer->EXTCTL &= ~TIMER_EXTCTL_CNTDBEN_Msk;\r
292 }\r
293 \r
294 /**\r
295   * @brief      Enable Timer Time-out Interrupt\r
296   *\r
297   * @param[in]  timer       The pointer of the specified Timer module. It could be TIMER0, TIMER1, TIMER2, TIMER3.\r
298   *\r
299   * @return     None\r
300   *\r
301   * @details    This function is used to enable the timer time-out interrupt function.\r
302   */\r
303 __STATIC_INLINE void TIMER_EnableInt(TIMER_T *timer)\r
304 {\r
305     timer->CTL |= TIMER_CTL_INTEN_Msk;\r
306 }\r
307 \r
308 /**\r
309   * @brief      Disable Timer Time-out Interrupt\r
310   *\r
311   * @param[in]  timer       The pointer of the specified Timer module. It could be TIMER0, TIMER1, TIMER2, TIMER3.\r
312   *\r
313   * @return     None\r
314   *\r
315   * @details    This function is used to disable the timer time-out interrupt function.\r
316   */\r
317 __STATIC_INLINE void TIMER_DisableInt(TIMER_T *timer)\r
318 {\r
319     timer->CTL &= ~TIMER_CTL_INTEN_Msk;\r
320 }\r
321 \r
322 /**\r
323   * @brief      Enable Capture Trigger Interrupt\r
324   *\r
325   * @param[in]  timer       The pointer of the specified Timer module. It could be TIMER0, TIMER1, TIMER2, TIMER3.\r
326   *\r
327   * @return     None\r
328   *\r
329   * @details    This function is used to enable the timer capture trigger interrupt function.\r
330   */\r
331 __STATIC_INLINE void TIMER_EnableCaptureInt(TIMER_T *timer)\r
332 {\r
333     timer->EXTCTL |= TIMER_EXTCTL_CAPIEN_Msk;\r
334 }\r
335 \r
336 /**\r
337   * @brief      Disable Capture Trigger Interrupt\r
338   *\r
339   * @param[in]  timer       The pointer of the specified Timer module. It could be TIMER0, TIMER1, TIMER2, TIMER3.\r
340   *\r
341   * @return     None\r
342   *\r
343   * @details    This function is used to disable the timer capture trigger interrupt function.\r
344   */\r
345 __STATIC_INLINE void TIMER_DisableCaptureInt(TIMER_T *timer)\r
346 {\r
347     timer->EXTCTL &= ~TIMER_EXTCTL_CAPIEN_Msk;\r
348 }\r
349 \r
350 /**\r
351   * @brief      Get Timer Time-out Interrupt Flag\r
352   *\r
353   * @param[in]  timer   The pointer of the specified Timer module. It could be TIMER0, TIMER1, TIMER2, TIMER3.\r
354   *\r
355   * @retval     0   Timer time-out interrupt did not occur\r
356   * @retval     1   Timer time-out interrupt occurred\r
357   *\r
358   * @details    This function indicates timer time-out interrupt occurred or not.\r
359   */\r
360 __STATIC_INLINE uint32_t TIMER_GetIntFlag(TIMER_T *timer)\r
361 {\r
362     return ((timer->INTSTS & TIMER_INTSTS_TIF_Msk) ? 1UL : 0UL);\r
363 }\r
364 \r
365 /**\r
366   * @brief      Clear Timer Time-out Interrupt Flag\r
367   *\r
368   * @param[in]  timer       The pointer of the specified Timer module. It could be TIMER0, TIMER1, TIMER2, TIMER3.\r
369   *\r
370   * @return     None\r
371   *\r
372   * @details    This function clears timer time-out interrupt flag to 0.\r
373   */\r
374 __STATIC_INLINE void TIMER_ClearIntFlag(TIMER_T *timer)\r
375 {\r
376     timer->INTSTS = TIMER_INTSTS_TIF_Msk;\r
377 }\r
378 \r
379 /**\r
380   * @brief      Get Timer Capture Interrupt Flag\r
381   *\r
382   * @param[in]  timer   The pointer of the specified Timer module. It could be TIMER0, TIMER1, TIMER2, TIMER3.\r
383   *\r
384   * @retval     0   Timer capture interrupt did not occur\r
385   * @retval     1   Timer capture interrupt occurred\r
386   *\r
387   * @details    This function indicates timer capture trigger interrupt occurred or not.\r
388   */\r
389 __STATIC_INLINE uint32_t TIMER_GetCaptureIntFlag(TIMER_T *timer)\r
390 {\r
391     return timer->EINTSTS;\r
392 }\r
393 \r
394 /**\r
395   * @brief      Clear Timer Capture Interrupt Flag\r
396   *\r
397   * @param[in]  timer       The pointer of the specified Timer module. It could be TIMER0, TIMER1, TIMER2, TIMER3.\r
398   *\r
399   * @return     None\r
400   *\r
401   * @details    This function clears timer capture trigger interrupt flag to 0.\r
402   */\r
403 __STATIC_INLINE void TIMER_ClearCaptureIntFlag(TIMER_T *timer)\r
404 {\r
405     timer->EINTSTS = TIMER_EINTSTS_CAPIF_Msk;\r
406 }\r
407 \r
408 /**\r
409   * @brief      Get Timer Wake-up Flag\r
410   *\r
411   * @param[in]  timer   The pointer of the specified Timer module. It could be TIMER0, TIMER1, TIMER2, TIMER3.\r
412   *\r
413   * @retval     0   Timer does not cause CPU wake-up\r
414   * @retval     1   Timer interrupt event cause CPU wake-up\r
415   *\r
416   * @details    This function indicates timer interrupt event has waked up system or not.\r
417   */\r
418 __STATIC_INLINE uint32_t TIMER_GetWakeupFlag(TIMER_T *timer)\r
419 {\r
420     return (timer->INTSTS & TIMER_INTSTS_TWKF_Msk ? 1UL : 0UL);\r
421 }\r
422 \r
423 /**\r
424   * @brief      Clear Timer Wake-up Flag\r
425   *\r
426   * @param[in]  timer       The pointer of the specified Timer module. It could be TIMER0, TIMER1, TIMER2, TIMER3.\r
427   *\r
428   * @return     None\r
429   *\r
430   * @details    This function clears the timer wake-up system flag to 0.\r
431   */\r
432 __STATIC_INLINE void TIMER_ClearWakeupFlag(TIMER_T *timer)\r
433 {\r
434     timer->INTSTS = TIMER_INTSTS_TWKF_Msk;\r
435 }\r
436 \r
437 /**\r
438   * @brief      Get Capture value\r
439   *\r
440   * @param[in]  timer       The pointer of the specified Timer module. It could be TIMER0, TIMER1, TIMER2, TIMER3.\r
441   *\r
442   * @return     24-bit Capture Value\r
443   *\r
444   * @details    This function reports the current 24-bit timer capture value.\r
445   */\r
446 __STATIC_INLINE uint32_t TIMER_GetCaptureData(TIMER_T *timer)\r
447 {\r
448     return timer->CAP;\r
449 }\r
450 \r
451 /**\r
452   * @brief      Get Counter value\r
453   *\r
454   * @param[in]  timer       The pointer of the specified Timer module. It could be TIMER0, TIMER1, TIMER2, TIMER3.\r
455   *\r
456   * @return     24-bit Counter Value\r
457   *\r
458   * @details    This function reports the current 24-bit timer counter value.\r
459   */\r
460 __STATIC_INLINE uint32_t TIMER_GetCounter(TIMER_T *timer)\r
461 {\r
462     return timer->CNT;\r
463 }\r
464 \r
465 /**\r
466   * @brief      Reset Counter\r
467   *\r
468   * @param[in]  timer       The pointer of the specified Timer module. It could be TIMER0, TIMER1, TIMER2, TIMER3.\r
469   *\r
470   * @return     None\r
471   *\r
472   * @details    This function is used to reset current counter value and internal prescale counter value.\r
473   */\r
474 __STATIC_INLINE void TIMER_ResetCounter(TIMER_T *timer)\r
475 {\r
476     timer->CNT = 0UL;\r
477     while((timer->CNT & TIMER_CNT_RSTACT_Msk) == TIMER_CNT_RSTACT_Msk) {}\r
478 }\r
479 \r
480 \r
481 uint32_t TIMER_Open(TIMER_T *timer, uint32_t u32Mode, uint32_t u32Freq);\r
482 void TIMER_Close(TIMER_T *timer);\r
483 void TIMER_Delay(TIMER_T *timer, uint32_t u32Usec);\r
484 void TIMER_EnableCapture(TIMER_T *timer, uint32_t u32CapMode, uint32_t u32Edge);\r
485 void TIMER_DisableCapture(TIMER_T *timer);\r
486 void TIMER_EnableEventCounter(TIMER_T *timer, uint32_t u32Edge);\r
487 void TIMER_DisableEventCounter(TIMER_T *timer);\r
488 uint32_t TIMER_GetModuleClock(TIMER_T *timer);\r
489 void TIMER_EnableFreqCounter(TIMER_T *timer, uint32_t u32DropCount, uint32_t u32Timeout, uint32_t u32EnableInt);\r
490 void TIMER_DisableFreqCounter(TIMER_T *timer);\r
491 void TIMER_SetTriggerSource(TIMER_T *timer, uint32_t u32Src);\r
492 void TIMER_SetTriggerTarget(TIMER_T *timer, uint32_t u32Mask);\r
493 \r
494 /*@}*/ /* end of group TIMER_EXPORTED_FUNCTIONS */\r
495 \r
496 /*@}*/ /* end of group TIMER_Driver */\r
497 \r
498 /*@}*/ /* end of group Standard_Driver */\r
499 \r
500 #ifdef __cplusplus\r
501 }\r
502 #endif\r
503 \r
504 #endif /* __TIMER_H__ */\r
505 \r
506 /*** (C) COPYRIGHT 2017 Nuvoton Technology Corp. ***/\r