nu_ecap.h 19 KB

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