acmp_reg.h 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255
  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) 2018 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 0 Disabled.
  32. * | | |1 = Comparator 0 Enabled.
  33. * |[1] |ACMPIE |Comparator Interrupt Enable Bit
  34. * | | |0 = Comparator 0 interrupt Disabled.
  35. * | | |1 = Comparator 0 interrupt Enabled. If WKEN (ACMP_CTL0[16]) is set to 1, the wake-up interrupt function will be enabled as well.
  36. * |[3] |ACMPOINV |Comparator Output Inverse
  37. * | | |0 = Comparator 0 output inverse Disabled.
  38. * | | |1 = Comparator 0 output inverse Enabled.
  39. * |[5:4] |NEGSEL |Comparator Negative Input Selection
  40. * | | |00 = ACMP0_N pin.
  41. * | | |01 = Internal comparator reference voltage (CRV).
  42. * | | |10 = Band-gap voltage.
  43. * | | |11 = Reserved.
  44. * |[7:6] |POSSEL |Comparator Positive Input Selection
  45. * | | |00 = Input from ACMP0_P0.
  46. * | | |01 = Input from ACMP0_P1.
  47. * | | |10 = Input from ACMP0_P2.
  48. * | | |11 = Input from ACMP0_P3.
  49. * |[9:8] |INTPOL |Interrupt Condition Polarity Selection
  50. * | | |ACMPIF0 will be set to 1 when comparator output edge condition is detected.
  51. * | | |00 = Rising edge or falling edge.
  52. * | | |01 = Rising edge.
  53. * | | |10 = Falling edge.
  54. * | | |11 = Reserved.
  55. * |[12] |OUTSEL |Comparator Output Select
  56. * | | |0 = Comparator 0 output to ACMP0_O pin is unfiltered comparator output.
  57. * | | |1 = Comparator 0 output to ACMP0_O pin is from filter output.
  58. * |[15:13] |FILTSEL |Comparator Output Filter Count Selection
  59. * | | |000 = Filter function is Disabled.
  60. * | | |001 = ACMP0 output is sampled 1 consecutive PCLK.
  61. * | | |010 = ACMP0 output is sampled 2 consecutive PCLKs.
  62. * | | |011 = ACMP0 output is sampled 4 consecutive PCLKs.
  63. * | | |100 = ACMP0 output is sampled 8 consecutive PCLKs.
  64. * | | |101 = ACMP0 output is sampled 16 consecutive PCLKs.
  65. * | | |110 = ACMP0 output is sampled 32 consecutive PCLKs.
  66. * | | |111 = ACMP0 output is sampled 64 consecutive PCLKs.
  67. * |[16] |WKEN |Power-down Wake-up Enable Bit
  68. * | | |0 = Wake-up function Disabled.
  69. * | | |1 = Wake-up function Enabled.
  70. * |[17] |WLATEN |Window Latch Mode Enable Bit
  71. * | | |0 = Window Latch Mode Disabled.
  72. * | | |1 = Window Latch Mode Enabled.
  73. * |[18] |WCMPSEL |Window Compare Mode Selection
  74. * | | |0 = Window Compare Mode Disabled.
  75. * | | |1 = Window Compare Mode is Selected.
  76. * @var ACMP_T::STATUS
  77. * Offset: 0x08 Analog Comparator Status Register
  78. * ---------------------------------------------------------------------------------------------------
  79. * |Bits |Field |Descriptions
  80. * | :----: | :----: | :---- |
  81. * |[0] |ACMPIF0 |Comparator 0 Interrupt Flag
  82. * | | |This bit is set by hardware when the edge condition defined by INTPOL (ACMP_CTL0[9:8]) is detected on comparator 0 output. This will generate an interrupt if ACMPIE (ACMP_CTL0[1]) is set to 1.
  83. * | | |Note: Write 1 to clear this bit to 0.
  84. * |[1] |ACMPIF1 |Comparator 1 Interrupt Flag
  85. * | | |This bit is set by hardware when the edge condition defined by INTPOL (ACMP_CTL1[9:8]) is detected on comparator 1 output.
  86. * | | |This will cause an interrupt if ACMPIE (ACMP_CTL1[1]) is set to 1.
  87. * | | |Note: Write 1 to clear this bit to 0.
  88. * |[4] |ACMPO0 |Comparator 0 Output
  89. * | | |Synchronized to the PCLK to allow reading by software. Cleared when the comparator 0 is disabled, i.e. ACMPEN (ACMP_CTL0[0]) is cleared to 0.
  90. * |[5] |ACMPO1 |Comparator 1 Output
  91. * | | |Synchronized to the PCLK to allow reading by software
  92. * | | |Cleared when the comparator 1 is disabled, i.e
  93. * | | |ACMPEN (ACMP_CTL1[0]) is cleared to 0.
  94. * |[8] |WKIF0 |Comparator 0 Power-down Wake-up Interrupt Flag
  95. * | | |This bit will be set to 1 when ACMP0 wake-up interrupt event occurs.
  96. * | | |0 = No power-down wake-up occurred.
  97. * | | |1 = Power-down wake-up occurred.
  98. * | | |Note: Write 1 to clear this bit to 0.
  99. * |[9] |WKIF1 |Comparator 1 Power-down Wake-up Interrupt Flag
  100. * | | |This bit will be set to 1 when ACMP1 wake-up interrupt event occurs.
  101. * | | |0 = No power-down wake-up occurred.
  102. * | | |1 = Power-down wake-up occurred.
  103. * | | |Note: Write 1 to clear this bit to 0.
  104. * |[12] |ACMPS0 |Comparator 0 Status
  105. * | | |Synchronized to the PCLK to allow reading by software. Cleared when the comparator 0 is disabled, i.e. ACMPEN (ACMP_CTL0[0]) is cleared to 0.
  106. * |[13] |ACMPS1 |Comparator 1 Status
  107. * | | |Synchronized to the PCLK to allow reading by software. Cleared when the comparator 1 is disabled, i.e. ACMPEN (ACMP_CTL1[0]) is cleared to 0.
  108. * |[16] |ACMPWO |Comparator Window Output
  109. * | | |This bit shows the output status of window compare mode.
  110. * | | |0 = The positive input voltage is outside the window.
  111. * | | |1 = The positive input voltage is in the window.
  112. * @var ACMP_T::VREF
  113. * Offset: 0x0C Analog Comparator Reference Voltage Control Register
  114. * ---------------------------------------------------------------------------------------------------
  115. * |Bits |Field |Descriptions
  116. * | :----: | :----: | :---- |
  117. * |[3:0] |CRVCTL |Comparator Reference Voltage Setting
  118. * | | |CRV = CRV source voltage * (1/6+CRVCTL/24).
  119. * |[6] |CRVSSEL |CRV Source Voltage Selection
  120. * | | |0 = AVDD is selected as CRV source voltage.
  121. * | | |1 = VREF is selected as as CRV source voltage.
  122. */
  123. __IO uint32_t CTL[2]; /*!< [0x0000~0x0004] Analog Comparator 0/1 Control Register */
  124. __IO uint32_t STATUS; /*!< [0x0008] Analog Comparator Status Register */
  125. __IO uint32_t VREF; /*!< [0x000c] Analog Comparator Reference Voltage Control Register */
  126. __IO uint32_t CALCTL; /*!< [0x0010] Analog Comparator Calibration Control Register */
  127. __I uint32_t CALSR; /*!< [0x0014] Analog Comparator Calibration Status Register */
  128. } ACMP_T;
  129. /**
  130. @addtogroup ACMP_CONST ACMP Bit Field Definition
  131. Constant Definitions for ACMP Controller
  132. @{ */
  133. #define ACMP_CTL_ACMPEN_Pos (0) /*!< ACMP_T::CTL: ACMPEN Position */
  134. #define ACMP_CTL_ACMPEN_Msk (0x1ul << ACMP_CTL_ACMPEN_Pos) /*!< ACMP_T::CTL: ACMPEN Mask */
  135. #define ACMP_CTL_ACMPIE_Pos (1) /*!< ACMP_T::CTL: ACMPIE Position */
  136. #define ACMP_CTL_ACMPIE_Msk (0x1ul << ACMP_CTL_ACMPIE_Pos) /*!< ACMP_T::CTL: ACMPIE Mask */
  137. #define ACMP_CTL_HYSEN_Pos (2) /*!< ACMP_T::CTL: HYSEN Position */
  138. #define ACMP_CTL_HYSEN_Msk (0x1ul << ACMP_CTL_HYSEN_Pos) /*!< ACMP_T::CTL: HYSEN Mask */
  139. #define ACMP_CTL_ACMPOINV_Pos (3) /*!< ACMP_T::CTL: ACMPOINV Position */
  140. #define ACMP_CTL_ACMPOINV_Msk (0x1ul << ACMP_CTL_ACMPOINV_Pos) /*!< ACMP_T::CTL: ACMPOINV Mask */
  141. #define ACMP_CTL_NEGSEL_Pos (4) /*!< ACMP_T::CTL: NEGSEL Position */
  142. #define ACMP_CTL_NEGSEL_Msk (0x3ul << ACMP_CTL_NEGSEL_Pos) /*!< ACMP_T::CTL: NEGSEL Mask */
  143. #define ACMP_CTL_POSSEL_Pos (6) /*!< ACMP_T::CTL: POSSEL Position */
  144. #define ACMP_CTL_POSSEL_Msk (0x3ul << ACMP_CTL_POSSEL_Pos) /*!< ACMP_T::CTL: POSSEL Mask */
  145. #define ACMP_CTL_INTPOL_Pos (8) /*!< ACMP_T::CTL: INTPOL Position */
  146. #define ACMP_CTL_INTPOL_Msk (0x3ul << ACMP_CTL_INTPOL_Pos) /*!< ACMP_T::CTL: INTPOL Mask */
  147. #define ACMP_CTL_OUTSEL_Pos (12) /*!< ACMP_T::CTL: OUTSEL Position */
  148. #define ACMP_CTL_OUTSEL_Msk (0x1ul << ACMP_CTL_OUTSEL_Pos) /*!< ACMP_T::CTL: OUTSEL Mask */
  149. #define ACMP_CTL_FILTSEL_Pos (13) /*!< ACMP_T::CTL: FILTSEL Position */
  150. #define ACMP_CTL_FILTSEL_Msk (0x7ul << ACMP_CTL_FILTSEL_Pos) /*!< ACMP_T::CTL: FILTSEL Mask */
  151. #define ACMP_CTL_WKEN_Pos (16) /*!< ACMP_T::CTL: WKEN Position */
  152. #define ACMP_CTL_WKEN_Msk (0x1ul << ACMP_CTL_WKEN_Pos) /*!< ACMP_T::CTL: WKEN Mask */
  153. #define ACMP_CTL_WLATEN_Pos (17) /*!< ACMP_T::CTL: WLATEN Position */
  154. #define ACMP_CTL_WLATEN_Msk (0x1ul << ACMP_CTL_WLATEN_Pos) /*!< ACMP_T::CTL: WLATEN Mask */
  155. #define ACMP_CTL_WCMPSEL_Pos (18) /*!< ACMP_T::CTL: WCMPSEL Position */
  156. #define ACMP_CTL_WCMPSEL_Msk (0x1ul << ACMP_CTL_WCMPSEL_Pos) /*!< ACMP_T::CTL: WCMPSEL Mask */
  157. #define ACMP_STATUS_ACMPIF0_Pos (0) /*!< ACMP_T::STATUS: ACMPIF0 Position */
  158. #define ACMP_STATUS_ACMPIF0_Msk (0x1ul << ACMP_STATUS_ACMPIF0_Pos) /*!< ACMP_T::STATUS: ACMPIF0 Mask */
  159. #define ACMP_STATUS_ACMPIF1_Pos (1) /*!< ACMP_T::STATUS: ACMPIF1 Position */
  160. #define ACMP_STATUS_ACMPIF1_Msk (0x1ul << ACMP_STATUS_ACMPIF1_Pos) /*!< ACMP_T::STATUS: ACMPIF1 Mask */
  161. #define ACMP_STATUS_ACMPO0_Pos (4) /*!< ACMP_T::STATUS: ACMPO0 Position */
  162. #define ACMP_STATUS_ACMPO0_Msk (0x1ul << ACMP_STATUS_ACMPO0_Pos) /*!< ACMP_T::STATUS: ACMPO0 Mask */
  163. #define ACMP_STATUS_ACMPO1_Pos (5) /*!< ACMP_T::STATUS: ACMPO1 Position */
  164. #define ACMP_STATUS_ACMPO1_Msk (0x1ul << ACMP_STATUS_ACMPO1_Pos) /*!< ACMP_T::STATUS: ACMPO1 Mask */
  165. #define ACMP_STATUS_WKIF0_Pos (8) /*!< ACMP_T::STATUS: WKIF0 Position */
  166. #define ACMP_STATUS_WKIF0_Msk (0x1ul << ACMP_STATUS_WKIF0_Pos) /*!< ACMP_T::STATUS: WKIF0 Mask */
  167. #define ACMP_STATUS_WKIF1_Pos (9) /*!< ACMP_T::STATUS: WKIF1 Position */
  168. #define ACMP_STATUS_WKIF1_Msk (0x1ul << ACMP_STATUS_WKIF1_Pos) /*!< ACMP_T::STATUS: WKIF1 Mask */
  169. #define ACMP_STATUS_ACMPS0_Pos (12) /*!< ACMP_T::STATUS: ACMPS0 Position */
  170. #define ACMP_STATUS_ACMPS0_Msk (0x1ul << ACMP_STATUS_ACMPS0_Pos) /*!< ACMP_T::STATUS: ACMPS0 Mask */
  171. #define ACMP_STATUS_ACMPS1_Pos (13) /*!< ACMP_T::STATUS: ACMPS1 Position */
  172. #define ACMP_STATUS_ACMPS1_Msk (0x1ul << ACMP_STATUS_ACMPS1_Pos) /*!< ACMP_T::STATUS: ACMPS1 Mask */
  173. #define ACMP_STATUS_ACMPWO_Pos (16) /*!< ACMP_T::STATUS: ACMPWO Position */
  174. #define ACMP_STATUS_ACMPWO_Msk (0x1ul << ACMP_STATUS_ACMPWO_Pos) /*!< ACMP_T::STATUS: ACMPWO Mask */
  175. #define ACMP_VREF_CRVCTL_Pos (0) /*!< ACMP_T::VREF: CRVCTL Position */
  176. #define ACMP_VREF_CRVCTL_Msk (0xful << ACMP_VREF_CRVCTL_Pos) /*!< ACMP_T::VREF: CRVCTL Mask */
  177. #define ACMP_VREF_CRVSSEL_Pos (6) /*!< ACMP_T::VREF: CRVSSEL Position */
  178. #define ACMP_VREF_CRVSSEL_Msk (0x1ul << ACMP_VREF_CRVSSEL_Pos) /*!< ACMP_T::VREF: CRVSSEL Mask */
  179. #define ACMP_CALCTL_CALTRG0_Pos (0) /*!< ACMP_T::CALCTL: CALTRG0 Position */
  180. #define ACMP_CALCTL_CALTRG0_Msk (0x1ul << ACMP_CALCTL_CALTRG0_Pos) /*!< ACMP_T::CALCTL: CALTRG0 Mask */
  181. #define ACMP_CALCTL_CALTRG1_Pos (1) /*!< ACMP_T::CALCTL: CALTRG1 Position */
  182. #define ACMP_CALCTL_CALTRG1_Msk (0x1ul << ACMP_CALCTL_CALTRG1_Pos) /*!< ACMP_T::CALCTL: CALTRG1 Mask */
  183. #define ACMP_CALCTL_CALCLK0_Pos (4) /*!< ACMP_T::CALCTL: CALCLK0 Position */
  184. #define ACMP_CALCTL_CALCLK0_Msk (0x3ul << ACMP_CALCTL_CALCLK0_Pos) /*!< ACMP_T::CALCTL: CALCLK0 Mask */
  185. #define ACMP_CALCTL_CALCLK1_Pos (6) /*!< ACMP_T::CALCTL: CALCLK1 Position */
  186. #define ACMP_CALCTL_CALCLK1_Msk (0x3ul << ACMP_CALCTL_CALCLK1_Pos) /*!< ACMP_T::CALCTL: CALCLK1 Mask */
  187. #define ACMP_CALCTL_CALRVS0_Pos (16) /*!< ACMP_T::CALCTL: CALRVS0 Position */
  188. #define ACMP_CALCTL_CALRVS0_Msk (0x1ul << ACMP_CALCTL_CALRVS0_Pos) /*!< ACMP_T::CALCTL: CALRVS0 Mask */
  189. #define ACMP_CALCTL_CALRVS1_Pos (17) /*!< ACMP_T::CALCTL: CALRVS1 Position */
  190. #define ACMP_CALCTL_CALRVS1_Msk (0x1ul << ACMP_CALCTL_CALRVS1_Pos) /*!< ACMP_T::CALCTL: CALRVS1 Mask */
  191. #define ACMP_CALSR_DONE0_Pos (0) /*!< ACMP_T::CALSR: DONE0 Position */
  192. #define ACMP_CALSR_DONE0_Msk (0x1ul << ACMP_CALSR_DONE0_Pos) /*!< ACMP_T::CALSR: DONE0 Mask */
  193. #define ACMP_CALSR_CALNS0_Pos (1) /*!< ACMP_T::CALSR: CALNS0 Position */
  194. #define ACMP_CALSR_CALNS0_Msk (0x1ul << ACMP_CALSR_CALNS0_Pos) /*!< ACMP_T::CALSR: CALNS0 Mask */
  195. #define ACMP_CALSR_CALPS0_Pos (2) /*!< ACMP_T::CALSR: CALPS0 Position */
  196. #define ACMP_CALSR_CALPS0_Msk (0x1ul << ACMP_CALSR_CALPS0_Pos) /*!< ACMP_T::CALSR: CALPS0 Mask */
  197. #define ACMP_CALSR_DONE1_Pos (4) /*!< ACMP_T::CALSR: DONE1 Position */
  198. #define ACMP_CALSR_DONE1_Msk (0x1ul << ACMP_CALSR_DONE1_Pos) /*!< ACMP_T::CALSR: DONE1 Mask */
  199. #define ACMP_CALSR_CALNS1_Pos (5) /*!< ACMP_T::CALSR: CALNS1 Position */
  200. #define ACMP_CALSR_CALNS1_Msk (0x1ul << ACMP_CALSR_CALNS1_Pos) /*!< ACMP_T::CALSR: CALNS1 Mask */
  201. #define ACMP_CALSR_CALPS1_Pos (6) /*!< ACMP_T::CALSR: CALPS1 Position */
  202. #define ACMP_CALSR_CALPS1_Msk (0x1ul << ACMP_CALSR_CALPS1_Pos) /*!< ACMP_T::CALSR: CALPS1 Mask */
  203. /**@}*/ /* ACMP_CONST */
  204. /**@}*/ /* end of ACMP register group */
  205. /**@}*/ /* end of REGISTER group */
  206. #if defined ( __CC_ARM )
  207. #pragma no_anon_unions
  208. #endif
  209. #endif /* __ACMP_REG_H__ */