1 /**************************************************************************//**
2  * @file     ecap.h
3  * @version  V3.00
4  * @brief    EnHanced Input Capture Timer(ECAP) driver header file
5  *
6  * SPDX-License-Identifier: Apache-2.0
7  * @copyright (C) 2016-2020 Nuvoton Technology Corp. All rights reserved.
8 *****************************************************************************/
9 #ifndef __ECAP_H__
10 #define __ECAP_H__
11 
12 #ifdef __cplusplus
13 extern "C"
14 {
15 #endif
16 
17 
18 /** @addtogroup Standard_Driver Standard Driver
19   @{
20 */
21 
22 /** @addtogroup ECAP_Driver ECAP Driver
23   @{
24 */
25 
26 /** @addtogroup ECAP_EXPORTED_CONSTANTS ECAP Exported Constants
27   @{
28 */
29 
30 #define ECAP_IC0    (0UL)    /*!< ECAP IC0 Unit \hideinitializer */
31 #define ECAP_IC1    (1UL)    /*!< ECAP IC1 Unit \hideinitializer */
32 #define ECAP_IC2    (2UL)    /*!< ECAP IC2 Unit \hideinitializer */
33 
34 /*---------------------------------------------------------------------------------------------------------*/
35 /* ECAP CTL0 constant definitions                                                                          */
36 /*---------------------------------------------------------------------------------------------------------*/
37 #define ECAP_NOISE_FILTER_CLKDIV_1            (0UL<<ECAP_CTL0_NFCLKSEL_Pos)    /*!< Noise filter clock divide by 1  \hideinitializer */
38 #define ECAP_NOISE_FILTER_CLKDIV_2            (1UL<<ECAP_CTL0_NFCLKSEL_Pos)    /*!< Noise filter clock divide by 2  \hideinitializer */
39 #define ECAP_NOISE_FILTER_CLKDIV_4            (2UL<<ECAP_CTL0_NFCLKSEL_Pos)    /*!< Noise filter clock divide by 4  \hideinitializer */
40 #define ECAP_NOISE_FILTER_CLKDIV_16           (3UL<<ECAP_CTL0_NFCLKSEL_Pos)    /*!< Noise filter clock divide by 16 \hideinitializer */
41 #define ECAP_NOISE_FILTER_CLKDIV_32           (4UL<<ECAP_CTL0_NFCLKSEL_Pos)    /*!< Noise filter clock divide by 32  \hideinitializer */
42 #define ECAP_NOISE_FILTER_CLKDIV_64           (5UL<<ECAP_CTL0_NFCLKSEL_Pos)    /*!< Noise filter clock divide by 64  \hideinitializer */
43 
44 
45 #define ECAP_CAP_INPUT_SRC_FROM_IC            (0UL)  /*!< CAP input source from IC             \hideinitializer */
46 #define ECAP_CAP_INPUT_SRC_FROM_CH            (2UL)  /*!< CAP input source from CH of QEI      \hideinitializer */
47 
48 #define ECAP_DISABLE_COMPARE                  (0UL<<ECAP_CTL0_CMPEN_Pos)    /*!< Input capture compare and reload function disable \hideinitializer */
49 #define ECAP_COMPARE_FUNCTION                 (1UL<<ECAP_CTL0_CMPEN_Pos)    /*!< Input capture compare function  \hideinitializer */
50 /*---------------------------------------------------------------------------------------------------------*/
51 /* ECAP CTL1 constant definitions                                                                          */
52 /*---------------------------------------------------------------------------------------------------------*/
53 #define ECAP_RISING_EDGE                       (0UL<<ECAP_CTL1_EDGESEL0_Pos)   /*!< ECAP capture rising edge selection                      \hideinitializer */
54 #define ECAP_FALLING_EDGE                      (1UL<<ECAP_CTL1_EDGESEL0_Pos)   /*!< ECAP capture falling edge selection                     \hideinitializer */
55 #define ECAP_RISING_FALLING_EDGE               (2UL<<ECAP_CTL1_EDGESEL0_Pos)   /*!< ECAP capture either rising or falling edge selection    \hideinitializer */
56 
57 #define ECAP_CAPTURE_TIMER_CLKDIV_1            (0UL<<ECAP_CTL1_CLKSEL_Pos)    /*!< ECAP capture timer clock divide by 1   \hideinitializer */
58 #define ECAP_CAPTURE_TIMER_CLKDIV_4            (1UL<<ECAP_CTL1_CLKSEL_Pos)    /*!< ECAP capture timer clock divide by 4   \hideinitializer */
59 #define ECAP_CAPTURE_TIMER_CLKDIV_16           (2UL<<ECAP_CTL1_CLKSEL_Pos)    /*!< ECAP capture timer clock divide by 16  \hideinitializer */
60 #define ECAP_CAPTURE_TIMER_CLKDIV_32           (3UL<<ECAP_CTL1_CLKSEL_Pos)    /*!< ECAP capture timer clock divide by 32  \hideinitializer */
61 #define ECAP_CAPTURE_TIMER_CLKDIV_64           (4UL<<ECAP_CTL1_CLKSEL_Pos)    /*!< ECAP capture timer clock divide by 64  \hideinitializer */
62 #define ECAP_CAPTURE_TIMER_CLKDIV_96           (5UL<<ECAP_CTL1_CLKSEL_Pos)    /*!< ECAP capture timer clock divide by 96  \hideinitializer */
63 #define ECAP_CAPTURE_TIMER_CLKDIV_112          (6UL<<ECAP_CTL1_CLKSEL_Pos)    /*!< ECAP capture timer clock divide by 112 \hideinitializer */
64 #define ECAP_CAPTURE_TIMER_CLKDIV_128          (7UL<<ECAP_CTL1_CLKSEL_Pos)    /*!< ECAP capture timer clock divide by 128 \hideinitializer */
65 
66 #define ECAP_CAPTURE_TIMER_CLK_SRC_CAP_CLK     (0UL<<ECAP_CTL1_CNTSRCSEL_Pos)    /*!< ECAP capture timer/clock source from CAP_CLK \hideinitializer */
67 #define ECAP_CAPTURE_TIMER_CLK_SRC_CAP0        (1UL<<ECAP_CTL1_CNTSRCSEL_Pos)    /*!< ECAP capture timer/clock source from CAP0    \hideinitializer */
68 #define ECAP_CAPTURE_TIMER_CLK_SRC_CAP1        (2UL<<ECAP_CTL1_CNTSRCSEL_Pos)    /*!< ECAP capture timer/clock source from CAP1    \hideinitializer */
69 #define ECAP_CAPTURE_TIMER_CLK_SRC_CAP2        (3UL<<ECAP_CTL1_CNTSRCSEL_Pos)    /*!< ECAP capture timer/clock source from CAP2    \hideinitializer */
70 
71 /*@}*/ /* end of group ECAP_EXPORTED_CONSTANTS */
72 
73 /** @addtogroup ECAP_EXPORTED_FUNCTIONS ECAP Exported Functions
74   @{
75 */
76 
77 /**
78   * @brief This macro is used to select noise filter clock pre-divide number
79   * @param[in] ecap      Specify ECAP port
80   * @param[in] u32ClkSel The noise filter clock divide number
81   *                  - \ref ECAP_NOISE_FILTER_CLKDIV_1
82   *                  - \ref ECAP_NOISE_FILTER_CLKDIV_2
83   *                  - \ref ECAP_NOISE_FILTER_CLKDIV_4
84   *                  - \ref ECAP_NOISE_FILTER_CLKDIV_16
85   *                  - \ref ECAP_NOISE_FILTER_CLKDIV_32
86   *                  - \ref ECAP_NOISE_FILTER_CLKDIV_64
87   * @return None
88   * @details This macro will set the sampling frequency of the noise filter cock.
89   * \hideinitializer
90   */
91 #define ECAP_SET_NOISE_FILTER_CLKDIV(ecap, u32ClkSel) ((ecap)->CTL0 = ((ecap)->CTL0 & ~ECAP_CTL0_NFCLKSEL_Msk)|(u32ClkSel))
92 
93 /**
94   * @brief This macro is used to disable noise filter
95   * @param[in] ecap      Specify ECAP port
96   * @return None
97   * @details This macro will disable the noise filter of input capture.
98   * \hideinitializer
99   */
100 #define ECAP_NOISE_FILTER_DISABLE(ecap) ((ecap)->CTL0 |= ECAP_CTL0_CAPNFDIS_Msk)
101 
102 /**
103   * @brief This macro is used to enable noise filter
104   * @param[in] ecap      Specify ECAP port
105   * @param[in] u32ClkSel Select noise filter clock divide number
106   *                  - \ref ECAP_NOISE_FILTER_CLKDIV_1
107   *                  - \ref ECAP_NOISE_FILTER_CLKDIV_2
108   *                  - \ref ECAP_NOISE_FILTER_CLKDIV_4
109   *                  - \ref ECAP_NOISE_FILTER_CLKDIV_16
110   *                  - \ref ECAP_NOISE_FILTER_CLKDIV_32
111   *                  - \ref ECAP_NOISE_FILTER_CLKDIV_64
112   * @return None
113   * @details This macro will enable the noise filter of input capture and set noise filter clock divide.
114   * \hideinitializer
115   */
116 #define ECAP_NOISE_FILTER_ENABLE(ecap, u32ClkSel) ((ecap)->CTL0 = ((ecap)->CTL0 & ~(ECAP_CTL0_CAPNFDIS_Msk|ECAP_CTL0_NFCLKSEL_Msk))|(u32ClkSel))
117 
118 /**
119   * @brief This macro is used to enable input channel unit
120   * @param[in] ecap      Specify ECAP port
121   * @param[in] u32Mask   The input channel mask
122   *                  - \ref ECAP_CTL0_IC0EN_Msk
123   *                  - \ref ECAP_CTL0_IC1EN_Msk
124   *                  - \ref ECAP_CTL0_IC2EN_Msk
125   * @return None
126   * @details This macro will enable the input channel_n to input capture.
127   * \hideinitializer
128   */
129 #define ECAP_ENABLE_INPUT_CHANNEL(ecap, u32Mask) ((ecap)->CTL0 |= (u32Mask))
130 
131 /**
132   * @brief This macro is used to disable input channel unit
133   * @param[in] ecap      Specify ECAP port
134   * @param[in] u32Mask  The input channel mask
135   *                  - \ref ECAP_CTL0_IC0EN_Msk
136   *                  - \ref ECAP_CTL0_IC1EN_Msk
137   *                  - \ref ECAP_CTL0_IC2EN_Msk
138   * @return None
139   * @details This macro will disable the input channel_n to input capture.
140   * \hideinitializer
141   */
142 #define ECAP_DISABLE_INPUT_CHANNEL(ecap, u32Mask) ((ecap)->CTL0 &= ~(u32Mask))
143 
144 /**
145   * @brief This macro is used to select input channel source
146   * @param[in] ecap      Specify ECAP port
147   * @param[in] u32Index  The input channel number
148   *                  - \ref ECAP_IC0
149   *                  - \ref ECAP_IC1
150   *                  - \ref ECAP_IC2
151   * @param[in] u32Src    The input source
152   *                  - \ref ECAP_CAP_INPUT_SRC_FROM_IC
153   *                  - \ref ECAP_CAP_INPUT_SRC_FROM_CH
154   * @return None
155   * @details This macro will select the input source from ICx, CHx.
156   * \hideinitializer
157   */
158 #define ECAP_SEL_INPUT_SRC(ecap, u32Index, u32Src) ((ecap)->CTL0 = ((ecap)->CTL0 & ~(ECAP_CTL0_CAPSEL0_Msk<<((u32Index)<<1)))|(((u32Src)<<ECAP_CTL0_CAPSEL0_Pos)<<((u32Index)<<1)))
159 
160 /**
161   * @brief This macro is used to enable input channel interrupt
162   * @param[in] ecap      Specify ECAP port
163   * @param[in] u32Mask  The input channel mask
164   *                  - \ref ECAP_CTL0_CAPIEN0_Msk
165   *                  - \ref ECAP_CTL0_CAPIEN1_Msk
166   *                  - \ref ECAP_CTL0_CAPIEN2_Msk
167   * @return None
168   * @details This macro will enable the input channel_n interrupt.
169   * \hideinitializer
170   */
171 #define ECAP_ENABLE_INT(ecap, u32Mask) ((ecap)->CTL0 |= (u32Mask))
172 
173 /**
174   * @brief This macro is used to disable input channel interrupt
175   * @param[in] ecap      Specify ECAP port
176   * @param[in] u32Mask   The input channel mask
177   *                  - \ref ECAP_IC0
178   *                  - \ref ECAP_IC1
179   *                  - \ref ECAP_IC2
180   * @return None
181   * @details This macro will disable the input channel_n interrupt.
182   * \hideinitializer
183   */
184 #define ECAP_DISABLE_INT(ecap, u32Mask) ((ecap)->CTL0 &= ~(u32Mask))
185 
186 /**
187   * @brief This macro is used to enable input channel overflow interrupt
188   * @param[in] ecap      Specify ECAP port
189   * @return None
190   * @details This macro will enable the input channel overflow interrupt.
191   * \hideinitializer
192   */
193 #define ECAP_ENABLE_OVF_INT(ecap) ((ecap)->CTL0 |= ECAP_CTL0_OVIEN_Msk)
194 
195 /**
196   * @brief This macro is used to disable input channel overflow interrupt
197   * @param[in] ecap      Specify ECAP port
198   * @return None
199   * @details This macro will disable the input channel overflow interrupt.
200   * \hideinitializer
201   */
202 #define ECAP_DISABLE_OVF_INT(ecap) ((ecap)->CTL0 &= ~ECAP_CTL0_OVIEN_Msk)
203 
204 /**
205   * @brief This macro is used to enable input channel compare-match interrupt
206   * @param[in] ecap      Specify ECAP port
207   * @return None
208   * @details This macro will enable the input channel compare-match interrupt.
209   * \hideinitializer
210   */
211 #define ECAP_ENABLE_CMP_MATCH_INT(ecap) ((ecap)->CTL0 |= ECAP_CTL0_CMPIEN_Msk)
212 
213 /**
214   * @brief This macro is used to disable input channel compare-match interrupt
215   * @param[in] ecap      Specify ECAP port
216   * @return None
217   * @details This macro will disable the input channel compare-match interrupt.
218   * \hideinitializer
219   */
220 #define ECAP_DISABLE_CMP_MATCH_INT(ecap) ((ecap)->CTL0 &= ~ECAP_CTL0_CMPIEN_Msk)
221 
222 /**
223   * @brief This macro is used to start capture counter
224   * @param[in] ecap      Specify ECAP port
225   * @return None
226   * @details This macro will start capture counter up-counting.
227   * \hideinitializer
228   */
229 #define ECAP_CNT_START(ecap) ((ecap)->CTL0 |= ECAP_CTL0_CNTEN_Msk)
230 
231 /**
232   * @brief This macro is used to stop capture counter
233   * @param[in] ecap      Specify ECAP port
234   * @return None
235   * @details This macro will stop capture counter up-counting.
236   * \hideinitializer
237   */
238 #define ECAP_CNT_STOP(ecap) ((ecap)->CTL0 &= ~ECAP_CTL0_CNTEN_Msk)
239 
240 /**
241   * @brief This macro is used to set event to clear capture counter
242   * @param[in] ecap      Specify ECAP port
243   * @param[in] u32Event The input channel number
244   *                  - \ref ECAP_CTL0_CMPCLREN_Msk
245   *                  - \ref ECAP_CTL1_CAP0RLDEN_Msk
246   *                  - \ref ECAP_CTL1_CAP1RLDEN_Msk
247   *                  - \ref ECAP_CTL1_CAP2RLDEN_Msk
248   *                  - \ref ECAP_CTL1_OVRLDEN_Msk
249 
250   * @return None
251   * @details This macro will enable and select compare or capture event that can clear capture counter.
252   * \hideinitializer
253   */
254 #define ECAP_SET_CNT_CLEAR_EVENT(ecap, u32Event) do{ \
255   if((u32Event) & ECAP_CTL0_CMPCLREN_Msk) \
256     (ecap)->CTL0 |= ECAP_CTL0_CMPCLREN_Msk; \
257   else \
258     (ecap)->CTL0 &= ~ECAP_CTL0_CMPCLREN_Msk; \
259   (ecap)->CTL1 = ((ecap)->CTL1 &~0xF00) | ((u32Event) & 0xF00); \
260   }while(0);
261 
262 /**
263   * @brief This macro is used to enable compare function
264   * @param[in] ecap      Specify ECAP port
265   * @return None
266   * @details This macro will enable the compare function.
267   * \hideinitializer
268   */
269 #define ECAP_ENABLE_CMP(ecap) ((ecap)->CTL0 |= ECAP_CTL0_CMPEN_Msk)
270 
271 /**
272   * @brief This macro is used to disable compare function
273   * @param[in] ecap      Specify ECAP port
274   * @return None
275   * @details This macro will disable the compare function.
276   * \hideinitializer
277   */
278 #define ECAP_DISABLE_CMP(ecap) ((ecap)->CTL0 &= ~ECAP_CTL0_CMPEN_Msk)
279 
280 /**
281   * @brief This macro is used to enable input capture function.
282   * @param[in] ecap      Specify ECAP port
283   * @return None
284   * @details This macro will enable input capture timer/counter.
285   * \hideinitializer
286   */
287 #define ECAP_ENABLE_CNT(ecap) ((ecap)->CTL0 |= ECAP_CTL0_CAPEN_Msk)
288 
289 /**
290   * @brief This macro is used to disable input capture function.
291   * @param[in] ecap      Specify ECAP port
292   * @return None
293   * @details This macro will disable input capture timer/counter.
294   * \hideinitializer
295   */
296 #define ECAP_DISABLE_CNT(ecap) ((ecap)->CTL0 &= ~ECAP_CTL0_CAPEN_Msk)
297 
298 /**
299   * @brief This macro is used to select input channel edge detection
300   * @param[in] ecap      Specify ECAP port
301   * @param[in] u32Index  The input channel number
302   *                  - \ref ECAP_IC0
303   *                  - \ref ECAP_IC1
304   *                  - \ref ECAP_IC2
305   * @param[in] u32Edge   The input source
306   *                  - \ref ECAP_RISING_EDGE
307   *                  - \ref ECAP_FALLING_EDGE
308   *                  - \ref ECAP_RISING_FALLING_EDGE
309   * @return None
310   * @details This macro will select input capture can detect falling edge, rising edge or either rising or falling edge change.
311   * \hideinitializer
312   */
313 #define ECAP_SEL_CAPTURE_EDGE(ecap, u32Index, u32Edge) ((ecap)->CTL1 = ((ecap)->CTL1 & ~(ECAP_CTL1_EDGESEL0_Msk<<((u32Index)<<1)))|((u32Edge)<<((u32Index)<<1)))
314 
315 /**
316   * @brief This macro is used to select ECAP counter reload trigger source
317   * @param[in] ecap      Specify ECAP port
318   * @param[in] u32TrigSrc The input source
319   *                  - \ref ECAP_CTL1_CAP0RLDEN_Msk
320   *                  - \ref ECAP_CTL1_CAP1RLDEN_Msk
321   *                  - \ref ECAP_CTL1_CAP2RLDEN_Msk
322   *                  - \ref ECAP_CTL1_OVRLDEN_Msk
323   * @return None
324   * @details This macro will select capture counter reload trigger source.
325   * \hideinitializer
326   */
327 #define ECAP_SEL_RELOAD_TRIG_SRC(ecap, u32TrigSrc) ((ecap)->CTL1 = ((ecap)->CTL1 & ~0xF00)|(u32TrigSrc))
328 
329 /**
330   * @brief This macro is used to select capture timer clock divide.
331   * @param[in] ecap      Specify ECAP port
332   * @param[in] u32Clkdiv The input source
333   *                  - \ref ECAP_CAPTURE_TIMER_CLKDIV_1
334   *                  - \ref ECAP_CAPTURE_TIMER_CLKDIV_4
335   *                  - \ref ECAP_CAPTURE_TIMER_CLKDIV_16
336   *                  - \ref ECAP_CAPTURE_TIMER_CLKDIV_32
337   *                  - \ref ECAP_CAPTURE_TIMER_CLKDIV_64
338   *                  - \ref ECAP_CAPTURE_TIMER_CLKDIV_96
339   *                  - \ref ECAP_CAPTURE_TIMER_CLKDIV_112
340   *                  - \ref ECAP_CAPTURE_TIMER_CLKDIV_128
341   * @return None
342   * @details This macro will select capture timer clock has a pre-divider with eight divided option.
343   * \hideinitializer
344   */
345 #define ECAP_SEL_TIMER_CLK_DIV(ecap, u32Clkdiv) ((ecap)->CTL1 = ((ecap)->CTL1 & ~ECAP_CTL1_CLKSEL_Msk)|(u32Clkdiv))
346 
347 /**
348   * @brief This macro is used to select capture timer/counter clock source
349   * @param[in] ecap      Specify ECAP port
350   * @param[in] u32ClkSrc The input source
351   *                  - \ref ECAP_CAPTURE_TIMER_CLK_SRC_CAP_CLK
352   *                  - \ref ECAP_CAPTURE_TIMER_CLK_SRC_CAP0
353   *                  - \ref ECAP_CAPTURE_TIMER_CLK_SRC_CAP1
354   *                  - \ref ECAP_CAPTURE_TIMER_CLK_SRC_CAP2
355   * @return None
356   * @details This macro will select capture timer/clock clock source.
357   * \hideinitializer
358   */
359 #define ECAP_SEL_TIMER_CLK_SRC(ecap, u32ClkSrc) ((ecap)->CTL1 = ((ecap)->CTL1 & ~ECAP_CTL1_CNTSRCSEL_Msk)|(u32ClkSrc))
360 
361 /**
362   * @brief This macro is used to read input capture status
363   * @param[in] ecap      Specify ECAP port
364   * @return Input capture status flags
365   * @details This macro will get the input capture interrupt status.
366   * \hideinitializer
367   */
368 #define ECAP_GET_INT_STATUS(ecap) ((ecap)->STATUS)
369 
370 /**
371   * @brief This macro is used to get input channel interrupt flag
372   * @param[in] ecap      Specify ECAP port
373   * @param[in] u32Mask  The input channel mask
374   *                  - \ref ECAP_STATUS_CAPTF0_Msk
375   *                  - \ref ECAP_STATUS_CAPTF1_Msk
376   *                  - \ref ECAP_STATUS_CAPTF2_Msk
377   *                  - \ref ECAP_STATUS_CAPOVF_Msk
378   *                  - \ref ECAP_STATUS_CAPCMPF_Msk
379   * @return None
380   * @details This macro will write 1 to get the input channel_n interrupt flag.
381   * \hideinitializer
382   */
383 #define ECAP_GET_CAPTURE_FLAG(ecap, u32Mask) (((ecap)->STATUS & (u32Mask))?1:0)
384 
385 /**
386   * @brief This macro is used to clear input channel interrupt flag
387   * @param[in] ecap      Specify ECAP port
388   * @param[in] u32Mask  The input channel mask
389   *                  - \ref ECAP_STATUS_CAPTF0_Msk
390   *                  - \ref ECAP_STATUS_CAPTF1_Msk
391   *                  - \ref ECAP_STATUS_CAPTF2_Msk
392   *                  - \ref ECAP_STATUS_CAPOVF_Msk
393   *                  - \ref ECAP_STATUS_CAPCMPF_Msk
394   * @return None
395   * @details This macro will write 1 to clear the input channel_n interrupt flag.
396   * \hideinitializer
397   */
398 #define ECAP_CLR_CAPTURE_FLAG(ecap, u32Mask) ((ecap)->STATUS = (u32Mask))
399 
400 /**
401   * @brief This macro is used to set input capture counter value
402   * @param[in] ecap      Specify ECAP port
403   * @param[in] u32Val    Counter value
404   * @return None
405   * @details This macro will set a counter value of input capture.
406   * \hideinitializer
407   */
408 #define ECAP_SET_CNT_VALUE(ecap, u32Val) ((ecap)->CNT = (u32Val))
409 
410 /**
411   * @brief This macro is used to get input capture counter value
412   * @param[in] ecap      Specify ECAP port
413   * @return Capture counter value
414   * @details This macro will get a counter value of input capture.
415   * \hideinitializer
416   */
417 #define ECAP_GET_CNT_VALUE(ecap) ((ecap)->CNT)
418 
419 /**
420   * @brief This macro is used to get input capture counter hold value
421   * @param[in] ecap      Specify ECAP port
422   * @param[in] u32Index  The input channel number
423   *                  - \ref ECAP_IC0
424   *                  - \ref ECAP_IC1
425   *                  - \ref ECAP_IC2
426   * @return Capture counter hold value
427   * @details This macro will get a hold value of input capture channel_n.
428   * \hideinitializer
429   */
430 #define ECAP_GET_CNT_HOLD_VALUE(ecap, u32Index) (*(__IO uint32_t *) (&((ecap)->HLD0) + (u32Index)))
431 
432 /**
433   * @brief This macro is used to set input capture counter compare value
434   * @param[in] ecap      Specify ECAP port
435   * @param[in] u32Val    Input capture compare value
436   * @return None
437   * @details This macro will set a compare value of input capture counter.
438   * \hideinitializer
439   */
440 #define ECAP_SET_CNT_CMP(ecap, u32Val) ((ecap)->CNTCMP = (u32Val))
441 
442 void ECAP_Open(ECAP_T* ecap, uint32_t u32FuncMask);
443 void ECAP_Close(ECAP_T* ecap);
444 void ECAP_EnableINT(ECAP_T* ecap, uint32_t u32Mask);
445 void ECAP_DisableINT(ECAP_T* ecap, uint32_t u32Mask);
446 /*@}*/ /* end of group ECAP_EXPORTED_FUNCTIONS */
447 
448 /*@}*/ /* end of group ECAP_Driver */
449 
450 /*@}*/ /* end of group Standard_Driver */
451 
452 #ifdef __cplusplus
453 }
454 #endif
455 
456 #endif /* __ECAP_H__ */
457 
458 /*** (C) COPYRIGHT 2016 Nuvoton Technology Corp. ***/
459