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