nu_acmp.h 19 KB

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