acmp.h 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414
  1. /**************************************************************************//**
  2. * @file ACMP.h
  3. * @version V1.00
  4. * @brief M480 Series ACMP Driver Header File
  5. *
  6. * @copyright (C) 2016 Nuvoton Technology Corp. All rights reserved.
  7. ******************************************************************************/
  8. #ifndef __ACMP_H__
  9. #define __ACMP_H__
  10. #ifdef __cplusplus
  11. extern "C"
  12. {
  13. #endif
  14. /** @addtogroup Standard_Driver Standard Driver
  15. @{
  16. */
  17. /** @addtogroup ACMP_Driver ACMP Driver
  18. @{
  19. */
  20. /** @addtogroup ACMP_EXPORTED_CONSTANTS ACMP Exported Constants
  21. @{
  22. */
  23. /*---------------------------------------------------------------------------------------------------------*/
  24. /* ACMP_CTL constant definitions */
  25. /*---------------------------------------------------------------------------------------------------------*/
  26. #define ACMP_CTL_FILTSEL_OFF (0UL << ACMP_CTL_FILTSEL_Pos) /*!< ACMP_CTL setting for filter function disabled. \hideinitializer */
  27. #define ACMP_CTL_FILTSEL_1PCLK (1UL << ACMP_CTL_FILTSEL_Pos) /*!< ACMP_CTL setting for 1 PCLK filter count. \hideinitializer */
  28. #define ACMP_CTL_FILTSEL_2PCLK (2UL << ACMP_CTL_FILTSEL_Pos) /*!< ACMP_CTL setting for 2 PCLK filter count. \hideinitializer */
  29. #define ACMP_CTL_FILTSEL_4PCLK (3UL << ACMP_CTL_FILTSEL_Pos) /*!< ACMP_CTL setting for 4 PCLK filter count. \hideinitializer */
  30. #define ACMP_CTL_FILTSEL_8PCLK (4UL << ACMP_CTL_FILTSEL_Pos) /*!< ACMP_CTL setting for 8 PCLK filter count. \hideinitializer */
  31. #define ACMP_CTL_FILTSEL_16PCLK (5UL << ACMP_CTL_FILTSEL_Pos) /*!< ACMP_CTL setting for 16 PCLK filter count. \hideinitializer */
  32. #define ACMP_CTL_FILTSEL_32PCLK (6UL << ACMP_CTL_FILTSEL_Pos) /*!< ACMP_CTL setting for 32 PCLK filter count. \hideinitializer */
  33. #define ACMP_CTL_FILTSEL_64PCLK (7UL << ACMP_CTL_FILTSEL_Pos) /*!< ACMP_CTL setting for 64 PCLK filter count. \hideinitializer */
  34. #define ACMP_CTL_INTPOL_RF (0UL << ACMP_CTL_INTPOL_Pos) /*!< ACMP_CTL setting for selecting rising edge and falling edge as interrupt condition. \hideinitializer */
  35. #define ACMP_CTL_INTPOL_R (1UL << ACMP_CTL_INTPOL_Pos) /*!< ACMP_CTL setting for selecting rising edge as interrupt condition. \hideinitializer */
  36. #define ACMP_CTL_INTPOL_F (2UL << ACMP_CTL_INTPOL_Pos) /*!< ACMP_CTL setting for selecting falling edge as interrupt condition. \hideinitializer */
  37. #define ACMP_CTL_POSSEL_P0 (0UL << ACMP_CTL_POSSEL_Pos) /*!< ACMP_CTL setting for selecting ACMPx_P0 pin as the source of ACMP V+. \hideinitializer */
  38. #define ACMP_CTL_POSSEL_P1 (1UL << ACMP_CTL_POSSEL_Pos) /*!< ACMP_CTL setting for selecting ACMPx_P1 pin as the source of ACMP V+. \hideinitializer */
  39. #define ACMP_CTL_POSSEL_P2 (2UL << ACMP_CTL_POSSEL_Pos) /*!< ACMP_CTL setting for selecting ACMPx_P2 pin as the source of ACMP V+. \hideinitializer */
  40. #define ACMP_CTL_POSSEL_P3 (3UL << ACMP_CTL_POSSEL_Pos) /*!< ACMP_CTL setting for selecting ACMPx_P3 pin as the source of ACMP V+. \hideinitializer */
  41. #define ACMP_CTL_NEGSEL_PIN (0UL << ACMP_CTL_NEGSEL_Pos) /*!< ACMP_CTL setting for selecting the voltage of ACMP negative input pin as the source of ACMP V-. \hideinitializer */
  42. #define ACMP_CTL_NEGSEL_CRV (1UL << ACMP_CTL_NEGSEL_Pos) /*!< ACMP_CTL setting for selecting internal comparator reference voltage as the source of ACMP V-. \hideinitializer */
  43. #define ACMP_CTL_NEGSEL_VBG (2UL << ACMP_CTL_NEGSEL_Pos) /*!< ACMP_CTL setting for selecting internal Band-gap voltage as the source of ACMP V-. \hideinitializer */
  44. #define ACMP_CTL_NEGSEL_DAC (3UL << ACMP_CTL_NEGSEL_Pos) /*!< ACMP_CTL setting for selecting DAC output voltage as the source of ACMP V-. \hideinitializer */
  45. #define ACMP_CTL_HYSTERESIS_30MV (3UL << ACMP_CTL_HYSSEL_Pos) /*!< ACMP_CTL setting for enabling the hysteresis function at 30mV. \hideinitializer */
  46. #define ACMP_CTL_HYSTERESIS_20MV (2UL << ACMP_CTL_HYSSEL_Pos) /*!< ACMP_CTL setting for enabling the hysteresis function at 20mV. \hideinitializer */
  47. #define ACMP_CTL_HYSTERESIS_10MV (1UL << ACMP_CTL_HYSSEL_Pos) /*!< ACMP_CTL setting for enabling the hysteresis function at 10mV. \hideinitializer */
  48. #define ACMP_CTL_HYSTERESIS_DISABLE (0UL << ACMP_CTL_HYSSEL_Pos) /*!< ACMP_CTL setting for disabling the hysteresis function. \hideinitializer */
  49. /*---------------------------------------------------------------------------------------------------------*/
  50. /* ACMP_VREF constant definitions */
  51. /*---------------------------------------------------------------------------------------------------------*/
  52. #define ACMP_VREF_CRVSSEL_VDDA (0UL << ACMP_VREF_CRVSSEL_Pos) /*!< ACMP_VREF setting for selecting analog supply voltage VDDA as the CRV source voltage \hideinitializer */
  53. #define ACMP_VREF_CRVSSEL_INTVREF (1UL << ACMP_VREF_CRVSSEL_Pos) /*!< ACMP_VREF setting for selecting internal reference voltage as the CRV source voltage \hideinitializer */
  54. /*@}*/ /* end of group ACMP_EXPORTED_CONSTANTS */
  55. /** @addtogroup ACMP_EXPORTED_FUNCTIONS ACMP Exported Functions
  56. @{
  57. */
  58. /*---------------------------------------------------------------------------------------------------------*/
  59. /* Define Macros and functions */
  60. /*---------------------------------------------------------------------------------------------------------*/
  61. /**
  62. * @brief This macro is used to enable output inverse function
  63. * @param[in] acmp The pointer of the specified ACMP module
  64. * @param[in] u32ChNum The ACMP number
  65. * @return None
  66. * @details This macro will set ACMPOINV bit of ACMP_CTL register to enable output inverse function.
  67. * \hideinitializer
  68. */
  69. #define ACMP_ENABLE_OUTPUT_INVERSE(acmp, u32ChNum) ((acmp)->CTL[(u32ChNum)] |= ACMP_CTL_ACMPOINV_Msk)
  70. /**
  71. * @brief This macro is used to disable output inverse function
  72. * @param[in] acmp The pointer of the specified ACMP module
  73. * @param[in] u32ChNum The ACMP number
  74. * @return None
  75. * @details This macro will clear ACMPOINV bit of ACMP_CTL register to disable output inverse function.
  76. * \hideinitializer
  77. */
  78. #define ACMP_DISABLE_OUTPUT_INVERSE(acmp, u32ChNum) ((acmp)->CTL[(u32ChNum)] &= ~ACMP_CTL_ACMPOINV_Msk)
  79. /**
  80. * @brief This macro is used to select ACMP negative input source
  81. * @param[in] acmp The pointer of the specified ACMP module
  82. * @param[in] u32ChNum The ACMP number
  83. * @param[in] u32Src is comparator negative input selection. Including:
  84. * - \ref ACMP_CTL_NEGSEL_PIN
  85. * - \ref ACMP_CTL_NEGSEL_CRV
  86. * - \ref ACMP_CTL_NEGSEL_VBG
  87. * - \ref ACMP_CTL_NEGSEL_DAC
  88. * @return None
  89. * @details This macro will set NEGSEL (ACMP_CTL[5:4]) to determine the source of negative input.
  90. * \hideinitializer
  91. */
  92. #define ACMP_SET_NEG_SRC(acmp, u32ChNum, u32Src) ((acmp)->CTL[(u32ChNum)] = ((acmp)->CTL[(u32ChNum)] & ~ACMP_CTL_NEGSEL_Msk) | (u32Src))
  93. /**
  94. * @brief This macro is used to enable hysteresis function and set hysteresis to 30mV
  95. * @param[in] acmp The pointer of the specified ACMP module
  96. * @param[in] u32ChNum The ACMP number
  97. * @return None
  98. * \hideinitializer
  99. */
  100. #define ACMP_ENABLE_HYSTERESIS(acmp, u32ChNum) ((acmp)->CTL[(u32ChNum)] |= ACMP_CTL_HYSTERESIS_30MV)
  101. /**
  102. * @brief This macro is used to disable hysteresis function
  103. * @param[in] acmp The pointer of the specified ACMP module
  104. * @param[in] u32ChNum The ACMP number
  105. * @return None
  106. * @details This macro will clear HYSEL bits of ACMP_CTL register to disable hysteresis function.
  107. * \hideinitializer
  108. */
  109. #define ACMP_DISABLE_HYSTERESIS(acmp, u32ChNum) ((acmp)->CTL[(u32ChNum)] &= ~ACMP_CTL_HYSSEL_Msk)
  110. /**
  111. * @brief This macro is used to select hysteresis level
  112. * @param[in] acmp The pointer of the specified ACMP module
  113. * @param[in] u32ChNum The ACMP number
  114. * @param[in] u32HysSel The hysteresis function option. Including:
  115. * - \ref ACMP_CTL_HYSTERESIS_30MV
  116. * - \ref ACMP_CTL_HYSTERESIS_20MV
  117. * - \ref ACMP_CTL_HYSTERESIS_10MV
  118. * - \ref ACMP_CTL_HYSTERESIS_DISABLE
  119. * \hideinitializer
  120. * @return None
  121. */
  122. #define ACMP_CONFIG_HYSTERESIS(acmp, u32ChNum, u32HysSel) ((acmp)->CTL[(u32ChNum)] = ((acmp)->CTL[(u32ChNum)] & ~ACMP_CTL_HYSSEL_Msk) | (u32HysSel))
  123. /**
  124. * @brief This macro is used to enable interrupt
  125. * @param[in] acmp The pointer of the specified ACMP module
  126. * @param[in] u32ChNum The ACMP number
  127. * @return None
  128. * @details This macro will set ACMPIE bit of ACMP_CTL register to enable interrupt function.
  129. * If wake-up function is enabled, the wake-up interrupt will be enabled as well.
  130. * \hideinitializer
  131. */
  132. #define ACMP_ENABLE_INT(acmp, u32ChNum) ((acmp)->CTL[(u32ChNum)] |= ACMP_CTL_ACMPIE_Msk)
  133. /**
  134. * @brief This macro is used to disable interrupt
  135. * @param[in] acmp The pointer of the specified ACMP module
  136. * @param[in] u32ChNum The ACMP number
  137. * @return None
  138. * @details This macro will clear ACMPIE bit of ACMP_CTL register to disable interrupt function.
  139. * \hideinitializer
  140. */
  141. #define ACMP_DISABLE_INT(acmp, u32ChNum) ((acmp)->CTL[(u32ChNum)] &= ~ACMP_CTL_ACMPIE_Msk)
  142. /**
  143. * @brief This macro is used to enable ACMP
  144. * @param[in] acmp The pointer of the specified ACMP module
  145. * @param[in] u32ChNum The ACMP number
  146. * @return None
  147. * @details This macro will set ACMPEN bit of ACMP_CTL register to enable analog comparator.
  148. * \hideinitializer
  149. */
  150. #define ACMP_ENABLE(acmp, u32ChNum) ((acmp)->CTL[(u32ChNum)] |= ACMP_CTL_ACMPEN_Msk)
  151. /**
  152. * @brief This macro is used to disable ACMP
  153. * @param[in] acmp The pointer of the specified ACMP module
  154. * @param[in] u32ChNum The ACMP number
  155. * @return None
  156. * @details This macro will clear ACMPEN bit of ACMP_CTL register to disable analog comparator.
  157. * \hideinitializer
  158. */
  159. #define ACMP_DISABLE(acmp, u32ChNum) ((acmp)->CTL[(u32ChNum)] &= ~ACMP_CTL_ACMPEN_Msk)
  160. /**
  161. * @brief This macro is used to get ACMP output value
  162. * @param[in] acmp The pointer of the specified ACMP module
  163. * @param[in] u32ChNum The ACMP number
  164. * @return ACMP output value
  165. * @details This macro will return the ACMP output value.
  166. * \hideinitializer
  167. */
  168. #define ACMP_GET_OUTPUT(acmp, u32ChNum) (((acmp)->STATUS & (ACMP_STATUS_ACMPO0_Msk<<((u32ChNum))))?1:0)
  169. /**
  170. * @brief This macro is used to get ACMP interrupt flag
  171. * @param[in] acmp The pointer of the specified ACMP module
  172. * @param[in] u32ChNum The ACMP number
  173. * @return ACMP interrupt occurred (1) or not (0)
  174. * @details This macro will return the ACMP interrupt flag.
  175. * \hideinitializer
  176. */
  177. #define ACMP_GET_INT_FLAG(acmp, u32ChNum) (((acmp)->STATUS & (ACMP_STATUS_ACMPIF0_Msk<<((u32ChNum))))?1:0)
  178. /**
  179. * @brief This macro is used to clear ACMP interrupt flag
  180. * @param[in] acmp The pointer of the specified ACMP module
  181. * @param[in] u32ChNum The ACMP number
  182. * @return None
  183. * @details This macro will write 1 to ACMPIFn bit of ACMP_STATUS register to clear interrupt flag.
  184. * \hideinitializer
  185. */
  186. #define ACMP_CLR_INT_FLAG(acmp, u32ChNum) ((acmp)->STATUS = (ACMP_STATUS_ACMPIF0_Msk<<((u32ChNum))))
  187. /**
  188. * @brief This macro is used to clear ACMP wake-up interrupt flag
  189. * @param[in] acmp The pointer of the specified ACMP module
  190. * @param[in] u32ChNum The ACMP number
  191. * @return None
  192. * @details This macro will write 1 to WKIFn bit of ACMP_STATUS register to clear interrupt flag.
  193. * \hideinitializer
  194. */
  195. #define ACMP_CLR_WAKEUP_INT_FLAG(acmp, u32ChNum) ((acmp)->STATUS = (ACMP_STATUS_WKIF0_Msk<<((u32ChNum))))
  196. /**
  197. * @brief This macro is used to enable ACMP wake-up function
  198. * @param[in] acmp The pointer of the specified ACMP module
  199. * @param[in] u32ChNum The ACMP number
  200. * @return None
  201. * @details This macro will set WKEN (ACMP_CTL[16]) to enable ACMP wake-up function.
  202. * \hideinitializer
  203. */
  204. #define ACMP_ENABLE_WAKEUP(acmp, u32ChNum) ((acmp)->CTL[(u32ChNum)] |= ACMP_CTL_WKEN_Msk)
  205. /**
  206. * @brief This macro is used to disable ACMP wake-up function
  207. * @param[in] acmp The pointer of the specified ACMP module
  208. * @param[in] u32ChNum The ACMP number
  209. * @return None
  210. * @details This macro will clear WKEN (ACMP_CTL[16]) to disable ACMP wake-up function.
  211. * \hideinitializer
  212. */
  213. #define ACMP_DISABLE_WAKEUP(acmp, u32ChNum) ((acmp)->CTL[(u32ChNum)] &= ~ACMP_CTL_WKEN_Msk)
  214. /**
  215. * @brief This macro is used to select ACMP positive input pin
  216. * @param[in] acmp The pointer of the specified ACMP module
  217. * @param[in] u32ChNum The ACMP number
  218. * @param[in] u32Pin Comparator positive pin selection. Including:
  219. * - \ref ACMP_CTL_POSSEL_P0
  220. * - \ref ACMP_CTL_POSSEL_P1
  221. * - \ref ACMP_CTL_POSSEL_P2
  222. * - \ref ACMP_CTL_POSSEL_P3
  223. * @return None
  224. * @details This macro will set POSSEL (ACMP_CTL[7:6]) to determine the comparator positive input pin.
  225. * \hideinitializer
  226. */
  227. #define ACMP_SELECT_P(acmp, u32ChNum, u32Pin) ((acmp)->CTL[(u32ChNum)] = ((acmp)->CTL[(u32ChNum)] & ~ACMP_CTL_POSSEL_Msk) | (u32Pin))
  228. /**
  229. * @brief This macro is used to enable ACMP filter function
  230. * @param[in] acmp The pointer of the specified ACMP module
  231. * @param[in] u32ChNum The ACMP number
  232. * @return None
  233. * @details This macro will set OUTSEL (ACMP_CTL[12]) to enable output filter function.
  234. * \hideinitializer
  235. */
  236. #define ACMP_ENABLE_FILTER(acmp, u32ChNum) ((acmp)->CTL[(u32ChNum)] |= ACMP_CTL_OUTSEL_Msk)
  237. /**
  238. * @brief This macro is used to disable ACMP filter function
  239. * @param[in] acmp The pointer of the specified ACMP module
  240. * @param[in] u32ChNum The ACMP number
  241. * @return None
  242. * @details This macro will clear OUTSEL (ACMP_CTL[12]) to disable output filter function.
  243. * \hideinitializer
  244. */
  245. #define ACMP_DISABLE_FILTER(acmp, u32ChNum) ((acmp)->CTL[(u32ChNum)] &= ~ACMP_CTL_OUTSEL_Msk)
  246. /**
  247. * @brief This macro is used to set ACMP filter function
  248. * @param[in] acmp The pointer of the specified ACMP module
  249. * @param[in] u32ChNum The ACMP number
  250. * @param[in] u32Cnt is comparator filter count setting.
  251. * - \ref ACMP_CTL_FILTSEL_OFF
  252. * - \ref ACMP_CTL_FILTSEL_1PCLK
  253. * - \ref ACMP_CTL_FILTSEL_2PCLK
  254. * - \ref ACMP_CTL_FILTSEL_4PCLK
  255. * - \ref ACMP_CTL_FILTSEL_8PCLK
  256. * - \ref ACMP_CTL_FILTSEL_16PCLK
  257. * - \ref ACMP_CTL_FILTSEL_32PCLK
  258. * - \ref ACMP_CTL_FILTSEL_64PCLK
  259. * @return None
  260. * @details When ACMP output filter function is enabled, the output sampling count is determined by FILTSEL (ACMP_CTL[15:13]).
  261. * \hideinitializer
  262. */
  263. #define ACMP_SET_FILTER(acmp, u32ChNum, u32Cnt) ((acmp)->CTL[(u32ChNum)] = ((acmp)->CTL[(u32ChNum)] & ~ACMP_CTL_FILTSEL_Msk) | (u32Cnt))
  264. /**
  265. * @brief This macro is used to select comparator reference voltage
  266. * @param[in] acmp The pointer of the specified ACMP module
  267. * @param[in] u32Level The comparator reference voltage setting.
  268. * The formula is:
  269. * comparator reference voltage = CRV source voltage x (1/6 + u32Level/24)
  270. * The range of u32Level is 0 ~ 15.
  271. * @return None
  272. * @details When CRV is selected as ACMP negative input source, the CRV level is determined by CRVCTL (ACMP_VREF[3:0]).
  273. * \hideinitializer
  274. */
  275. #define ACMP_CRV_SEL(acmp, u32Level) ((acmp)->VREF = ((acmp)->VREF & ~ACMP_VREF_CRVCTL_Msk) | ((u32Level)<<ACMP_VREF_CRVCTL_Pos))
  276. /**
  277. * @brief This macro is used to select the source of CRV
  278. * @param[in] acmp The pointer of the specified ACMP module
  279. * @param[in] u32Src is the source of CRV. Including:
  280. * - \ref ACMP_VREF_CRVSSEL_VDDA
  281. * - \ref ACMP_VREF_CRVSSEL_INTVREF
  282. * @return None
  283. * @details The source of CRV can be VDDA or internal reference voltage. The internal reference voltage level is determined by SYS_VREFCTL register.
  284. * \hideinitializer
  285. */
  286. #define ACMP_SELECT_CRV_SRC(acmp, u32Src) ((acmp)->VREF = ((acmp)->VREF & ~ACMP_VREF_CRVSSEL_Msk) | (u32Src))
  287. /**
  288. * @brief This macro is used to select ACMP interrupt condition
  289. * @param[in] acmp The pointer of the specified ACMP module
  290. * @param[in] u32ChNum The ACMP number
  291. * @param[in] u32Cond Comparator interrupt condition selection. Including:
  292. * - \ref ACMP_CTL_INTPOL_RF
  293. * - \ref ACMP_CTL_INTPOL_R
  294. * - \ref ACMP_CTL_INTPOL_F
  295. * @return None
  296. * @details The ACMP output interrupt condition can be rising edge, falling edge or any edge.
  297. * \hideinitializer
  298. */
  299. #define ACMP_SELECT_INT_COND(acmp, u32ChNum, u32Cond) ((acmp)->CTL[(u32ChNum)] = ((acmp)->CTL[(u32ChNum)] & ~ACMP_CTL_INTPOL_Msk) | (u32Cond))
  300. /**
  301. * @brief This macro is used to enable ACMP window latch mode
  302. * @param[in] acmp The pointer of the specified ACMP module
  303. * @param[in] u32ChNum The ACMP number
  304. * @return None
  305. * @details This macro will set WLATEN (ACMP_CTL[17]) to enable ACMP window latch mode.
  306. * When ACMP0/1_WLAT pin is at high level, ACMPO0/1 passes through window latch
  307. * block; when ACMP0/1_WLAT pin is at low level, the output of window latch block,
  308. * WLATOUT, is frozen.
  309. * \hideinitializer
  310. */
  311. #define ACMP_ENABLE_WINDOW_LATCH(acmp, u32ChNum) ((acmp)->CTL[(u32ChNum)] |= ACMP_CTL_WLATEN_Msk)
  312. /**
  313. * @brief This macro is used to disable ACMP window latch mode
  314. * @param[in] acmp The pointer of the specified ACMP module
  315. * @param[in] u32ChNum The ACMP number
  316. * @return None
  317. * @details This macro will clear WLATEN (ACMP_CTL[17]) to disable ACMP window latch mode.
  318. * \hideinitializer
  319. */
  320. #define ACMP_DISABLE_WINDOW_LATCH(acmp, u32ChNum) ((acmp)->CTL[(u32ChNum)] &= ~ACMP_CTL_WLATEN_Msk)
  321. /**
  322. * @brief This macro is used to enable ACMP window compare mode
  323. * @param[in] acmp The pointer of the specified ACMP module
  324. * @param[in] u32ChNum The ACMP number
  325. * @return None
  326. * @details This macro will set WCMPSEL (ACMP_CTL[18]) to enable ACMP window compare mode.
  327. * When window compare mode is enabled, user can connect the specific analog voltage
  328. * source to either the positive inputs of both comparators or the negative inputs of
  329. * both comparators. The upper bound and lower bound of the designated range are
  330. * determined by the voltages applied to the other inputs of both comparators. If the
  331. * output of a comparator is low and the other comparator outputs high, which means two
  332. * comparators implies the upper and lower bound. User can directly monitor a specific
  333. * analog voltage source via ACMPWO (ACMP_STATUS[16]).
  334. * \hideinitializer
  335. */
  336. #define ACMP_ENABLE_WINDOW_COMPARE(acmp, u32ChNum) ((acmp)->CTL[(u32ChNum)] |= ACMP_CTL_WCMPSEL_Msk)
  337. /**
  338. * @brief This macro is used to disable ACMP window compare mode
  339. * @param[in] acmp The pointer of the specified ACMP module
  340. * @param[in] u32ChNum The ACMP number
  341. * @return None
  342. * @details This macro will clear WCMPSEL (ACMP_CTL[18]) to disable ACMP window compare mode.
  343. * \hideinitializer
  344. */
  345. #define ACMP_DISABLE_WINDOW_COMPARE(acmp, u32ChNum) ((acmp)->CTL[(u32ChNum)] &= ~ACMP_CTL_WCMPSEL_Msk)
  346. /* Function prototype declaration */
  347. void ACMP_Open(ACMP_T *acmp, uint32_t u32ChNum, uint32_t u32NegSrc, uint32_t u32HysSel);
  348. void ACMP_Close(ACMP_T *acmp, uint32_t u32ChNum);
  349. /*@}*/ /* end of group ACMP_EXPORTED_FUNCTIONS */
  350. /*@}*/ /* end of group ACMP_Driver */
  351. /*@}*/ /* end of group Standard_Driver */
  352. #ifdef __cplusplus
  353. }
  354. #endif
  355. #endif /* __ACMP_H__ */
  356. /*** (C) COPYRIGHT 2016 Nuvoton Technology Corp. ***/