acmp_reg.h 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240
  1. /**************************************************************************//**
  2. * @file acmp_reg.h
  3. * @version V1.00
  4. * @brief ACMP register definition header file
  5. *
  6. * SPDX-License-Identifier: Apache-2.0
  7. * @copyright (C) 2017-2020 Nuvoton Technology Corp. All rights reserved.
  8. *****************************************************************************/
  9. #ifndef __ACMP_REG_H__
  10. #define __ACMP_REG_H__
  11. #if defined ( __CC_ARM )
  12. #pragma anon_unions
  13. #endif
  14. /**
  15. @addtogroup REGISTER Control Register
  16. @{
  17. */
  18. /**
  19. @addtogroup ACMP Analog Comparator Controller(ACMP)
  20. Memory Mapped Structure for ACMP Controller
  21. @{ */
  22. typedef struct
  23. {
  24. /**
  25. * @var ACMP_T::CTL
  26. * Offset: 0x00~0x04 Analog Comparator 0/1 Control Register
  27. * ---------------------------------------------------------------------------------------------------
  28. * |Bits |Field |Descriptions
  29. * | :----: | :----: | :---- |
  30. * |[0] |ACMPEN |Comparator Enable Bit
  31. * | | |0 = Comparator x Disabled.
  32. * | | |1 = Comparator x Enabled.
  33. * |[1] |ACMPIE |Comparator Interrupt Enable Bit
  34. * | | |0 = Comparator x interrupt Disabled.
  35. * | | |1 = Comparator x interrupt Enabled
  36. * | | |If WKEN (ACMP_CTL0[16]) is set to 1, the wake-up interrupt function will be enabled as well.
  37. * |[3] |ACMPOINV |Comparator Output Inverse
  38. * | | |0 = Comparator x output inverse Disabled.
  39. * | | |1 = Comparator x output inverse Enabled.
  40. * |[5:4] |NEGSEL |Comparator Negative Input Selection
  41. * | | |00 = ACMPx_N pin.
  42. * | | |01 = Internal comparator reference voltage (CRV).
  43. * | | |10 = Band-gap voltage.
  44. * | | |11 = DAC output.
  45. * |[7:6] |POSSEL |Comparator Positive Input Selection
  46. * | | |00 = Input from ACMPx_P0.
  47. * | | |01 = Input from ACMPx_P1.
  48. * | | |10 = Input from ACMPx_P2.
  49. * | | |11 = Input from ACMPx_P3.
  50. * |[9:8] |INTPOL |Interrupt Condition Polarity Selection
  51. * | | |ACMPIFx will be set to 1 when comparator output edge condition is detected.
  52. * | | |00 = Rising edge or falling edge.
  53. * | | |01 = Rising edge.
  54. * | | |10 = Falling edge.
  55. * | | |11 = Reserved.
  56. * |[12] |OUTSEL |Comparator Output Select
  57. * | | |0 = Comparator x output to ACMPx_O pin is unfiltered comparator output.
  58. * | | |1 = Comparator x output to ACMPx_O pin is from filter output.
  59. * |[15:13] |FILTSEL |Comparator Output Filter Count Selection
  60. * | | |000 = Filter function is Disabled.
  61. * | | |001 = ACMPx output is sampled 1 consecutive PCLK.
  62. * | | |010 = ACMPx output is sampled 2 consecutive PCLKs.
  63. * | | |011 = ACMPx output is sampled 4 consecutive PCLKs.
  64. * | | |100 = ACMPx output is sampled 8 consecutive PCLKs.
  65. * | | |101 = ACMPx output is sampled 16 consecutive PCLKs.
  66. * | | |110 = ACMPx output is sampled 32 consecutive PCLKs.
  67. * | | |111 = ACMPx output is sampled 64 consecutive PCLKs.
  68. * |[16] |WKEN |Power-down Wake-up Enable Bit
  69. * | | |0 = Wake-up function Disabled.
  70. * | | |1 = Wake-up function Enabled.
  71. * |[17] |WLATEN |Window Latch Mode Enable Bit
  72. * | | |0 = Window Latch Mode Disabled.
  73. * | | |1 = Window Latch Mode Enabled.
  74. * |[18] |WCMPSEL |Window Compare Mode Selection
  75. * | | |0 = Window Compare Mode Disabled.
  76. * | | |1 = Window Compare Mode is Selected.
  77. * |[25:24] |HYSSEL |Hysteresis Mode Selection
  78. * | | |00 = Hysteresis is 0mV.
  79. * | | |01 = Hysteresis is 10mV.
  80. * | | |10 = Hysteresis is 20mV.
  81. * | | |11 = Hysteresis is 30mV.
  82. * |[29:28] |MODESEL |Propagation Delay Mode Selection
  83. * | | |00 = Max propagation delay is 4.5uS, operation current is 1.2uA.
  84. * | | |01 = Max propagation delay is 2uS, operation current is 3uA.
  85. * | | |10 = Max propagation delay is 600nS, operation current is 10uA.
  86. * | | |11 = Max propagation delay is 200nS, operation current is 75uA.
  87. * @var ACMP_T::STATUS
  88. * Offset: 0x08 Analog Comparator Status Register
  89. * ---------------------------------------------------------------------------------------------------
  90. * |Bits |Field |Descriptions
  91. * | :----: | :----: | :---- |
  92. * |[0] |ACMPIF0 |Comparator 0 Interrupt Flag
  93. * | | |This bit is set by hardware when the edge condition defined by INTPOL (ACMP_CTL0[9:8])
  94. * | | |is detected on comparator 0 output.
  95. * | | |This will generate an interrupt if ACMPIE (ACMP_CTL0[1]) is set to 1.
  96. * | | |Note: Write 1 to clear this bit to 0.
  97. * |[1] |ACMPIF1 |Comparator 1 Interrupt Flag
  98. * | | |This bit is set by hardware when the edge condition defined by INTPOL (ACMP_CTL1[9:8])
  99. * | | |is detected on comparator 1 output.
  100. * | | |This will cause an interrupt if ACMPIE (ACMP_CTL1[1]) is set to 1.
  101. * | | |Note: Write 1 to clear this bit to 0.
  102. * |[4] |ACMPO0 |Comparator 0 Output
  103. * | | |Synchronized to the PCLK to allow reading by software
  104. * | | |Cleared when the comparator 0 is disabled, i.e.
  105. * | | |ACMPEN (ACMP_CTL0[0]) is cleared to 0.
  106. * |[5] |ACMPO1 |Comparator 1 Output
  107. * | | |Synchronized to the PCLK to allow reading by software.
  108. * | | |Cleared when the comparator 1 is disabled, i.e.
  109. * | | |ACMPEN (ACMP_CTL1[0]) is cleared to 0.
  110. * |[8] |WKIF0 |Comparator 0 Power-down Wake-up Interrupt Flag
  111. * | | |This bit will be set to 1 when ACMP0 wake-up interrupt event occurs.
  112. * | | |0 = No power-down wake-up occurred.
  113. * | | |1 = Power-down wake-up occurred.
  114. * | | |Note: Write 1 to clear this bit to 0.
  115. * |[9] |WKIF1 |Comparator 1 Power-down Wake-up Interrupt Flag
  116. * | | |This bit will be set to 1 when ACMP1 wake-up interrupt event occurs.
  117. * | | |0 = No power-down wake-up occurred.
  118. * | | |1 = Power-down wake-up occurred.
  119. * | | |Note: Write 1 to clear this bit to 0.
  120. * |[12] |ACMPS0 |Comparator 0 Status
  121. * | | |Synchronized to the PCLK to allow reading by software
  122. * | | |Cleared when the comparator 0 is disabled, i.e.
  123. * | | |ACMPEN (ACMP_CTL0[0]) is cleared to 0.
  124. * |[13] |ACMPS1 |Comparator 1 Status
  125. * | | |Synchronized to the PCLK to allow reading by software
  126. * | | |Cleared when the comparator 1 is disabled, i.e.
  127. * | | |ACMPEN (ACMP_CTL1[0]) is cleared to 0.
  128. * |[16] |ACMPWO |Comparator Window Output
  129. * | | |This bit shows the output status of window compare mode
  130. * | | |0 = The positive input voltage is outside the window.
  131. * | | |1 = The positive input voltage is in the window.
  132. * @var ACMP_T::VREF
  133. * Offset: 0x0C Analog Comparator Reference Voltage Control Register
  134. * ---------------------------------------------------------------------------------------------------
  135. * |Bits |Field |Descriptions
  136. * | :----: | :----: | :---- |
  137. * |[3:0] |CRVCTL |Comparator Reference Voltage Setting
  138. * | | |CRV = CRV source voltage * (1/6+CRVCTL/24).
  139. * |[6] |CRVSSEL |CRV Source Voltage Selection
  140. * | | |0 = VDDA is selected as CRV source voltage.
  141. * | | |1 = The reference voltage defined by SYS_VREFCTL register is selected as CRV source voltage.
  142. */
  143. __IO uint32_t CTL[2]; /*!< [0x0000~0x0004] Analog Comparator 0/1 Control Register */
  144. __IO uint32_t STATUS; /*!< [0x0008] Analog Comparator Status Register */
  145. __IO uint32_t VREF; /*!< [0x000c] Analog Comparator Reference Voltage Control Register */
  146. } ACMP_T;
  147. /**
  148. @addtogroup ACMP_CONST ACMP Bit Field Definition
  149. Constant Definitions for ACMP Controller
  150. @{ */
  151. #define ACMP_CTL_ACMPEN_Pos (0) /*!< ACMP_T::CTL: ACMPEN Position */
  152. #define ACMP_CTL_ACMPEN_Msk (0x1ul << ACMP_CTL_ACMPEN_Pos) /*!< ACMP_T::CTL: ACMPEN Mask */
  153. #define ACMP_CTL_ACMPIE_Pos (1) /*!< ACMP_T::CTL: ACMPIE Position */
  154. #define ACMP_CTL_ACMPIE_Msk (0x1ul << ACMP_CTL_ACMPIE_Pos) /*!< ACMP_T::CTL: ACMPIE Mask */
  155. #define ACMP_CTL_ACMPOINV_Pos (3) /*!< ACMP_T::CTL: ACMPOINV Position */
  156. #define ACMP_CTL_ACMPOINV_Msk (0x1ul << ACMP_CTL_ACMPOINV_Pos) /*!< ACMP_T::CTL: ACMPOINV Mask */
  157. #define ACMP_CTL_NEGSEL_Pos (4) /*!< ACMP_T::CTL: NEGSEL Position */
  158. #define ACMP_CTL_NEGSEL_Msk (0x3ul << ACMP_CTL_NEGSEL_Pos) /*!< ACMP_T::CTL: NEGSEL Mask */
  159. #define ACMP_CTL_POSSEL_Pos (6) /*!< ACMP_T::CTL: POSSEL Position */
  160. #define ACMP_CTL_POSSEL_Msk (0x3ul << ACMP_CTL_POSSEL_Pos) /*!< ACMP_T::CTL: POSSEL Mask */
  161. #define ACMP_CTL_INTPOL_Pos (8) /*!< ACMP_T::CTL: INTPOL Position */
  162. #define ACMP_CTL_INTPOL_Msk (0x3ul << ACMP_CTL_INTPOL_Pos) /*!< ACMP_T::CTL: INTPOL Mask */
  163. #define ACMP_CTL_OUTSEL_Pos (12) /*!< ACMP_T::CTL: OUTSEL Position */
  164. #define ACMP_CTL_OUTSEL_Msk (0x1ul << ACMP_CTL_OUTSEL_Pos) /*!< ACMP_T::CTL: OUTSEL Mask */
  165. #define ACMP_CTL_FILTSEL_Pos (13) /*!< ACMP_T::CTL: FILTSEL Position */
  166. #define ACMP_CTL_FILTSEL_Msk (0x7ul << ACMP_CTL_FILTSEL_Pos) /*!< ACMP_T::CTL: FILTSEL Mask */
  167. #define ACMP_CTL_WKEN_Pos (16) /*!< ACMP_T::CTL: WKEN Position */
  168. #define ACMP_CTL_WKEN_Msk (0x1ul << ACMP_CTL_WKEN_Pos) /*!< ACMP_T::CTL: WKEN Mask */
  169. #define ACMP_CTL_WLATEN_Pos (17) /*!< ACMP_T::CTL: WLATEN Position */
  170. #define ACMP_CTL_WLATEN_Msk (0x1ul << ACMP_CTL_WLATEN_Pos) /*!< ACMP_T::CTL: WLATEN Mask */
  171. #define ACMP_CTL_WCMPSEL_Pos (18) /*!< ACMP_T::CTL: WCMPSEL Position */
  172. #define ACMP_CTL_WCMPSEL_Msk (0x1ul << ACMP_CTL_WCMPSEL_Pos) /*!< ACMP_T::CTL: WCMPSEL Mask */
  173. #define ACMP_CTL_HYSSEL_Pos (24) /*!< ACMP_T::CTL: HYSSEL Position */
  174. #define ACMP_CTL_HYSSEL_Msk (0x3ul << ACMP_CTL_HYSSEL_Pos) /*!< ACMP_T::CTL: HYSSEL Mask */
  175. #define ACMP_CTL_MODESEL_Pos (28) /*!< ACMP_T::CTL: MODESEL Position */
  176. #define ACMP_CTL_MODESEL_Msk (0x3ul << ACMP_CTL_MODESEL_Pos) /*!< ACMP_T::CTL: MODESEL Mask */
  177. #define ACMP_STATUS_ACMPIF0_Pos (0) /*!< ACMP_T::STATUS: ACMPIF0 Position */
  178. #define ACMP_STATUS_ACMPIF0_Msk (0x1ul << ACMP_STATUS_ACMPIF0_Pos) /*!< ACMP_T::STATUS: ACMPIF0 Mask */
  179. #define ACMP_STATUS_ACMPIF1_Pos (1) /*!< ACMP_T::STATUS: ACMPIF1 Position */
  180. #define ACMP_STATUS_ACMPIF1_Msk (0x1ul << ACMP_STATUS_ACMPIF1_Pos) /*!< ACMP_T::STATUS: ACMPIF1 Mask */
  181. #define ACMP_STATUS_ACMPO0_Pos (4) /*!< ACMP_T::STATUS: ACMPO0 Position */
  182. #define ACMP_STATUS_ACMPO0_Msk (0x1ul << ACMP_STATUS_ACMPO0_Pos) /*!< ACMP_T::STATUS: ACMPO0 Mask */
  183. #define ACMP_STATUS_ACMPO1_Pos (5) /*!< ACMP_T::STATUS: ACMPO1 Position */
  184. #define ACMP_STATUS_ACMPO1_Msk (0x1ul << ACMP_STATUS_ACMPO1_Pos) /*!< ACMP_T::STATUS: ACMPO1 Mask */
  185. #define ACMP_STATUS_WKIF0_Pos (8) /*!< ACMP_T::STATUS: WKIF0 Position */
  186. #define ACMP_STATUS_WKIF0_Msk (0x1ul << ACMP_STATUS_WKIF0_Pos) /*!< ACMP_T::STATUS: WKIF0 Mask */
  187. #define ACMP_STATUS_WKIF1_Pos (9) /*!< ACMP_T::STATUS: WKIF1 Position */
  188. #define ACMP_STATUS_WKIF1_Msk (0x1ul << ACMP_STATUS_WKIF1_Pos) /*!< ACMP_T::STATUS: WKIF1 Mask */
  189. #define ACMP_STATUS_ACMPS0_Pos (12) /*!< ACMP_T::STATUS: ACMPS0 Position */
  190. #define ACMP_STATUS_ACMPS0_Msk (0x1ul << ACMP_STATUS_ACMPS0_Pos) /*!< ACMP_T::STATUS: ACMPS0 Mask */
  191. #define ACMP_STATUS_ACMPS1_Pos (13) /*!< ACMP_T::STATUS: ACMPS1 Position */
  192. #define ACMP_STATUS_ACMPS1_Msk (0x1ul << ACMP_STATUS_ACMPS1_Pos) /*!< ACMP_T::STATUS: ACMPS1 Mask */
  193. #define ACMP_STATUS_ACMPWO_Pos (16) /*!< ACMP_T::STATUS: ACMPWO Position */
  194. #define ACMP_STATUS_ACMPWO_Msk (0x1ul << ACMP_STATUS_ACMPWO_Pos) /*!< ACMP_T::STATUS: ACMPWO Mask */
  195. #define ACMP_VREF_CRVCTL_Pos (0) /*!< ACMP_T::VREF: CRVCTL Position */
  196. #define ACMP_VREF_CRVCTL_Msk (0xful << ACMP_VREF_CRVCTL_Pos) /*!< ACMP_T::VREF: CRVCTL Mask */
  197. #define ACMP_VREF_CRVSSEL_Pos (6) /*!< ACMP_T::VREF: CRVSSEL Position */
  198. #define ACMP_VREF_CRVSSEL_Msk (0x1ul << ACMP_VREF_CRVSSEL_Pos) /*!< ACMP_T::VREF: CRVSSEL Mask */
  199. /**@}*/ /* ACMP_CONST */
  200. /**@}*/ /* end of ACMP register group */
  201. /**@}*/ /* end of REGISTER group */
  202. #if defined ( __CC_ARM )
  203. #pragma no_anon_unions
  204. #endif
  205. #endif /* __ACMP_REG_H__ */