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