am_reg_vcomp.h 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  1. //*****************************************************************************
  2. //
  3. // am_reg_vcomp.h
  4. //! @file
  5. //!
  6. //! @brief Register macros for the VCOMP module
  7. //
  8. //*****************************************************************************
  9. //*****************************************************************************
  10. //
  11. // Copyright (c) 2017, Ambiq Micro
  12. // All rights reserved.
  13. //
  14. // Redistribution and use in source and binary forms, with or without
  15. // modification, are permitted provided that the following conditions are met:
  16. //
  17. // 1. Redistributions of source code must retain the above copyright notice,
  18. // this list of conditions and the following disclaimer.
  19. //
  20. // 2. Redistributions in binary form must reproduce the above copyright
  21. // notice, this list of conditions and the following disclaimer in the
  22. // documentation and/or other materials provided with the distribution.
  23. //
  24. // 3. Neither the name of the copyright holder nor the names of its
  25. // contributors may be used to endorse or promote products derived from this
  26. // software without specific prior written permission.
  27. //
  28. // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  29. // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  30. // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  31. // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
  32. // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  33. // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  34. // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  35. // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  36. // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  37. // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  38. // POSSIBILITY OF SUCH DAMAGE.
  39. //
  40. // This is part of revision 1.2.11 of the AmbiqSuite Development Package.
  41. //
  42. //*****************************************************************************
  43. #ifndef AM_REG_VCOMP_H
  44. #define AM_REG_VCOMP_H
  45. //*****************************************************************************
  46. //
  47. // Instance finder. (1 instance(s) available)
  48. //
  49. //*****************************************************************************
  50. #define AM_REG_VCOMP_NUM_MODULES 1
  51. #define AM_REG_VCOMPn(n) \
  52. (REG_VCOMP_BASEADDR + 0x00000000 * n)
  53. //*****************************************************************************
  54. //
  55. // Register offsets.
  56. //
  57. //*****************************************************************************
  58. #define AM_REG_VCOMP_CFG_O 0x00000000
  59. #define AM_REG_VCOMP_STAT_O 0x00000004
  60. #define AM_REG_VCOMP_PWDKEY_O 0x00000008
  61. #define AM_REG_VCOMP_INTEN_O 0x00000200
  62. #define AM_REG_VCOMP_INTSTAT_O 0x00000204
  63. #define AM_REG_VCOMP_INTCLR_O 0x00000208
  64. #define AM_REG_VCOMP_INTSET_O 0x0000020C
  65. //*****************************************************************************
  66. //
  67. // Key values.
  68. //
  69. //*****************************************************************************
  70. #define AM_REG_VCOMP_PWDKEY_KEYVAL 0x00000037
  71. //*****************************************************************************
  72. //
  73. // VCOMP_INTEN - Voltage Comparator Interrupt registers: Enable
  74. //
  75. //*****************************************************************************
  76. // This bit is the vcompout high interrupt.
  77. #define AM_REG_VCOMP_INTEN_OUTHI_S 1
  78. #define AM_REG_VCOMP_INTEN_OUTHI_M 0x00000002
  79. #define AM_REG_VCOMP_INTEN_OUTHI(n) (((uint32_t)(n) << 1) & 0x00000002)
  80. // This bit is the vcompout low interrupt.
  81. #define AM_REG_VCOMP_INTEN_OUTLOW_S 0
  82. #define AM_REG_VCOMP_INTEN_OUTLOW_M 0x00000001
  83. #define AM_REG_VCOMP_INTEN_OUTLOW(n) (((uint32_t)(n) << 0) & 0x00000001)
  84. //*****************************************************************************
  85. //
  86. // VCOMP_INTSTAT - Voltage Comparator Interrupt registers: Status
  87. //
  88. //*****************************************************************************
  89. // This bit is the vcompout high interrupt.
  90. #define AM_REG_VCOMP_INTSTAT_OUTHI_S 1
  91. #define AM_REG_VCOMP_INTSTAT_OUTHI_M 0x00000002
  92. #define AM_REG_VCOMP_INTSTAT_OUTHI(n) (((uint32_t)(n) << 1) & 0x00000002)
  93. // This bit is the vcompout low interrupt.
  94. #define AM_REG_VCOMP_INTSTAT_OUTLOW_S 0
  95. #define AM_REG_VCOMP_INTSTAT_OUTLOW_M 0x00000001
  96. #define AM_REG_VCOMP_INTSTAT_OUTLOW(n) (((uint32_t)(n) << 0) & 0x00000001)
  97. //*****************************************************************************
  98. //
  99. // VCOMP_INTCLR - Voltage Comparator Interrupt registers: Clear
  100. //
  101. //*****************************************************************************
  102. // This bit is the vcompout high interrupt.
  103. #define AM_REG_VCOMP_INTCLR_OUTHI_S 1
  104. #define AM_REG_VCOMP_INTCLR_OUTHI_M 0x00000002
  105. #define AM_REG_VCOMP_INTCLR_OUTHI(n) (((uint32_t)(n) << 1) & 0x00000002)
  106. // This bit is the vcompout low interrupt.
  107. #define AM_REG_VCOMP_INTCLR_OUTLOW_S 0
  108. #define AM_REG_VCOMP_INTCLR_OUTLOW_M 0x00000001
  109. #define AM_REG_VCOMP_INTCLR_OUTLOW(n) (((uint32_t)(n) << 0) & 0x00000001)
  110. //*****************************************************************************
  111. //
  112. // VCOMP_INTSET - Voltage Comparator Interrupt registers: Set
  113. //
  114. //*****************************************************************************
  115. // This bit is the vcompout high interrupt.
  116. #define AM_REG_VCOMP_INTSET_OUTHI_S 1
  117. #define AM_REG_VCOMP_INTSET_OUTHI_M 0x00000002
  118. #define AM_REG_VCOMP_INTSET_OUTHI(n) (((uint32_t)(n) << 1) & 0x00000002)
  119. // This bit is the vcompout low interrupt.
  120. #define AM_REG_VCOMP_INTSET_OUTLOW_S 0
  121. #define AM_REG_VCOMP_INTSET_OUTLOW_M 0x00000001
  122. #define AM_REG_VCOMP_INTSET_OUTLOW(n) (((uint32_t)(n) << 0) & 0x00000001)
  123. //*****************************************************************************
  124. //
  125. // VCOMP_CFG - Configuration Register
  126. //
  127. //*****************************************************************************
  128. // When the reference input NSEL is set to NSEL_DAC, this bitfield selects the
  129. // voltage level for the negative input to the comparator.
  130. #define AM_REG_VCOMP_CFG_LVLSEL_S 16
  131. #define AM_REG_VCOMP_CFG_LVLSEL_M 0x000F0000
  132. #define AM_REG_VCOMP_CFG_LVLSEL(n) (((uint32_t)(n) << 16) & 0x000F0000)
  133. #define AM_REG_VCOMP_CFG_LVLSEL_0P58V 0x00000000
  134. #define AM_REG_VCOMP_CFG_LVLSEL_0P77V 0x00010000
  135. #define AM_REG_VCOMP_CFG_LVLSEL_0P97V 0x00020000
  136. #define AM_REG_VCOMP_CFG_LVLSEL_1P16V 0x00030000
  137. #define AM_REG_VCOMP_CFG_LVLSEL_1P35V 0x00040000
  138. #define AM_REG_VCOMP_CFG_LVLSEL_1P55V 0x00050000
  139. #define AM_REG_VCOMP_CFG_LVLSEL_1P74V 0x00060000
  140. #define AM_REG_VCOMP_CFG_LVLSEL_1P93V 0x00070000
  141. #define AM_REG_VCOMP_CFG_LVLSEL_2P13V 0x00080000
  142. #define AM_REG_VCOMP_CFG_LVLSEL_2P32V 0x00090000
  143. #define AM_REG_VCOMP_CFG_LVLSEL_2P51V 0x000A0000
  144. #define AM_REG_VCOMP_CFG_LVLSEL_2P71V 0x000B0000
  145. #define AM_REG_VCOMP_CFG_LVLSEL_2P90V 0x000C0000
  146. #define AM_REG_VCOMP_CFG_LVLSEL_3P09V 0x000D0000
  147. #define AM_REG_VCOMP_CFG_LVLSEL_3P29V 0x000E0000
  148. #define AM_REG_VCOMP_CFG_LVLSEL_3P48V 0x000F0000
  149. // This bitfield selects the negative input to the comparator.
  150. #define AM_REG_VCOMP_CFG_NSEL_S 8
  151. #define AM_REG_VCOMP_CFG_NSEL_M 0x00000300
  152. #define AM_REG_VCOMP_CFG_NSEL(n) (((uint32_t)(n) << 8) & 0x00000300)
  153. #define AM_REG_VCOMP_CFG_NSEL_VREFEXT1 0x00000000
  154. #define AM_REG_VCOMP_CFG_NSEL_VREFEXT2 0x00000100
  155. #define AM_REG_VCOMP_CFG_NSEL_VREFEXT3 0x00000200
  156. #define AM_REG_VCOMP_CFG_NSEL_DAC 0x00000300
  157. // This bitfield selects the positive input to the comparator.
  158. #define AM_REG_VCOMP_CFG_PSEL_S 0
  159. #define AM_REG_VCOMP_CFG_PSEL_M 0x00000003
  160. #define AM_REG_VCOMP_CFG_PSEL(n) (((uint32_t)(n) << 0) & 0x00000003)
  161. #define AM_REG_VCOMP_CFG_PSEL_VDDADJ 0x00000000
  162. #define AM_REG_VCOMP_CFG_PSEL_VTEMP 0x00000001
  163. #define AM_REG_VCOMP_CFG_PSEL_VEXT1 0x00000002
  164. #define AM_REG_VCOMP_CFG_PSEL_VEXT2 0x00000003
  165. //*****************************************************************************
  166. //
  167. // VCOMP_STAT - Status Register
  168. //
  169. //*****************************************************************************
  170. // This bit indicates the power down state of the voltage comparator.
  171. #define AM_REG_VCOMP_STAT_PWDSTAT_S 1
  172. #define AM_REG_VCOMP_STAT_PWDSTAT_M 0x00000002
  173. #define AM_REG_VCOMP_STAT_PWDSTAT(n) (((uint32_t)(n) << 1) & 0x00000002)
  174. #define AM_REG_VCOMP_STAT_PWDSTAT_POWERED_DOWN 0x00000002
  175. // This bit is 1 if the positive input of the comparator is greater than the
  176. // negative input.
  177. #define AM_REG_VCOMP_STAT_CMPOUT_S 0
  178. #define AM_REG_VCOMP_STAT_CMPOUT_M 0x00000001
  179. #define AM_REG_VCOMP_STAT_CMPOUT(n) (((uint32_t)(n) << 0) & 0x00000001)
  180. #define AM_REG_VCOMP_STAT_CMPOUT_VOUT_LOW 0x00000000
  181. #define AM_REG_VCOMP_STAT_CMPOUT_VOUT_HIGH 0x00000001
  182. #endif // AM_REG_VCOMP_H