ecap.h 19 KB

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