1 /***************************************************************************//**
2  * @file
3  * @brief Analog Comparator (ACMP) peripheral API
4  *******************************************************************************
5  * # License
6  * <b>Copyright 2018 Silicon Laboratories Inc. www.silabs.com</b>
7  *******************************************************************************
8  *
9  * SPDX-License-Identifier: Zlib
10  *
11  * The licensor of this software is Silicon Laboratories Inc.
12  *
13  * This software is provided 'as-is', without any express or implied
14  * warranty. In no event will the authors be held liable for any damages
15  * arising from the use of this software.
16  *
17  * Permission is granted to anyone to use this software for any purpose,
18  * including commercial applications, and to alter it and redistribute it
19  * freely, subject to the following restrictions:
20  *
21  * 1. The origin of this software must not be misrepresented; you must not
22  *    claim that you wrote the original software. If you use this software
23  *    in a product, an acknowledgment in the product documentation would be
24  *    appreciated but is not required.
25  * 2. Altered source versions must be plainly marked as such, and must not be
26  *    misrepresented as being the original software.
27  * 3. This notice may not be removed or altered from any source distribution.
28  *
29  ******************************************************************************/
30 
31 #ifndef EM_ACMP_H
32 #define EM_ACMP_H
33 
34 #include "em_device.h"
35 #include "em_gpio.h"
36 
37 #if defined(ACMP_COUNT) && (ACMP_COUNT > 0)
38 
39 #include <stdint.h>
40 #include <stdbool.h>
41 
42 #ifdef __cplusplus
43 extern "C" {
44 #endif
45 
46 /***************************************************************************//**
47  * @addtogroup acmp
48  * @{
49  ******************************************************************************/
50 
51 /*******************************************************************************
52  ********************************   ENUMS   ************************************
53  ******************************************************************************/
54 
55 /** Resistor values used for the internal capacitive sense resistor. See
56  *  data sheet for your device for details on each resistor value. */
57 typedef enum {
58 #if defined(_ACMP_INPUTCTRL_CSRESSEL_MASK)
59   acmpResistor0 = _ACMP_INPUTCTRL_CSRESSEL_RES0,   /**< Resistor value 0 */
60   acmpResistor1 = _ACMP_INPUTCTRL_CSRESSEL_RES1,   /**< Resistor value 1 */
61   acmpResistor2 = _ACMP_INPUTCTRL_CSRESSEL_RES2,   /**< Resistor value 2 */
62   acmpResistor3 = _ACMP_INPUTCTRL_CSRESSEL_RES3,   /**< Resistor value 3 */
63   acmpResistor4 = _ACMP_INPUTCTRL_CSRESSEL_RES4,   /**< Resistor value 4 */
64   acmpResistor5 = _ACMP_INPUTCTRL_CSRESSEL_RES5,   /**< Resistor value 5 */
65   acmpResistor6 = _ACMP_INPUTCTRL_CSRESSEL_RES6,   /**< Resistor value 6 */
66 #else
67   acmpResistor0 = _ACMP_INPUTSEL_CSRESSEL_RES0,   /**< Resistor value 0 */
68   acmpResistor1 = _ACMP_INPUTSEL_CSRESSEL_RES1,   /**< Resistor value 1 */
69   acmpResistor2 = _ACMP_INPUTSEL_CSRESSEL_RES2,   /**< Resistor value 2 */
70   acmpResistor3 = _ACMP_INPUTSEL_CSRESSEL_RES3,   /**< Resistor value 3 */
71 #if defined(_ACMP_INPUTSEL_CSRESSEL_RES4)
72   acmpResistor4 = _ACMP_INPUTSEL_CSRESSEL_RES4,   /**< Resistor value 4 */
73   acmpResistor5 = _ACMP_INPUTSEL_CSRESSEL_RES5,   /**< Resistor value 5 */
74   acmpResistor6 = _ACMP_INPUTSEL_CSRESSEL_RES6,   /**< Resistor value 6 */
75   acmpResistor7 = _ACMP_INPUTSEL_CSRESSEL_RES7,   /**< Resistor value 7 */
76 #endif
77 #endif
78 } ACMP_CapsenseResistor_TypeDef;
79 
80 /** Hysteresis level. See data sheet for your device for details on each
81  *  level. */
82 typedef enum {
83 #if defined(_ACMP_CTRL_HYSTSEL_MASK)
84   acmpHysteresisLevel0 = _ACMP_CTRL_HYSTSEL_HYST0,       /**< Hysteresis level 0 */
85   acmpHysteresisLevel1 = _ACMP_CTRL_HYSTSEL_HYST1,       /**< Hysteresis level 1 */
86   acmpHysteresisLevel2 = _ACMP_CTRL_HYSTSEL_HYST2,       /**< Hysteresis level 2 */
87   acmpHysteresisLevel3 = _ACMP_CTRL_HYSTSEL_HYST3,       /**< Hysteresis level 3 */
88   acmpHysteresisLevel4 = _ACMP_CTRL_HYSTSEL_HYST4,       /**< Hysteresis level 4 */
89   acmpHysteresisLevel5 = _ACMP_CTRL_HYSTSEL_HYST5,       /**< Hysteresis level 5 */
90   acmpHysteresisLevel6 = _ACMP_CTRL_HYSTSEL_HYST6,       /**< Hysteresis level 6 */
91   acmpHysteresisLevel7 = _ACMP_CTRL_HYSTSEL_HYST7        /**< Hysteresis level 7 */
92 #endif
93 #if defined(_ACMP_HYSTERESIS0_HYST_MASK)
94   acmpHysteresisLevel0 = _ACMP_HYSTERESIS0_HYST_HYST0,   /**< Hysteresis level 0 */
95   acmpHysteresisLevel1 = _ACMP_HYSTERESIS0_HYST_HYST1,   /**< Hysteresis level 1 */
96   acmpHysteresisLevel2 = _ACMP_HYSTERESIS0_HYST_HYST2,   /**< Hysteresis level 2 */
97   acmpHysteresisLevel3 = _ACMP_HYSTERESIS0_HYST_HYST3,   /**< Hysteresis level 3 */
98   acmpHysteresisLevel4 = _ACMP_HYSTERESIS0_HYST_HYST4,   /**< Hysteresis level 4 */
99   acmpHysteresisLevel5 = _ACMP_HYSTERESIS0_HYST_HYST5,   /**< Hysteresis level 5 */
100   acmpHysteresisLevel6 = _ACMP_HYSTERESIS0_HYST_HYST6,   /**< Hysteresis level 6 */
101   acmpHysteresisLevel7 = _ACMP_HYSTERESIS0_HYST_HYST7,   /**< Hysteresis level 7 */
102   acmpHysteresisLevel8 = _ACMP_HYSTERESIS0_HYST_HYST8,   /**< Hysteresis level 8 */
103   acmpHysteresisLevel9 = _ACMP_HYSTERESIS0_HYST_HYST9,   /**< Hysteresis level 9 */
104   acmpHysteresisLevel10 = _ACMP_HYSTERESIS0_HYST_HYST10, /**< Hysteresis level 10 */
105   acmpHysteresisLevel11 = _ACMP_HYSTERESIS0_HYST_HYST11, /**< Hysteresis level 11 */
106   acmpHysteresisLevel12 = _ACMP_HYSTERESIS0_HYST_HYST12, /**< Hysteresis level 12 */
107   acmpHysteresisLevel13 = _ACMP_HYSTERESIS0_HYST_HYST13, /**< Hysteresis level 13 */
108   acmpHysteresisLevel14 = _ACMP_HYSTERESIS0_HYST_HYST14, /**< Hysteresis level 14 */
109   acmpHysteresisLevel15 = _ACMP_HYSTERESIS0_HYST_HYST15, /**< Hysteresis level 15 */
110 #endif
111 #if defined(_ACMP_CFG_HYST_MASK)
112   acmpHysteresisDisabled = _ACMP_CFG_HYST_DISABLED,   /**< Mode DISABLED for ACMP_CFG */
113   acmpHysteresis10Sym = _ACMP_CFG_HYST_SYM10MV,     /**< Mode HYST10SYM for ACMP_CFG */
114   acmpHysteresis20Sym = _ACMP_CFG_HYST_SYM20MV,     /**< Mode HYST20SYM for ACMP_CFG */
115   acmpHysteresis30Sym = _ACMP_CFG_HYST_SYM30MV,     /**< Mode HYST30SYM for ACMP_CFG */
116   acmpHysteresis10Pos = _ACMP_CFG_HYST_POS10MV,     /**< Mode HYST10POS for ACMP_CFG */
117   acmpHysteresis20Pos = _ACMP_CFG_HYST_POS20MV,     /**< Mode HYST20POS for ACMP_CFG */
118   acmpHysteresis30Pos = _ACMP_CFG_HYST_POS30MV,     /**< Mode HYST30POS for ACMP_CFG */
119   acmpHysteresis10Neg = _ACMP_CFG_HYST_NEG10MV,     /**< Mode HYST10NEG for ACMP_CFG */
120   acmpHysteresis20Neg = _ACMP_CFG_HYST_NEG20MV,     /**< Mode HYST20NEG for ACMP_CFG */
121   acmpHysteresis30Neg = _ACMP_CFG_HYST_NEG30MV,     /**< Mode HYST30NEG for ACMP_CFG */
122 #endif
123 } ACMP_HysteresisLevel_TypeDef;
124 
125 #if defined(_ACMP_CTRL_WARMTIME_MASK)
126 /** ACMP warmup time. The delay is measured in HFPERCLK / HFPERCCLK cycles and should
127  *  be at least 10 us. */
128 typedef enum {
129   /** 4 cycles warmup */
130   acmpWarmTime4   = _ACMP_CTRL_WARMTIME_4CYCLES,
131   /** 8 cycles warmup */
132   acmpWarmTime8   = _ACMP_CTRL_WARMTIME_8CYCLES,
133   /** 16 cycles warmup */
134   acmpWarmTime16  = _ACMP_CTRL_WARMTIME_16CYCLES,
135   /** 32 cycles warmup */
136   acmpWarmTime32  = _ACMP_CTRL_WARMTIME_32CYCLES,
137   /** 64 cycles warmup */
138   acmpWarmTime64  = _ACMP_CTRL_WARMTIME_64CYCLES,
139   /** 128 cycles warmup */
140   acmpWarmTime128 = _ACMP_CTRL_WARMTIME_128CYCLES,
141   /** 256 cycles warmup */
142   acmpWarmTime256 = _ACMP_CTRL_WARMTIME_256CYCLES,
143   /** 512 cycles warmup */
144   acmpWarmTime512 = _ACMP_CTRL_WARMTIME_512CYCLES
145 } ACMP_WarmTime_TypeDef;
146 #endif
147 
148 #if defined(_ACMP_CTRL_INPUTRANGE_MASK) \
149   || defined(_ACMP_CFG_INPUTRANGE_MASK)
150 /**
151  * Adjust ACMP performance for a given input voltage range.
152  */
153 typedef enum {
154 #if defined(_ACMP_CTRL_INPUTRANGE_MASK)
155   acmpInputRangeFull = _ACMP_CTRL_INPUTRANGE_FULL,      /**< Input can be from 0 to VDD. */
156   acmpInputRangeHigh = _ACMP_CTRL_INPUTRANGE_GTVDDDIV2, /**< Input will always be greater than VDD/2. */
157   acmpInputRangeLow  = _ACMP_CTRL_INPUTRANGE_LTVDDDIV2  /**< Input will always be less than VDD/2. */
158 #elif defined(_ACMP_CFG_INPUTRANGE_MASK)
159   acmpInputRangeFull    = _ACMP_CFG_INPUTRANGE_FULL,    /**< Input can be from 0 to VDD. */
160   acmpInputRangeReduced = _ACMP_CFG_INPUTRANGE_REDUCED, /**< Input can be from 0 to VDD-0.7 V. */
161 #endif
162 } ACMP_InputRange_TypeDef;
163 #endif
164 
165 #if defined(_ACMP_CTRL_PWRSEL_MASK)
166 /**
167  * ACMP Power source.
168  */
169 typedef enum {
170   acmpPowerSourceAvdd      = _ACMP_CTRL_PWRSEL_AVDD,    /**< Power ACMP using the AVDD supply. */
171 #if defined(_ACMP_CTRL_PWRSEL_DVDD)
172   acmpPowerSourceDvdd      = _ACMP_CTRL_PWRSEL_DVDD,    /**< Power ACMP using the DVDD supply. */
173 #endif
174   acmpPowerSourceIOVdd0    = _ACMP_CTRL_PWRSEL_IOVDD0,  /**< Power ACMP using the IOVDD/IOVDD0 supply. */
175   acmpPowerSourceIOVdd1    = _ACMP_CTRL_PWRSEL_IOVDD1,  /**< Power ACMP using the IOVDD1 supply (if the part has two I/O voltages). */
176 } ACMP_PowerSource_TypeDef;
177 #endif
178 
179 #if defined(_ACMP_CTRL_ACCURACY_MASK) \
180   || defined(_ACMP_CFG_ACCURACY_MASK)
181 /**
182  * ACMP accuracy mode.
183  */
184 typedef enum {
185 #if defined(_ACMP_CTRL_ACCURACY_MASK)
186   acmpAccuracyLow = _ACMP_CTRL_ACCURACY_LOW,   /**< Low-accuracy mode which consumes less current. */
187   acmpAccuracyHigh = _ACMP_CTRL_ACCURACY_HIGH  /**< High-accuracy mode which consumes more current. */
188 #elif defined(_ACMP_CFG_ACCURACY_MASK)
189   acmpAccuracyLow = _ACMP_CFG_ACCURACY_LOW,   /**< Low-accuracy mode which consumes less current. */
190   acmpAccuracyHigh = _ACMP_CFG_ACCURACY_HIGH  /**< High-accuracy mode which consumes more current. */
191 #endif
192 } ACMP_Accuracy_TypeDef;
193 #endif
194 
195 #if defined(_ACMP_INPUTSEL_VASEL_MASK)
196 /** ACMP input to the VA divider. This enumeration is used to select the input for
197  *  the VA Divider. */
198 typedef enum {
199   acmpVAInputVDD         = _ACMP_INPUTSEL_VASEL_VDD,         /**< Select VDD for the VA divider. */
200   acmpVAInputAPORT2YCH0  = _ACMP_INPUTSEL_VASEL_APORT2YCH0,  /**< Select APORT2Y CHannel 0 for the VA divider. */
201   acmpVAInputAPORT2YCH2  = _ACMP_INPUTSEL_VASEL_APORT2YCH2,  /**< Select APORT2Y CHannel 2 for the VA divider. */
202   acmpVAInputAPORT2YCH4  = _ACMP_INPUTSEL_VASEL_APORT2YCH4,  /**< Select APORT2Y CHannel 4 for the VA divider. */
203   acmpVAInputAPORT2YCH6  = _ACMP_INPUTSEL_VASEL_APORT2YCH6,  /**< Select APORT2Y CHannel 6 for the VA divider. */
204   acmpVAInputAPORT2YCH8  = _ACMP_INPUTSEL_VASEL_APORT2YCH8,  /**< Select APORT2Y CHannel 8 for the VA divider. */
205   acmpVAInputAPORT2YCH10 = _ACMP_INPUTSEL_VASEL_APORT2YCH10, /**< Select APORT2Y CHannel 10 for the VA divider. */
206   acmpVAInputAPORT2YCH12 = _ACMP_INPUTSEL_VASEL_APORT2YCH12, /**< Select APORT2Y CHannel 12 for the VA divider. */
207   acmpVAInputAPORT2YCH14 = _ACMP_INPUTSEL_VASEL_APORT2YCH14, /**< Select APORT2Y CHannel 14 for the VA divider. */
208   acmpVAInputAPORT2YCH16 = _ACMP_INPUTSEL_VASEL_APORT2YCH16, /**< Select APORT2Y CHannel 16 for the VA divider. */
209   acmpVAInputAPORT2YCH18 = _ACMP_INPUTSEL_VASEL_APORT2YCH18, /**< Select APORT2Y CHannel 18 for the VA divider. */
210   acmpVAInputAPORT2YCH20 = _ACMP_INPUTSEL_VASEL_APORT2YCH20, /**< Select APORT2Y CHannel 20 for the VA divider. */
211   acmpVAInputAPORT2YCH22 = _ACMP_INPUTSEL_VASEL_APORT2YCH22, /**< Select APORT2Y CHannel 22 for the VA divider. */
212   acmpVAInputAPORT2YCH24 = _ACMP_INPUTSEL_VASEL_APORT2YCH24, /**< Select APORT2Y CHannel 24 for the VA divider. */
213   acmpVAInputAPORT2YCH26 = _ACMP_INPUTSEL_VASEL_APORT2YCH26, /**< Select APORT2Y CHannel 26 for the VA divider. */
214   acmpVAInputAPORT2YCH28 = _ACMP_INPUTSEL_VASEL_APORT2YCH28, /**< Select APORT2Y CHannel 28 for the VA divider. */
215   acmpVAInputAPORT2YCH30 = _ACMP_INPUTSEL_VASEL_APORT2YCH30, /**< Select APORT2Y CHannel 30 for the VA divider. */
216   acmpVAInputAPORT1XCH0  = _ACMP_INPUTSEL_VASEL_APORT1XCH0,  /**< Select APORT1X CHannel 0 for the VA divider. */
217   acmpVAInputAPORT1YCH1  = _ACMP_INPUTSEL_VASEL_APORT1YCH1,  /**< Select APORT1Y CHannel 1 for the VA divider. */
218   acmpVAInputAPORT1XCH2  = _ACMP_INPUTSEL_VASEL_APORT1XCH2,  /**< Select APORT1X CHannel 2 for the VA divider. */
219   acmpVAInputAPORT1YCH3  = _ACMP_INPUTSEL_VASEL_APORT1YCH3,  /**< Select APORT1Y CHannel 3 for the VA divider. */
220   acmpVAInputAPORT1XCH4  = _ACMP_INPUTSEL_VASEL_APORT1XCH4,  /**< Select APORT1X CHannel 4 for the VA divider. */
221   acmpVAInputAPORT1YCH5  = _ACMP_INPUTSEL_VASEL_APORT1YCH5,  /**< Select APORT1Y CHannel 5 for the VA divider. */
222   acmpVAInputAPORT1XCH6  = _ACMP_INPUTSEL_VASEL_APORT1XCH6,  /**< Select APORT1X CHannel 6 for the VA divider. */
223   acmpVAInputAPORT1YCH7  = _ACMP_INPUTSEL_VASEL_APORT1YCH7,  /**< Select APORT1Y CHannel 7 for the VA divider. */
224   acmpVAInputAPORT1XCH8  = _ACMP_INPUTSEL_VASEL_APORT1XCH8,  /**< Select APORT1X CHannel 8 for the VA divider. */
225   acmpVAInputAPORT1YCH9  = _ACMP_INPUTSEL_VASEL_APORT1YCH9,  /**< Select APORT1Y CHannel 9 for the VA divider. */
226   acmpVAInputAPORT1XCH10 = _ACMP_INPUTSEL_VASEL_APORT1XCH10, /**< Select APORT1X CHannel 10 for the VA divider. */
227   acmpVAInputAPORT1YCH11 = _ACMP_INPUTSEL_VASEL_APORT1YCH11, /**< Select APORT1Y CHannel 11 for the VA divider. */
228   acmpVAInputAPORT1XCH12 = _ACMP_INPUTSEL_VASEL_APORT1XCH12, /**< Select APORT1X CHannel 12 for the VA divider. */
229   acmpVAInputAPORT1YCH13 = _ACMP_INPUTSEL_VASEL_APORT1YCH13, /**< Select APORT1Y CHannel 13 for the VA divider. */
230   acmpVAInputAPORT1XCH14 = _ACMP_INPUTSEL_VASEL_APORT1XCH14, /**< Select APORT1X CHannel 14 for the VA divider. */
231   acmpVAInputAPORT1YCH15 = _ACMP_INPUTSEL_VASEL_APORT1YCH15, /**< Select APORT1Y CHannel 15 for the VA divider. */
232   acmpVAInputAPORT1XCH16 = _ACMP_INPUTSEL_VASEL_APORT1XCH16, /**< Select APORT1X CHannel 16 for the VA divider. */
233   acmpVAInputAPORT1YCH17 = _ACMP_INPUTSEL_VASEL_APORT1YCH17, /**< Select APORT1Y CHannel 17 for the VA divider. */
234   acmpVAInputAPORT1XCH18 = _ACMP_INPUTSEL_VASEL_APORT1XCH18, /**< Select APORT1X CHannel 18 for the VA divider. */
235   acmpVAInputAPORT1YCH19 = _ACMP_INPUTSEL_VASEL_APORT1YCH19, /**< Select APORT1Y CHannel 19 for the VA divider. */
236   acmpVAInputAPORT1XCH20 = _ACMP_INPUTSEL_VASEL_APORT1XCH20, /**< Select APORT1X CHannel 20 for the VA divider. */
237   acmpVAInputAPORT1YCH21 = _ACMP_INPUTSEL_VASEL_APORT1YCH21, /**< Select APORT1Y CHannel 21 for the VA divider. */
238   acmpVAInputAPORT1XCH22 = _ACMP_INPUTSEL_VASEL_APORT1XCH22, /**< Select APORT1X CHannel 22 for the VA divider. */
239   acmpVAInputAPORT1YCH23 = _ACMP_INPUTSEL_VASEL_APORT1YCH23, /**< Select APORT1Y CHannel 23 for the VA divider. */
240   acmpVAInputAPORT1XCH24 = _ACMP_INPUTSEL_VASEL_APORT1XCH24, /**< Select APORT1X CHannel 24 for the VA divider. */
241   acmpVAInputAPORT1YCH25 = _ACMP_INPUTSEL_VASEL_APORT1YCH25, /**< Select APORT1Y CHannel 25 for the VA divider. */
242   acmpVAInputAPORT1XCH26 = _ACMP_INPUTSEL_VASEL_APORT1XCH26, /**< Select APORT1X CHannel 26 for the VA divider. */
243   acmpVAInputAPORT1YCH27 = _ACMP_INPUTSEL_VASEL_APORT1YCH27, /**< Select APORT1Y CHannel 27 for the VA divider. */
244   acmpVAInputAPORT1XCH28 = _ACMP_INPUTSEL_VASEL_APORT1XCH28, /**< Select APORT1X CHannel 28 for the VA divider. */
245   acmpVAInputAPORT1YCH29 = _ACMP_INPUTSEL_VASEL_APORT1YCH29, /**< Select APORT1Y CHannel 29 for the VA divider. */
246   acmpVAInputAPORT1XCH30 = _ACMP_INPUTSEL_VASEL_APORT1XCH30, /**< Select APORT1X CHannel 30 for the VA divider. */
247   acmpVAInputAPORT1YCH31 = _ACMP_INPUTSEL_VASEL_APORT1YCH31  /**< Select APORT1Y CHannel 31 for the VA divider. */
248 } ACMP_VAInput_TypeDef;
249 #endif
250 
251 #if defined(_ACMP_INPUTSEL_VBSEL_MASK)
252 /**
253  * ACMP input to the VB divider. This enumeration is used to select the input for
254  * the VB divider.
255  */
256 typedef enum {
257   acmpVBInput1V25 = _ACMP_INPUTSEL_VBSEL_1V25, /**< Mode 1V25 for ACMP_INPUTSEL */
258   acmpVBInput2V5  = _ACMP_INPUTSEL_VBSEL_2V5   /**< Mode 2V5 for ACMP_INPUTSEL */
259 } ACMP_VBInput_TypeDef;
260 #endif
261 
262 #if defined(_ACMP_INPUTSEL_VLPSEL_MASK)
263 /**
264  * ACMP Low-Power Input Selection.
265  */
266 typedef enum {
267   acmpVLPInputVADIV = _ACMP_INPUTSEL_VLPSEL_VADIV, /**< Mode VADIV for ACMP_INPUTSEL */
268   acmpVLPInputVBDIV = _ACMP_INPUTSEL_VLPSEL_VBDIV  /**< Mode VBDIV for ACMP_INPUTSEL */
269 } ACMP_VLPInput_Typedef;
270 #endif
271 
272 #if defined(_ACMP_INPUTCTRL_MASK)
273 /** ACMP Input Selection. */
274 typedef enum {
275   acmpInputVSS            = _ACMP_INPUTCTRL_POSSEL_VSS,            /**< Select VSS. */
276   acmpInputVREFDIVAVDD    = _ACMP_INPUTCTRL_POSSEL_VREFDIVAVDD,    /**< Select Divided AVDD. */
277   acmpInputVREFDIVAVDDLP  = _ACMP_INPUTCTRL_POSSEL_VREFDIVAVDDLP,  /**< Select Low-Power Divided AVDD. */
278   acmpInputVREFDIV1V25    = _ACMP_INPUTCTRL_POSSEL_VREFDIV1V25,    /**< Select Divided 1V25 reference. */
279   acmpInputVREFDIV1V25LP  = _ACMP_INPUTCTRL_POSSEL_VREFDIV1V25LP,  /**< Select Low-power Divided 1V25 reference. */
280   acmpInputVREFDIV2V5     = _ACMP_INPUTCTRL_POSSEL_VREFDIV2V5,     /**< Select Divided 2V5 reference. */
281   acmpInputVREFDIV2V5LP   = _ACMP_INPUTCTRL_POSSEL_VREFDIV2V5LP,   /**< Select Low-power Divided 2V5 reference. */
282   acmpInputVSENSE01DIV4   = _ACMP_INPUTCTRL_POSSEL_VSENSE01DIV4,   /**< Select VSENSE0 divided by 4. */
283   acmpInputVSENSE01DIV4LP = _ACMP_INPUTCTRL_POSSEL_VSENSE01DIV4LP, /**< Select Low-power VSENSE0 divided by 4. */
284   acmpInputVSENSE11DIV4   = _ACMP_INPUTCTRL_POSSEL_VSENSE11DIV4,   /**< VSENSE1 divided by 4. */
285   acmpInputVSENSE11DIV4LP = _ACMP_INPUTCTRL_POSSEL_VSENSE11DIV4LP, /**< Low-power VSENSE1 divided by 4. */
286   acmpInputCAPSENSE       = _ACMP_INPUTCTRL_NEGSEL_CAPSENSE,       /**< Select Low-Power Divided AVDD. */
287 #if defined(_ACMP_INPUTCTRL_POSSEL_VDACOUT0)
288   acmpInputVDACOUT0       = _ACMP_INPUTCTRL_POSSEL_VDACOUT0, /**< Select VDAC0 channel 0 output. */
289   acmpInputVDACOUT1       = _ACMP_INPUTCTRL_POSSEL_VDACOUT1, /**< Select VDAC0 channel 1 output. */
290 #endif
291 #if defined(_ACMP_INPUTCTRL_POSSEL_VDAC0OUT1)
292   acmpInputVDAC0OUT1       = _ACMP_INPUTCTRL_POSSEL_VDAC0OUT1, /**< Select VDAC0 channel 1 output. */
293   acmpInputVDAC1OUT1       = _ACMP_INPUTCTRL_POSSEL_VDAC1OUT1, /**< Select VDAC1 channel 1 output. */
294 #endif
295 #if (_SILICON_LABS_32B_SERIES_2_CONFIG > 2)
296   acmpInputEXTPA          = _ACMP_INPUTCTRL_POSSEL_EXTPA,  /**< Select external interface, base is PA0. */
297   acmpInputEXTPB          = _ACMP_INPUTCTRL_POSSEL_EXTPB,  /**< Select external interface, base is PB0. */
298   acmpInputEXTPC          = _ACMP_INPUTCTRL_POSSEL_EXTPC,  /**< Select external interface, base is PC0. */
299   acmpInputEXTPD          = _ACMP_INPUTCTRL_POSSEL_EXTPD,  /**< Select external interface, base is PD0. */
300 #endif
301   acmpInputPA0            = _ACMP_INPUTCTRL_POSSEL_PA0,  /**< Select Port A Pin0. */
302   acmpInputPA1            = _ACMP_INPUTCTRL_POSSEL_PA1,  /**< Select Port A Pin1. */
303   acmpInputPA2            = _ACMP_INPUTCTRL_POSSEL_PA2,  /**< Select Port A Pin2. */
304   acmpInputPA3            = _ACMP_INPUTCTRL_POSSEL_PA3,  /**< Select Port A Pin3. */
305   acmpInputPA4            = _ACMP_INPUTCTRL_POSSEL_PA4,  /**< Select Port A Pin4. */
306   acmpInputPA5            = _ACMP_INPUTCTRL_POSSEL_PA5,  /**< Select Port A Pin5. */
307   acmpInputPA6            = _ACMP_INPUTCTRL_POSSEL_PA6,  /**< Select Port A Pin6. */
308   acmpInputPA7            = _ACMP_INPUTCTRL_POSSEL_PA7,  /**< Select Port A Pin7. */
309   acmpInputPA8            = _ACMP_INPUTCTRL_POSSEL_PA8,  /**< Select Port A Pin8. */
310   acmpInputPA9            = _ACMP_INPUTCTRL_POSSEL_PA9,  /**< Select Port A Pin9. */
311   acmpInputPA10           = _ACMP_INPUTCTRL_POSSEL_PA10, /**< Select Port A Pin10. */
312   acmpInputPA11           = _ACMP_INPUTCTRL_POSSEL_PA11, /**< Select Port A Pin11. */
313   acmpInputPA12           = _ACMP_INPUTCTRL_POSSEL_PA12, /**< Select Port A Pin12. */
314   acmpInputPA13           = _ACMP_INPUTCTRL_POSSEL_PA13, /**< Select Port A Pin13. */
315   acmpInputPA14           = _ACMP_INPUTCTRL_POSSEL_PA14, /**< Select Port A Pin14. */
316   acmpInputPA15           = _ACMP_INPUTCTRL_POSSEL_PA15, /**< Select Port A Pin15. */
317   acmpInputPB0            = _ACMP_INPUTCTRL_POSSEL_PB0,  /**< Select Port B Pin0. */
318   acmpInputPB1            = _ACMP_INPUTCTRL_POSSEL_PB1,  /**< Select Port B Pin1. */
319   acmpInputPB2            = _ACMP_INPUTCTRL_POSSEL_PB2,  /**< Select Port B Pin2. */
320   acmpInputPB3            = _ACMP_INPUTCTRL_POSSEL_PB3,  /**< Select Port B Pin3. */
321   acmpInputPB4            = _ACMP_INPUTCTRL_POSSEL_PB4,  /**< Select Port B Pin4. */
322   acmpInputPB5            = _ACMP_INPUTCTRL_POSSEL_PB5,  /**< Select Port B Pin5. */
323   acmpInputPB6            = _ACMP_INPUTCTRL_POSSEL_PB6,  /**< Select Port B Pin6. */
324   acmpInputPB7            = _ACMP_INPUTCTRL_POSSEL_PB7,  /**< Select Port B Pin7. */
325   acmpInputPB8            = _ACMP_INPUTCTRL_POSSEL_PB8,  /**< Select Port B Pin8. */
326   acmpInputPB9            = _ACMP_INPUTCTRL_POSSEL_PB9,  /**< Select Port B Pin9. */
327   acmpInputPB10           = _ACMP_INPUTCTRL_POSSEL_PB10, /**< Select Port B Pin10. */
328   acmpInputPB11           = _ACMP_INPUTCTRL_POSSEL_PB11, /**< Select Port B Pin11. */
329   acmpInputPB12           = _ACMP_INPUTCTRL_POSSEL_PB12, /**< Select Port B Pin12. */
330   acmpInputPB13           = _ACMP_INPUTCTRL_POSSEL_PB13, /**< Select Port B Pin13. */
331   acmpInputPB14           = _ACMP_INPUTCTRL_POSSEL_PB14, /**< Select Port B Pin14. */
332   acmpInputPB15           = _ACMP_INPUTCTRL_POSSEL_PB15, /**< Select Port B Pin15. */
333   acmpInputPC0            = _ACMP_INPUTCTRL_POSSEL_PC0,  /**< Select Port C Pin0. */
334   acmpInputPC1            = _ACMP_INPUTCTRL_POSSEL_PC1,  /**< Select Port C Pin1. */
335   acmpInputPC2            = _ACMP_INPUTCTRL_POSSEL_PC2,  /**< Select Port C Pin2. */
336   acmpInputPC3            = _ACMP_INPUTCTRL_POSSEL_PC3,  /**< Select Port C Pin3. */
337   acmpInputPC4            = _ACMP_INPUTCTRL_POSSEL_PC4,  /**< Select Port C Pin4. */
338   acmpInputPC5            = _ACMP_INPUTCTRL_POSSEL_PC5,  /**< Select Port C Pin5. */
339   acmpInputPC6            = _ACMP_INPUTCTRL_POSSEL_PC6,  /**< Select Port C Pin6. */
340   acmpInputPC7            = _ACMP_INPUTCTRL_POSSEL_PC7,  /**< Select Port C Pin7. */
341   acmpInputPC8            = _ACMP_INPUTCTRL_POSSEL_PC8,  /**< Select Port C Pin8. */
342   acmpInputPC9            = _ACMP_INPUTCTRL_POSSEL_PC9,  /**< Select Port C Pin9. */
343   acmpInputPC10           = _ACMP_INPUTCTRL_POSSEL_PC10, /**< Select Port C Pin10. */
344   acmpInputPC11           = _ACMP_INPUTCTRL_POSSEL_PC11, /**< Select Port C Pin11. */
345   acmpInputPC12           = _ACMP_INPUTCTRL_POSSEL_PC12, /**< Select Port C Pin12. */
346   acmpInputPC13           = _ACMP_INPUTCTRL_POSSEL_PC13, /**< Select Port C Pin13. */
347   acmpInputPC14           = _ACMP_INPUTCTRL_POSSEL_PC14, /**< Select Port C Pin14. */
348   acmpInputPC15           = _ACMP_INPUTCTRL_POSSEL_PC15, /**< Select Port C Pin15. */
349   acmpInputPD0            = _ACMP_INPUTCTRL_POSSEL_PD0,  /**< Select Port D Pin0. */
350   acmpInputPD1            = _ACMP_INPUTCTRL_POSSEL_PD1,  /**< Select Port D Pin1. */
351   acmpInputPD2            = _ACMP_INPUTCTRL_POSSEL_PD2,  /**< Select Port D Pin2. */
352   acmpInputPD3            = _ACMP_INPUTCTRL_POSSEL_PD3,  /**< Select Port D Pin3. */
353   acmpInputPD4            = _ACMP_INPUTCTRL_POSSEL_PD4,  /**< Select Port D Pin4. */
354   acmpInputPD5            = _ACMP_INPUTCTRL_POSSEL_PD5,  /**< Select Port D Pin5. */
355   acmpInputPD6            = _ACMP_INPUTCTRL_POSSEL_PD6,  /**< Select Port D Pin6. */
356   acmpInputPD7            = _ACMP_INPUTCTRL_POSSEL_PD7,  /**< Select Port D Pin7. */
357   acmpInputPD8            = _ACMP_INPUTCTRL_POSSEL_PD8,  /**< Select Port D Pin8. */
358   acmpInputPD9            = _ACMP_INPUTCTRL_POSSEL_PD9,  /**< Select Port D Pin9. */
359   acmpInputPD10           = _ACMP_INPUTCTRL_POSSEL_PD10, /**< Select Port D Pin10. */
360   acmpInputPD11           = _ACMP_INPUTCTRL_POSSEL_PD11, /**< Select Port D Pin11. */
361   acmpInputPD12           = _ACMP_INPUTCTRL_POSSEL_PD12, /**< Select Port D Pin12. */
362   acmpInputPD13           = _ACMP_INPUTCTRL_POSSEL_PD13, /**< Select Port D Pin13. */
363   acmpInputPD14           = _ACMP_INPUTCTRL_POSSEL_PD14, /**< Select Port D Pin14. */
364   acmpInputPD15           = _ACMP_INPUTCTRL_POSSEL_PD15, /**< Select Port D Pin15. */
365 } ACMP_Channel_TypeDef;
366 #elif defined(_ACMP_INPUTSEL_POSSEL_APORT0XCH0)
367 /** ACMP Input Selection. */
368 typedef enum {
369   acmpInputAPORT0XCH0  = _ACMP_INPUTSEL_POSSEL_APORT0XCH0,  /**< Select Dedicated APORT0X CHannel 0. */
370   acmpInputAPORT0XCH1  = _ACMP_INPUTSEL_POSSEL_APORT0XCH1,  /**< Select Dedicated APORT0X CHannel 1. */
371   acmpInputAPORT0XCH2  = _ACMP_INPUTSEL_POSSEL_APORT0XCH2,  /**< Select Dedicated APORT0X CHannel 2. */
372   acmpInputAPORT0XCH3  = _ACMP_INPUTSEL_POSSEL_APORT0XCH3,  /**< Select Dedicated APORT0X CHannel 3. */
373   acmpInputAPORT0XCH4  = _ACMP_INPUTSEL_POSSEL_APORT0XCH4,  /**< Select Dedicated APORT0X CHannel 4. */
374   acmpInputAPORT0XCH5  = _ACMP_INPUTSEL_POSSEL_APORT0XCH5,  /**< Select Dedicated APORT0X CHannel 5. */
375   acmpInputAPORT0XCH6  = _ACMP_INPUTSEL_POSSEL_APORT0XCH6,  /**< Select Dedicated APORT0X CHannel 6. */
376   acmpInputAPORT0XCH7  = _ACMP_INPUTSEL_POSSEL_APORT0XCH7,  /**< Select Dedicated APORT0X CHannel 7. */
377   acmpInputAPORT0XCH8  = _ACMP_INPUTSEL_POSSEL_APORT0XCH8,  /**< Select Dedicated APORT0X CHannel 8. */
378   acmpInputAPORT0XCH9  = _ACMP_INPUTSEL_POSSEL_APORT0XCH9,  /**< Select Dedicated APORT0X CHannel 9. */
379   acmpInputAPORT0XCH10 = _ACMP_INPUTSEL_POSSEL_APORT0XCH10, /**< Select Dedicated APORT0X CHannel 10. */
380   acmpInputAPORT0XCH11 = _ACMP_INPUTSEL_POSSEL_APORT0XCH11, /**< Select Dedicated APORT0X CHannel 11. */
381   acmpInputAPORT0XCH12 = _ACMP_INPUTSEL_POSSEL_APORT0XCH12, /**< Select Dedicated APORT0X CHannel 12. */
382   acmpInputAPORT0XCH13 = _ACMP_INPUTSEL_POSSEL_APORT0XCH13, /**< Select Dedicated APORT0X CHannel 13. */
383   acmpInputAPORT0XCH14 = _ACMP_INPUTSEL_POSSEL_APORT0XCH14, /**< Select Dedicated APORT0X CHannel 14. */
384   acmpInputAPORT0XCH15 = _ACMP_INPUTSEL_POSSEL_APORT0XCH15, /**< Select Dedicated APORT0X CHannel 15. */
385   acmpInputAPORT0YCH0  = _ACMP_INPUTSEL_POSSEL_APORT0YCH0,  /**< Select Dedicated APORT0Y CHannel 0. */
386   acmpInputAPORT0YCH1  = _ACMP_INPUTSEL_POSSEL_APORT0YCH1,  /**< Select Dedicated APORT0Y CHannel 1. */
387   acmpInputAPORT0YCH2  = _ACMP_INPUTSEL_POSSEL_APORT0YCH2,  /**< Select Dedicated APORT0Y CHannel 2. */
388   acmpInputAPORT0YCH3  = _ACMP_INPUTSEL_POSSEL_APORT0YCH3,  /**< Select Dedicated APORT0Y CHannel 3. */
389   acmpInputAPORT0YCH4  = _ACMP_INPUTSEL_POSSEL_APORT0YCH4,  /**< Select Dedicated APORT0Y CHannel 4. */
390   acmpInputAPORT0YCH5  = _ACMP_INPUTSEL_POSSEL_APORT0YCH5,  /**< Select Dedicated APORT0Y CHannel 5. */
391   acmpInputAPORT0YCH6  = _ACMP_INPUTSEL_POSSEL_APORT0YCH6,  /**< Select Dedicated APORT0Y CHannel 6. */
392   acmpInputAPORT0YCH7  = _ACMP_INPUTSEL_POSSEL_APORT0YCH7,  /**< Select Dedicated APORT0Y CHannel 7. */
393   acmpInputAPORT0YCH8  = _ACMP_INPUTSEL_POSSEL_APORT0YCH8,  /**< Select Dedicated APORT0Y CHannel 8. */
394   acmpInputAPORT0YCH9  = _ACMP_INPUTSEL_POSSEL_APORT0YCH9,  /**< Select Dedicated APORT0Y CHannel 9. */
395   acmpInputAPORT0YCH10 = _ACMP_INPUTSEL_POSSEL_APORT0YCH10, /**< Select Dedicated APORT0Y CHannel 10. */
396   acmpInputAPORT0YCH11 = _ACMP_INPUTSEL_POSSEL_APORT0YCH11, /**< Select Dedicated APORT0Y CHannel 11. */
397   acmpInputAPORT0YCH12 = _ACMP_INPUTSEL_POSSEL_APORT0YCH12, /**< Select Dedicated APORT0Y CHannel 12. */
398   acmpInputAPORT0YCH13 = _ACMP_INPUTSEL_POSSEL_APORT0YCH13, /**< Select Dedicated APORT0Y CHannel 13. */
399   acmpInputAPORT0YCH14 = _ACMP_INPUTSEL_POSSEL_APORT0YCH14, /**< Select Dedicated APORT0Y CHannel 14. */
400   acmpInputAPORT0YCH15 = _ACMP_INPUTSEL_POSSEL_APORT0YCH15, /**< Select Dedicated APORT0Y CHannel 15. */
401   acmpInputAPORT1XCH0  = _ACMP_INPUTSEL_POSSEL_APORT1XCH0,  /**< Select Dedicated APORT1X CHannel 0. */
402   acmpInputAPORT1YCH1  = _ACMP_INPUTSEL_POSSEL_APORT1YCH1,  /**< Select Dedicated APORT1Y CHannel 1. */
403   acmpInputAPORT1XCH2  = _ACMP_INPUTSEL_POSSEL_APORT1XCH2,  /**< Select Dedicated APORT1X CHannel 2. */
404   acmpInputAPORT1YCH3  = _ACMP_INPUTSEL_POSSEL_APORT1YCH3,  /**< Select Dedicated APORT1Y CHannel 3. */
405   acmpInputAPORT1XCH4  = _ACMP_INPUTSEL_POSSEL_APORT1XCH4,  /**< Select Dedicated APORT1X CHannel 4. */
406   acmpInputAPORT1YCH5  = _ACMP_INPUTSEL_POSSEL_APORT1YCH5,  /**< Select Dedicated APORT1Y CHannel 5. */
407   acmpInputAPORT1XCH6  = _ACMP_INPUTSEL_POSSEL_APORT1XCH6,  /**< Select Dedicated APORT1X CHannel 6. */
408   acmpInputAPORT1YCH7  = _ACMP_INPUTSEL_POSSEL_APORT1YCH7,  /**< Select Dedicated APORT1Y CHannel 7. */
409   acmpInputAPORT1XCH8  = _ACMP_INPUTSEL_POSSEL_APORT1XCH8,  /**< Select Dedicated APORT1X CHannel 8. */
410   acmpInputAPORT1YCH9  = _ACMP_INPUTSEL_POSSEL_APORT1YCH9,  /**< Select Dedicated APORT1Y CHannel 9. */
411   acmpInputAPORT1XCH10 = _ACMP_INPUTSEL_POSSEL_APORT1XCH10, /**< Select Dedicated APORT1X CHannel 10. */
412   acmpInputAPORT1YCH11 = _ACMP_INPUTSEL_POSSEL_APORT1YCH11, /**< Select Dedicated APORT1Y CHannel 11. */
413   acmpInputAPORT1XCH12 = _ACMP_INPUTSEL_POSSEL_APORT1XCH12, /**< Select Dedicated APORT1X CHannel 12. */
414   acmpInputAPORT1YCH13 = _ACMP_INPUTSEL_POSSEL_APORT1YCH13, /**< Select Dedicated APORT1Y CHannel 13. */
415   acmpInputAPORT1XCH14 = _ACMP_INPUTSEL_POSSEL_APORT1XCH14, /**< Select Dedicated APORT1X CHannel 14. */
416   acmpInputAPORT1YCH15 = _ACMP_INPUTSEL_POSSEL_APORT1YCH15, /**< Select Dedicated APORT1Y CHannel 15. */
417   acmpInputAPORT1XCH16 = _ACMP_INPUTSEL_POSSEL_APORT1XCH16, /**< Select Dedicated APORT1X CHannel 16. */
418   acmpInputAPORT1YCH17 = _ACMP_INPUTSEL_POSSEL_APORT1YCH17, /**< Select Dedicated APORT1Y CHannel 17. */
419   acmpInputAPORT1XCH18 = _ACMP_INPUTSEL_POSSEL_APORT1XCH18, /**< Select Dedicated APORT1X CHannel 18. */
420   acmpInputAPORT1YCH19 = _ACMP_INPUTSEL_POSSEL_APORT1YCH19, /**< Select Dedicated APORT1Y CHannel 19. */
421   acmpInputAPORT1XCH20 = _ACMP_INPUTSEL_POSSEL_APORT1XCH20, /**< Select Dedicated APORT1X CHannel 20. */
422   acmpInputAPORT1YCH21 = _ACMP_INPUTSEL_POSSEL_APORT1YCH21, /**< Select Dedicated APORT1Y CHannel 21. */
423   acmpInputAPORT1XCH22 = _ACMP_INPUTSEL_POSSEL_APORT1XCH22, /**< Select Dedicated APORT1X CHannel 22. */
424   acmpInputAPORT1YCH23 = _ACMP_INPUTSEL_POSSEL_APORT1YCH23, /**< Select Dedicated APORT1Y CHannel 23. */
425   acmpInputAPORT1XCH24 = _ACMP_INPUTSEL_POSSEL_APORT1XCH24, /**< Select Dedicated APORT1X CHannel 24. */
426   acmpInputAPORT1YCH25 = _ACMP_INPUTSEL_POSSEL_APORT1YCH25, /**< Select Dedicated APORT1Y CHannel 25. */
427   acmpInputAPORT1XCH26 = _ACMP_INPUTSEL_POSSEL_APORT1XCH26, /**< Select Dedicated APORT1X CHannel 26. */
428   acmpInputAPORT1YCH27 = _ACMP_INPUTSEL_POSSEL_APORT1YCH27, /**< Select Dedicated APORT1Y CHannel 27. */
429   acmpInputAPORT1XCH28 = _ACMP_INPUTSEL_POSSEL_APORT1XCH28, /**< Select Dedicated APORT1X CHannel 28. */
430   acmpInputAPORT1YCH29 = _ACMP_INPUTSEL_POSSEL_APORT1YCH29, /**< Select Dedicated APORT1Y CHannel 29. */
431   acmpInputAPORT1XCH30 = _ACMP_INPUTSEL_POSSEL_APORT1XCH30, /**< Select Dedicated APORT1X CHannel 30. */
432   acmpInputAPORT1YCH31 = _ACMP_INPUTSEL_POSSEL_APORT1YCH31, /**< Select Dedicated APORT1Y CHannel 31. */
433   acmpInputAPORT2YCH0  = _ACMP_INPUTSEL_POSSEL_APORT2YCH0,  /**< Select Dedicated APORT2Y CHannel 0. */
434   acmpInputAPORT2XCH1  = _ACMP_INPUTSEL_POSSEL_APORT2XCH1,  /**< Select Dedicated APORT2X CHannel 1. */
435   acmpInputAPORT2YCH2  = _ACMP_INPUTSEL_POSSEL_APORT2YCH2,  /**< Select Dedicated APORT2Y CHannel 2. */
436   acmpInputAPORT2XCH3  = _ACMP_INPUTSEL_POSSEL_APORT2XCH3,  /**< Select Dedicated APORT2X CHannel 3. */
437   acmpInputAPORT2YCH4  = _ACMP_INPUTSEL_POSSEL_APORT2YCH4,  /**< Select Dedicated APORT2Y CHannel 4. */
438   acmpInputAPORT2XCH5  = _ACMP_INPUTSEL_POSSEL_APORT2XCH5,  /**< Select Dedicated APORT2X CHannel 5. */
439   acmpInputAPORT2YCH6  = _ACMP_INPUTSEL_POSSEL_APORT2YCH6,  /**< Select Dedicated APORT2Y CHannel 6. */
440   acmpInputAPORT2XCH7  = _ACMP_INPUTSEL_POSSEL_APORT2XCH7,  /**< Select Dedicated APORT2X CHannel 7. */
441   acmpInputAPORT2YCH8  = _ACMP_INPUTSEL_POSSEL_APORT2YCH8,  /**< Select Dedicated APORT2Y CHannel 8. */
442   acmpInputAPORT2XCH9  = _ACMP_INPUTSEL_POSSEL_APORT2XCH9,  /**< Select Dedicated APORT2X CHannel 9. */
443   acmpInputAPORT2YCH10 = _ACMP_INPUTSEL_POSSEL_APORT2YCH10, /**< Select Dedicated APORT2Y CHannel 10. */
444   acmpInputAPORT2XCH11 = _ACMP_INPUTSEL_POSSEL_APORT2XCH11, /**< Select Dedicated APORT2X CHannel 11. */
445   acmpInputAPORT2YCH12 = _ACMP_INPUTSEL_POSSEL_APORT2YCH12, /**< Select Dedicated APORT2Y CHannel 12. */
446   acmpInputAPORT2XCH13 = _ACMP_INPUTSEL_POSSEL_APORT2XCH13, /**< Select Dedicated APORT2X CHannel 13. */
447   acmpInputAPORT2YCH14 = _ACMP_INPUTSEL_POSSEL_APORT2YCH14, /**< Select Dedicated APORT2Y CHannel 14. */
448   acmpInputAPORT2XCH15 = _ACMP_INPUTSEL_POSSEL_APORT2XCH15, /**< Select Dedicated APORT2X CHannel 15. */
449   acmpInputAPORT2YCH16 = _ACMP_INPUTSEL_POSSEL_APORT2YCH16, /**< Select Dedicated APORT2Y CHannel 16. */
450   acmpInputAPORT2XCH17 = _ACMP_INPUTSEL_POSSEL_APORT2XCH17, /**< Select Dedicated APORT2X CHannel 17. */
451   acmpInputAPORT2YCH18 = _ACMP_INPUTSEL_POSSEL_APORT2YCH18, /**< Select Dedicated APORT2Y CHannel 18. */
452   acmpInputAPORT2XCH19 = _ACMP_INPUTSEL_POSSEL_APORT2XCH19, /**< Select Dedicated APORT2X CHannel 19. */
453   acmpInputAPORT2YCH20 = _ACMP_INPUTSEL_POSSEL_APORT2YCH20, /**< Select Dedicated APORT2Y CHannel 20. */
454   acmpInputAPORT2XCH21 = _ACMP_INPUTSEL_POSSEL_APORT2XCH21, /**< Select Dedicated APORT2X CHannel 21. */
455   acmpInputAPORT2YCH22 = _ACMP_INPUTSEL_POSSEL_APORT2YCH22, /**< Select Dedicated APORT2Y CHannel 22. */
456   acmpInputAPORT2XCH23 = _ACMP_INPUTSEL_POSSEL_APORT2XCH23, /**< Select Dedicated APORT2X CHannel 23. */
457   acmpInputAPORT2YCH24 = _ACMP_INPUTSEL_POSSEL_APORT2YCH24, /**< Select Dedicated APORT2Y CHannel 24. */
458   acmpInputAPORT2XCH25 = _ACMP_INPUTSEL_POSSEL_APORT2XCH25, /**< Select Dedicated APORT2X CHannel 25. */
459   acmpInputAPORT2YCH26 = _ACMP_INPUTSEL_POSSEL_APORT2YCH26, /**< Select Dedicated APORT2Y CHannel 26. */
460   acmpInputAPORT2XCH27 = _ACMP_INPUTSEL_POSSEL_APORT2XCH27, /**< Select Dedicated APORT2X CHannel 27. */
461   acmpInputAPORT2YCH28 = _ACMP_INPUTSEL_POSSEL_APORT2YCH28, /**< Select Dedicated APORT2Y CHannel 28. */
462   acmpInputAPORT2XCH29 = _ACMP_INPUTSEL_POSSEL_APORT2XCH29, /**< Select Dedicated APORT2X CHannel 29. */
463   acmpInputAPORT2YCH30 = _ACMP_INPUTSEL_POSSEL_APORT2YCH30, /**< Select Dedicated APORT2Y CHannel 30. */
464   acmpInputAPORT2XCH31 = _ACMP_INPUTSEL_POSSEL_APORT2XCH31, /**< Select Dedicated APORT2X CHannel 31. */
465   acmpInputAPORT3XCH0  = _ACMP_INPUTSEL_POSSEL_APORT3XCH0,  /**< Select Dedicated APORT3X CHannel 0. */
466   acmpInputAPORT3YCH1  = _ACMP_INPUTSEL_POSSEL_APORT3YCH1,  /**< Select Dedicated APORT3Y CHannel 1. */
467   acmpInputAPORT3XCH2  = _ACMP_INPUTSEL_POSSEL_APORT3XCH2,  /**< Select Dedicated APORT3X CHannel 2. */
468   acmpInputAPORT3YCH3  = _ACMP_INPUTSEL_POSSEL_APORT3YCH3,  /**< Select Dedicated APORT3Y CHannel 3. */
469   acmpInputAPORT3XCH4  = _ACMP_INPUTSEL_POSSEL_APORT3XCH4,  /**< Select Dedicated APORT3X CHannel 4. */
470   acmpInputAPORT3YCH5  = _ACMP_INPUTSEL_POSSEL_APORT3YCH5,  /**< Select Dedicated APORT3Y CHannel 5. */
471   acmpInputAPORT3XCH6  = _ACMP_INPUTSEL_POSSEL_APORT3XCH6,  /**< Select Dedicated APORT3X CHannel 6. */
472   acmpInputAPORT3YCH7  = _ACMP_INPUTSEL_POSSEL_APORT3YCH7,  /**< Select Dedicated APORT3Y CHannel 7. */
473   acmpInputAPORT3XCH8  = _ACMP_INPUTSEL_POSSEL_APORT3XCH8,  /**< Select Dedicated APORT3X CHannel 8. */
474   acmpInputAPORT3YCH9  = _ACMP_INPUTSEL_POSSEL_APORT3YCH9,  /**< Select Dedicated APORT3Y CHannel 9. */
475   acmpInputAPORT3XCH10 = _ACMP_INPUTSEL_POSSEL_APORT3XCH10, /**< Select Dedicated APORT3X CHannel 10. */
476   acmpInputAPORT3YCH11 = _ACMP_INPUTSEL_POSSEL_APORT3YCH11, /**< Select Dedicated APORT3Y CHannel 11. */
477   acmpInputAPORT3XCH12 = _ACMP_INPUTSEL_POSSEL_APORT3XCH12, /**< Select Dedicated APORT3X CHannel 12. */
478   acmpInputAPORT3YCH13 = _ACMP_INPUTSEL_POSSEL_APORT3YCH13, /**< Select Dedicated APORT3Y CHannel 13. */
479   acmpInputAPORT3XCH14 = _ACMP_INPUTSEL_POSSEL_APORT3XCH14, /**< Select Dedicated APORT3X CHannel 14. */
480   acmpInputAPORT3YCH15 = _ACMP_INPUTSEL_POSSEL_APORT3YCH15, /**< Select Dedicated APORT3Y CHannel 15. */
481   acmpInputAPORT3XCH16 = _ACMP_INPUTSEL_POSSEL_APORT3XCH16, /**< Select Dedicated APORT3X CHannel 16. */
482   acmpInputAPORT3YCH17 = _ACMP_INPUTSEL_POSSEL_APORT3YCH17, /**< Select Dedicated APORT3Y CHannel 17. */
483   acmpInputAPORT3XCH18 = _ACMP_INPUTSEL_POSSEL_APORT3XCH18, /**< Select Dedicated APORT3X CHannel 18. */
484   acmpInputAPORT3YCH19 = _ACMP_INPUTSEL_POSSEL_APORT3YCH19, /**< Select Dedicated APORT3Y CHannel 19. */
485   acmpInputAPORT3XCH20 = _ACMP_INPUTSEL_POSSEL_APORT3XCH20, /**< Select Dedicated APORT3X CHannel 20. */
486   acmpInputAPORT3YCH21 = _ACMP_INPUTSEL_POSSEL_APORT3YCH21, /**< Select Dedicated APORT3Y CHannel 21. */
487   acmpInputAPORT3XCH22 = _ACMP_INPUTSEL_POSSEL_APORT3XCH22, /**< Select Dedicated APORT3X CHannel 22. */
488   acmpInputAPORT3YCH23 = _ACMP_INPUTSEL_POSSEL_APORT3YCH23, /**< Select Dedicated APORT3Y CHannel 23. */
489   acmpInputAPORT3XCH24 = _ACMP_INPUTSEL_POSSEL_APORT3XCH24, /**< Select Dedicated APORT3X CHannel 24. */
490   acmpInputAPORT3YCH25 = _ACMP_INPUTSEL_POSSEL_APORT3YCH25, /**< Select Dedicated APORT3Y CHannel 25. */
491   acmpInputAPORT3XCH26 = _ACMP_INPUTSEL_POSSEL_APORT3XCH26, /**< Select Dedicated APORT3X CHannel 26. */
492   acmpInputAPORT3YCH27 = _ACMP_INPUTSEL_POSSEL_APORT3YCH27, /**< Select Dedicated APORT3Y CHannel 27. */
493   acmpInputAPORT3XCH28 = _ACMP_INPUTSEL_POSSEL_APORT3XCH28, /**< Select Dedicated APORT3X CHannel 28. */
494   acmpInputAPORT3YCH29 = _ACMP_INPUTSEL_POSSEL_APORT3YCH29, /**< Select Dedicated APORT3Y CHannel 29. */
495   acmpInputAPORT3XCH30 = _ACMP_INPUTSEL_POSSEL_APORT3XCH30, /**< Select Dedicated APORT3X CHannel 30. */
496   acmpInputAPORT3YCH31 = _ACMP_INPUTSEL_POSSEL_APORT3YCH31, /**< Select Dedicated APORT3Y CHannel 31. */
497   acmpInputAPORT4YCH0  = _ACMP_INPUTSEL_POSSEL_APORT4YCH0,  /**< Select Dedicated APORT4Y CHannel 0. */
498   acmpInputAPORT4XCH1  = _ACMP_INPUTSEL_POSSEL_APORT4XCH1,  /**< Select Dedicated APORT4X CHannel 1. */
499   acmpInputAPORT4YCH2  = _ACMP_INPUTSEL_POSSEL_APORT4YCH2,  /**< Select Dedicated APORT4Y CHannel 2. */
500   acmpInputAPORT4XCH3  = _ACMP_INPUTSEL_POSSEL_APORT4XCH3,  /**< Select Dedicated APORT4X CHannel 3. */
501   acmpInputAPORT4YCH4  = _ACMP_INPUTSEL_POSSEL_APORT4YCH4,  /**< Select Dedicated APORT4Y CHannel 4. */
502   acmpInputAPORT4XCH5  = _ACMP_INPUTSEL_POSSEL_APORT4XCH5,  /**< Select Dedicated APORT4X CHannel 5. */
503   acmpInputAPORT4YCH6  = _ACMP_INPUTSEL_POSSEL_APORT4YCH6,  /**< Select Dedicated APORT4Y CHannel 6. */
504   acmpInputAPORT4XCH7  = _ACMP_INPUTSEL_POSSEL_APORT4XCH7,  /**< Select Dedicated APORT4X CHannel 7. */
505   acmpInputAPORT4YCH8  = _ACMP_INPUTSEL_POSSEL_APORT4YCH8,  /**< Select Dedicated APORT4Y CHannel 8. */
506   acmpInputAPORT4XCH9  = _ACMP_INPUTSEL_POSSEL_APORT4XCH9,  /**< Select Dedicated APORT4X CHannel 9. */
507   acmpInputAPORT4YCH10 = _ACMP_INPUTSEL_POSSEL_APORT4YCH10, /**< Select Dedicated APORT4Y CHannel 10. */
508   acmpInputAPORT4XCH11 = _ACMP_INPUTSEL_POSSEL_APORT4XCH11, /**< Select Dedicated APORT4X CHannel 11. */
509   acmpInputAPORT4YCH12 = _ACMP_INPUTSEL_POSSEL_APORT4YCH12, /**< Select Dedicated APORT4Y CHannel 12. */
510   acmpInputAPORT4XCH13 = _ACMP_INPUTSEL_POSSEL_APORT4XCH13, /**< Select Dedicated APORT4X CHannel 13. */
511   acmpInputAPORT4YCH16 = _ACMP_INPUTSEL_POSSEL_APORT4YCH16, /**< Select Dedicated APORT4Y CHannel 14. */
512   acmpInputAPORT4XCH17 = _ACMP_INPUTSEL_POSSEL_APORT4XCH17, /**< Select Dedicated APORT4X CHannel 15. */
513   acmpInputAPORT4YCH18 = _ACMP_INPUTSEL_POSSEL_APORT4YCH18, /**< Select Dedicated APORT4Y CHannel 16. */
514   acmpInputAPORT4XCH19 = _ACMP_INPUTSEL_POSSEL_APORT4XCH19, /**< Select Dedicated APORT4X CHannel 17. */
515   acmpInputAPORT4YCH20 = _ACMP_INPUTSEL_POSSEL_APORT4YCH20, /**< Select Dedicated APORT4Y CHannel 18. */
516   acmpInputAPORT4XCH21 = _ACMP_INPUTSEL_POSSEL_APORT4XCH21, /**< Select Dedicated APORT4X CHannel 19. */
517   acmpInputAPORT4YCH22 = _ACMP_INPUTSEL_POSSEL_APORT4YCH22, /**< Select Dedicated APORT4Y CHannel 20. */
518   acmpInputAPORT4XCH23 = _ACMP_INPUTSEL_POSSEL_APORT4XCH23, /**< Select Dedicated APORT4X CHannel 21. */
519   acmpInputAPORT4YCH24 = _ACMP_INPUTSEL_POSSEL_APORT4YCH24, /**< Select Dedicated APORT4Y CHannel 22. */
520   acmpInputAPORT4XCH25 = _ACMP_INPUTSEL_POSSEL_APORT4XCH25, /**< Select Dedicated APORT4X CHannel 23. */
521   acmpInputAPORT4YCH26 = _ACMP_INPUTSEL_POSSEL_APORT4YCH26, /**< Select Dedicated APORT4Y CHannel 24. */
522   acmpInputAPORT4XCH27 = _ACMP_INPUTSEL_POSSEL_APORT4XCH27, /**< Select Dedicated APORT4X CHannel 25. */
523   acmpInputAPORT4YCH28 = _ACMP_INPUTSEL_POSSEL_APORT4YCH28, /**< Select Dedicated APORT4Y CHannel 26. */
524   acmpInputAPORT4XCH29 = _ACMP_INPUTSEL_POSSEL_APORT4XCH29, /**< Select Dedicated APORT4X CHannel 27. */
525   acmpInputAPORT4YCH30 = _ACMP_INPUTSEL_POSSEL_APORT4YCH30, /**< Select Dedicated APORT4Y CHannel 28. */
526   acmpInputAPORT4YCH14 = _ACMP_INPUTSEL_POSSEL_APORT4YCH14, /**< Select Dedicated APORT4X CHannel 29. */
527   acmpInputAPORT4XCH15 = _ACMP_INPUTSEL_POSSEL_APORT4XCH15, /**< Select Dedicated APORT4Y CHannel 30. */
528   acmpInputAPORT4XCH31 = _ACMP_INPUTSEL_POSSEL_APORT4XCH31, /**< Select Dedicated APORT4X CHannel 31. */
529 #if defined(_ACMP_INPUTSEL_POSSEL_DACOUT0)
530   acmpInputDACOUT0   = _ACMP_INPUTSEL_POSSEL_DACOUT0, /**< Select DAC Channel 0 Output. */
531 #endif
532 #if defined(_ACMP_INPUTSEL_POSSEL_DACOUT1)
533   acmpInputDACOUT1   = _ACMP_INPUTSEL_POSSEL_DACOUT1, /**< Select DAC Channel 1 Output. */
534 #endif
535   acmpInputVLP       = _ACMP_INPUTSEL_POSSEL_VLP,   /**< Select Low-Power Sampled Voltage. */
536   acmpInputVBDIV     = _ACMP_INPUTSEL_POSSEL_VBDIV, /**< Select Divided VB Voltage. */
537   acmpInputVADIV     = _ACMP_INPUTSEL_POSSEL_VADIV, /**< Select Divided VA Voltage. */
538   acmpInputVDD       = _ACMP_INPUTSEL_POSSEL_VDD,   /**< ACMPVDD as selected via PWRSEL. */
539   acmpInputVSS       = _ACMP_INPUTSEL_POSSEL_VSS,   /**< Select VSS. */
540 } ACMP_Channel_TypeDef;
541 #else
542 /** ACMP inputs. Note that scaled VDD and bandgap references can only be used
543  *  as negative inputs. */
544 typedef enum {
545   /** Channel 0 */
546   acmpChannel0    = _ACMP_INPUTSEL_NEGSEL_CH0,
547   /** Channel 1 */
548   acmpChannel1    = _ACMP_INPUTSEL_NEGSEL_CH1,
549   /** Channel 2 */
550   acmpChannel2    = _ACMP_INPUTSEL_NEGSEL_CH2,
551   /** Channel 3 */
552   acmpChannel3    = _ACMP_INPUTSEL_NEGSEL_CH3,
553   /** Channel 4 */
554   acmpChannel4    = _ACMP_INPUTSEL_NEGSEL_CH4,
555   /** Channel 5 */
556   acmpChannel5    = _ACMP_INPUTSEL_NEGSEL_CH5,
557   /** Channel 6 */
558   acmpChannel6    = _ACMP_INPUTSEL_NEGSEL_CH6,
559   /** Channel 7 */
560   acmpChannel7    = _ACMP_INPUTSEL_NEGSEL_CH7,
561   /** 1.25 V internal reference */
562   acmpChannel1V25 = _ACMP_INPUTSEL_NEGSEL_1V25,
563   /** 2.5 V internal reference */
564   acmpChannel2V5  = _ACMP_INPUTSEL_NEGSEL_2V5,
565   /** Scaled VDD reference */
566   acmpChannelVDD  = _ACMP_INPUTSEL_NEGSEL_VDD,
567 
568 #if defined(_ACMP_INPUTSEL_NEGSEL_DAC0CH0)
569   /** DAC0 channel 0 */
570   acmpChannelDAC0Ch0 = _ACMP_INPUTSEL_NEGSEL_DAC0CH0,
571 #endif
572 
573 #if defined(_ACMP_INPUTSEL_NEGSEL_DAC0CH1)
574   /** DAC0 channel 1 */
575   acmpChannelDAC0Ch1 = _ACMP_INPUTSEL_NEGSEL_DAC0CH1,
576 #endif
577 
578 #if defined(_ACMP_INPUTSEL_NEGSEL_CAPSENSE)
579   /** Capacitive sense mode */
580   acmpChannelCapSense = _ACMP_INPUTSEL_NEGSEL_CAPSENSE,
581 #endif
582 } ACMP_Channel_TypeDef;
583 #endif
584 
585 #if defined(_ACMP_EXTIFCTRL_MASK)
586 /**
587  * ACMP external input select. This type is used to select which APORT is
588  * used by an external module, such as LESENSE, when it's taking control over
589  * the ACMP input.
590  */
591 typedef enum {
592   acmpExternalInputAPORT0X  = _ACMP_EXTIFCTRL_APORTSEL_APORT0X,  /**< Select APORT0X as an external input. */
593   acmpExternalInputAPORT0Y  = _ACMP_EXTIFCTRL_APORTSEL_APORT0Y,  /**< Select APORT0Y as an external input. */
594   acmpExternalInputAPORT1X  = _ACMP_EXTIFCTRL_APORTSEL_APORT1X,  /**< Select APORT1X as an external input. */
595   acmpExternalInputAPORT1Y  = _ACMP_EXTIFCTRL_APORTSEL_APORT1Y,  /**< Select APORT1Y as an external input. */
596   acmpExternalInputAPORT1XY = _ACMP_EXTIFCTRL_APORTSEL_APORT1XY, /**< Select APORT1XY as an external input. */
597   acmpExternalInputAPORT2X  = _ACMP_EXTIFCTRL_APORTSEL_APORT2X,  /**< Select APORT2X as an external input. */
598   acmpExternalInputAPORT2Y  = _ACMP_EXTIFCTRL_APORTSEL_APORT2Y,  /**< Select APORT2Y as an external input. */
599   acmpExternalInputAPORT2YX = _ACMP_EXTIFCTRL_APORTSEL_APORT2YX, /**< Select APORT2YX as an external input. */
600   acmpExternalInputAPORT3X  = _ACMP_EXTIFCTRL_APORTSEL_APORT3X,  /**< Select APORT3X as an external input. */
601   acmpExternalInputAPORT3Y  = _ACMP_EXTIFCTRL_APORTSEL_APORT3Y,  /**< Select APORT3Y as an external input. */
602   acmpExternalInputAPORT3XY = _ACMP_EXTIFCTRL_APORTSEL_APORT3XY, /**< Select APORT3XY as an external input. */
603   acmpExternalInputAPORT4X  = _ACMP_EXTIFCTRL_APORTSEL_APORT4X,  /**< Select APORT4X as an external input. */
604   acmpExternalInputAPORT4Y  = _ACMP_EXTIFCTRL_APORTSEL_APORT4Y,  /**< Select APORT4Y as an external input. */
605   acmpExternalInputAPORT4YX = _ACMP_EXTIFCTRL_APORTSEL_APORT4YX, /**< Select APORT4YX as an external input. */
606 } ACMP_ExternalInput_Typedef;
607 #endif
608 
609 /*******************************************************************************
610  ******************************   STRUCTS   ************************************
611  ******************************************************************************/
612 
613 /** Capsense initialization structure. */
614 typedef struct {
615 #if defined(_ACMP_CTRL_FULLBIAS_MASK)
616   /** Full-bias current. See the ACMP chapter about bias and response time in
617    *  the reference manual for details. */
618   bool                          fullBias;
619 #endif
620 
621 #if defined(_ACMP_CTRL_HALFBIAS_MASK)
622   /** Half-bias current. See the ACMP chapter about bias and response time in
623    *  the reference manual for details. */
624   bool                          halfBias;
625 #endif
626 
627   /** Bias current. See the ACMP chapter about bias and response time in the
628    *  reference manual for details. */
629   uint32_t                      biasProg;
630 
631 #if defined(_ACMP_CTRL_WARMTIME_MASK)
632   /** Warmup time, which is measured in HFPERCLK / HFPERCCLK cycles and should be
633    *  about 10 us in wall clock time. */
634   ACMP_WarmTime_TypeDef         warmTime;
635 #endif
636 
637 #if defined(_ACMP_CTRL_HYSTSEL_MASK) \
638   ||  defined(_ACMP_CFG_HYST_MASK)
639   /** Hysteresis level. */
640   ACMP_HysteresisLevel_TypeDef  hysteresisLevel;
641 #else
642   /** Hysteresis level when ACMP output is 0. */
643   ACMP_HysteresisLevel_TypeDef  hysteresisLevel_0;
644 
645   /** Hysteresis level when ACMP output is 1. */
646   ACMP_HysteresisLevel_TypeDef  hysteresisLevel_1;
647 #endif
648 
649   /** A resistor used in the capacitive sensing circuit. For values see
650    *  the device data sheet. */
651   ACMP_CapsenseResistor_TypeDef resistor;
652 
653 #if defined(_ACMP_INPUTSEL_LPREF_MASK)
654   /** Low-power reference enabled. This setting, if enabled, reduces the
655    *  power used by VDD and bandgap references. */
656   bool                          lowPowerReferenceEnabled;
657 #endif
658 
659 #if defined(_ACMP_INPUTCTRL_VREFDIV_MASK)
660   /** VDD division factor. VREFOUT = VREFIN * (VREFDIV / 63).
661    *  Valid values are in the 0-63 range. */
662   uint32_t                      vrefDiv;
663 #elif defined(_ACMP_INPUTSEL_VDDLEVEL_MASK)
664   /** VDD reference value. VDD_SCALED = (VDD * VDDLEVEL) / 63.
665    *  Valid values are in the 0-63 range. */
666   uint32_t                      vddLevel;
667 #else
668   /**
669    * This value configures the upper voltage threshold of the capsense
670    * oscillation rail.
671    *
672    * The voltage threshold is calculated as follows:
673    *   VDD * (vddLevelHigh + 1) / 64
674    */
675   uint32_t                      vddLevelHigh;
676 
677   /**
678    * This value configures the lower voltage threshold of the capsense
679    * oscillation rail.
680    *
681    * The voltage threshold is calculated as follows:
682    *   VDD * (vddLevelLow + 1) / 64
683    */
684   uint32_t                      vddLevelLow;
685 #endif
686 
687   /** If true, ACMP is enabled after configuration. */
688   bool                          enable;
689 } ACMP_CapsenseInit_TypeDef;
690 
691 /** A default configuration for capacitive sense mode initialization. */
692 #if defined(_ACMP_CFG_MASK)
693 
694 // PM5507: provide default configuration that is functional
695 /** Analog comparator CFG with initial bias value */
696 #define PM5507_ACMP_CFG_BIAS_DEFAULT  0x00000004UL
697 /** Analog comparator reset value */
698 #define PM5507_ACMP_CFG_RESETVALUE    0x00000004UL
699 
700 /** Capacitive sense mode configuration default values. */
701 #define ACMP_CAPSENSE_INIT_DEFAULT                                                \
702   {                                                                               \
703     PM5507_ACMP_CFG_BIAS_DEFAULT, /* Using biasProg default value. */             \
704     acmpHysteresisDisabled,       /* Disable hysteresis. */                       \
705     acmpResistor5,                /* Use internal resistor value 5. */            \
706     0x3F,                         /* Set VREFDIV to maximum to disable divide. */ \
707     true                          /* Enable after init. */                        \
708   }
709 #elif defined(_ACMP_HYSTERESIS0_HYST_MASK)
710 #define ACMP_CAPSENSE_INIT_DEFAULT                                            \
711   {                                                                           \
712     false,              /* Don't use fullBias to lower power consumption. */  \
713     0x20,               /* Using biasProg value of 0x20 (32). */              \
714     acmpHysteresisLevel8, /* Use hysteresis level 8 when ACMP output is 0. */ \
715     acmpHysteresisLevel8, /* Use hysteresis level 8 when ACMP output is 1. */ \
716     acmpResistor5,      /* Use internal resistor value 5. */                  \
717     0x30,               /* VDD level high. */                                 \
718     0x10,               /* VDD level low. */                                  \
719     true                /* Enable after initialization. */                    \
720   }
721 #elif defined(_ACMP_CTRL_WARMTIME_MASK)
722 #define ACMP_CAPSENSE_INIT_DEFAULT                      \
723   {                                                     \
724     false,            /* fullBias */                    \
725     false,            /* halfBias */                    \
726     0x7,              /* biasProg */                    \
727     acmpWarmTime512,  /* 512 cycle warmup to be safe */ \
728     acmpHysteresisLevel5,                               \
729     acmpResistor3,                                      \
730     false,            /* low power reference */         \
731     0x3D,             /* VDD level */                   \
732     true              /* Enable after init. */          \
733   }
734 #else
735 #define ACMP_CAPSENSE_INIT_DEFAULT              \
736   {                                             \
737     false,            /* fullBias */            \
738     false,            /* halfBias */            \
739     0x7,              /* biasProg */            \
740     acmpHysteresisLevel5,                       \
741     acmpResistor3,                              \
742     false,            /* low power reference */ \
743     0x3D,             /* VDD level */           \
744     true              /* Enable after init. */  \
745   }
746 #endif
747 
748 /** ACMP initialization structure. */
749 typedef struct {
750 #if defined(_ACMP_CTRL_FULLBIAS_MASK)
751   /** Full-bias current. See the ACMP chapter about bias and response time in
752    *  the reference manual for details. */
753   bool                         fullBias;
754 #endif
755 
756 #if defined(_ACMP_CTRL_HALFBIAS_MASK)
757   /** Half-bias current. See the ACMP chapter about bias and response time in
758    *  the reference manual for details. */
759   bool                         halfBias;
760 #endif
761 
762   /** Bias current. See the ACMP chapter about bias and response time in the
763    *  reference manual for details. Valid values are in the range 0-7. */
764   uint32_t                     biasProg;
765 
766 #if defined(_ACMP_CTRL_IFALL_SHIFT)
767   /** Enable setting the interrupt flag on the falling edge. */
768   bool                         interruptOnFallingEdge;
769 #endif
770 #if defined(_ACMP_CTRL_IRISE_SHIFT)
771   /** Enable setting the interrupt flag on the rising edge. */
772   bool                         interruptOnRisingEdge;
773 #endif
774 
775 #if defined(_ACMP_CTRL_INPUTRANGE_MASK) \
776   || defined(_ACMP_CFG_INPUTRANGE_MASK)
777   /** Input range. Adjust this setting to optimize the performance for a
778    *  given input voltage range.  */
779   ACMP_InputRange_TypeDef      inputRange;
780 #endif
781 
782 #if defined(_ACMP_CTRL_ACCURACY_MASK) \
783   || defined(_ACMP_CFG_ACCURACY_MASK)
784   /** ACMP accuracy mode. Select the accuracy mode that matches the
785    *  required current usage and accuracy requirement. Low accuracy
786    *  consumes less current while high accuracy consumes more current. */
787   ACMP_Accuracy_TypeDef        accuracy;
788 #endif
789 
790 #if defined(_ACMP_CTRL_PWRSEL_MASK)
791   /** Select the power source for the ACMP. */
792   ACMP_PowerSource_TypeDef     powerSource;
793 #endif
794 
795 #if defined(_ACMP_CTRL_WARMTIME_MASK)
796   /** Warmup time, which is measured in HFPERCLK / HFPERCCLK cycles and should be
797    *  about 10 us in wall clock time. */
798   ACMP_WarmTime_TypeDef        warmTime;
799 #endif
800 
801 #if defined(_ACMP_CTRL_HYSTSEL_MASK) \
802   ||  defined(_ACMP_CFG_HYST_MASK)
803   /** Hysteresis level. */
804   ACMP_HysteresisLevel_TypeDef hysteresisLevel;
805 #else
806   /** Hysteresis when ACMP output is 0. */
807   ACMP_HysteresisLevel_TypeDef hysteresisLevel_0;
808 
809   /** Hysteresis when ACMP output is 1. */
810   ACMP_HysteresisLevel_TypeDef hysteresisLevel_1;
811 #endif
812 
813 #if defined(_ACMP_INPUTSEL_VLPSEL_MASK)
814   /** VLP Input source. Select between using VADIV or VBDIV as the VLP
815    *  source. */
816   ACMP_VLPInput_Typedef        vlpInput;
817 #endif
818 
819   /** Inactive value emitted by ACMP during warmup. */
820   bool                         inactiveValue;
821 
822 #if defined(_ACMP_INPUTSEL_LPREF_MASK)
823   /** Low power reference enabled. This setting, if enabled, reduces the
824    *  power used by the VDD and bandgap references. */
825   bool                         lowPowerReferenceEnabled;
826 #endif
827 
828 #if defined(_ACMP_INPUTCTRL_VREFDIV_MASK)
829   /** VDD division factor. VREFOUT = VREFIN * (VREFDIV / 63).
830    *  Valid values are in the 0-63 range. */
831   uint32_t                     vrefDiv;
832 #elif defined(_ACMP_INPUTSEL_VDDLEVEL_MASK)
833   /** VDD reference value. VDD_SCALED = VDD * VDDLEVEL * 50 mV/3.8 V.
834    *  Valid values are in the 0-63 range. */
835   uint32_t                     vddLevel;
836 #endif
837 
838   /** If true, ACMP is enabled after configuration. */
839   bool                         enable;
840 } ACMP_Init_TypeDef;
841 
842 /** Default configuration for ACMP regular initialization. */
843 #if defined(_ACMP_CFG_MASK)
844 #define ACMP_INIT_DEFAULT                                                         \
845   {                                                                               \
846     PM5507_ACMP_CFG_BIAS_DEFAULT, /* Using biasProg default value. */             \
847     acmpInputRangeFull,           /* Input range from 0 to Vdd. */                \
848     acmpAccuracyLow,              /* Low accuracy, less current usage. */         \
849     acmpHysteresisDisabled,       /* Disable hysteresis. */                       \
850     false,                        /* Output 0 when ACMP is inactive. */           \
851     0x3F,                         /* Set VREFDIV to maximum to disable divide. */ \
852     true                          /* Enable after init. */                        \
853   }
854 #elif defined(_ACMP_HYSTERESIS0_HYST_MASK)
855 #define ACMP_INIT_DEFAULT                                                   \
856   {                                                                         \
857     false,                    /* fullBias */                                \
858     0x7,                      /* biasProg */                                \
859     false,                    /* No interrupt on falling edge. */           \
860     false,                    /* No interrupt on rising edge. */            \
861     acmpInputRangeFull,       /* Input range from 0 to VDD. */              \
862     acmpAccuracyLow,          /* Low accuracy, less current usage. */       \
863     acmpPowerSourceAvdd,      /* Use the AVDD supply. */                    \
864     acmpHysteresisLevel5,     /* Use hysteresis level 5 when output is 0 */ \
865     acmpHysteresisLevel5,     /* Use hysteresis level 5 when output is 1 */ \
866     acmpVLPInputVADIV,        /* Use VADIV as the VLP input source. */      \
867     false,                    /* Output 0 when ACMP is inactive. */         \
868     true                      /* Enable after init. */                      \
869   }
870 #else
871 #define ACMP_INIT_DEFAULT                                                   \
872   {                                                                         \
873     false,            /* fullBias */                                        \
874     false,            /* halfBias */                                        \
875     0x7,              /* biasProg */                                        \
876     false,            /* No interrupt on falling edge. */                   \
877     false,            /* No interrupt on rising edge. */                    \
878     acmpWarmTime512,  /* 512 cycle warmup to be safe */                     \
879     acmpHysteresisLevel5,                                                   \
880     false,            /* Disabled emitting inactive value during warmup. */ \
881     false,            /* low power reference */                             \
882     0x3D,             /* VDD level */                                       \
883     true              /* Enable after init. */                              \
884   }
885 #endif
886 
887 #if defined(_ACMP_INPUTSEL_VASEL_MASK)
888 /** VA Configuration structure. This structure is used to configure the
889  *  VA voltage input source and its dividers. */
890 typedef struct {
891   ACMP_VAInput_TypeDef input; /**< VA voltage input source */
892 
893   /**
894    * A divider for VA voltage input source when ACMP output is 0. This value is
895    * used to divide the VA voltage input source by a specific value. The valid
896    * range is between 0 and 63.
897    *
898    *  VA divided = VA input * (div0 + 1) / 64
899    */
900   uint32_t             div0;
901 
902   /**
903    * A divider for VA voltage input source when ACMP output is 1. This value is
904    * used to divide the VA voltage input source by a specific value. The valid
905    * range is between 0 and 63.
906    *
907    *  VA divided = VA input * (div1 + 1) / 64
908    */
909   uint32_t             div1;
910 } ACMP_VAConfig_TypeDef;
911 
912 /** VA default configuration. */
913 #define ACMP_VACONFIG_DEFAULT                                               \
914   {                                                                         \
915     acmpVAInputVDD, /* Use VDD as VA voltage input source. */               \
916     63,           /* No division of the VA source when ACMP output is 0. */ \
917     63,           /* No division of the VA source when ACMP output is 1. */ \
918   }
919 #endif
920 
921 #if defined(_ACMP_INPUTSEL_VBSEL_MASK)
922 /** VB Configuration structure. This structure is used to configure the
923  *  VB voltage input source and its dividers. */
924 typedef struct {
925   ACMP_VBInput_TypeDef input; /**< VB Voltage input source */
926 
927   /**
928    * A divider for VB voltage input source when ACMP output is 0. This value is
929    * used to divide the VB voltage input source by a specific value. The valid
930    * range is between 0 and 63.
931    *
932    *  VB divided = VB input * (div0 + 1) / 64
933    */
934   uint32_t             div0;
935 
936   /**
937    * A divider for VB voltage input source when ACMP output is 1. This value is
938    * used to divide the VB voltage input source by a specific value. The valid
939    * range is between 0 and 63.
940    *
941    *  VB divided = VB input * (div1 + 1) / 64
942    */
943   uint32_t             div1;
944 } ACMP_VBConfig_TypeDef;
945 
946 /** VB default configuration. */
947 #define ACMP_VBCONFIG_DEFAULT                                                \
948   {                                                                          \
949     acmpVBInput1V25, /* Use 1.25 V as VB voltage input source. */            \
950     63,            /* No division of the VB source when ACMP output is 0. */ \
951     63,            /* No division of the VB source when ACMP output is 1. */ \
952   }
953 #endif
954 
955 /*******************************************************************************
956  *****************************   PROTOTYPES   **********************************
957  ******************************************************************************/
958 
959 void ACMP_CapsenseInit(ACMP_TypeDef *acmp, const ACMP_CapsenseInit_TypeDef *init);
960 void ACMP_CapsenseChannelSet(ACMP_TypeDef *acmp, ACMP_Channel_TypeDef channel);
961 void ACMP_ChannelSet(ACMP_TypeDef *acmp, ACMP_Channel_TypeDef negSel, ACMP_Channel_TypeDef posSel);
962 void ACMP_Disable(ACMP_TypeDef *acmp);
963 void ACMP_Enable(ACMP_TypeDef *acmp);
964 #if defined(_ACMP_EXTIFCTRL_MASK)
965 void ACMP_ExternalInputSelect(ACMP_TypeDef *acmp, ACMP_ExternalInput_Typedef aport);
966 #endif
967 #if defined(_GPIO_ACMP_ROUTEEN_MASK)
968 void ACMP_GPIOSetup(ACMP_TypeDef *acmp, GPIO_Port_TypeDef port, unsigned int pin, bool enable, bool invert);
969 #else
970 void ACMP_GPIOSetup(ACMP_TypeDef *acmp, uint32_t location, bool enable, bool invert);
971 #endif
972 void ACMP_Init(ACMP_TypeDef *acmp, const ACMP_Init_TypeDef *init);
973 void ACMP_Reset(ACMP_TypeDef *acmp);
974 #if defined(_ACMP_INPUTSEL_VASEL_MASK)
975 void ACMP_VASetup(ACMP_TypeDef *acmp, const ACMP_VAConfig_TypeDef *vaconfig);
976 #endif
977 #if defined(_ACMP_INPUTSEL_VBSEL_MASK)
978 void ACMP_VBSetup(ACMP_TypeDef *acmp, const ACMP_VBConfig_TypeDef *vbconfig);
979 #endif
980 
981 /***************************************************************************//**
982  * @brief
983  *   Clear one or more pending ACMP interrupts.
984  *
985  * @param[in] acmp
986  *   A pointer to the ACMP peripheral register block.
987  *
988  * @param[in] flags
989  *   Pending ACMP interrupt source to clear. Use a bitwise logic OR combination
990  *   of valid interrupt flags for the ACMP module. The flags can be, for instance,
991  *   ACMP_IFC_EDGE or ACMP_IFC_WARMUP.
992  ******************************************************************************/
ACMP_IntClear(ACMP_TypeDef * acmp,uint32_t flags)993 __STATIC_INLINE void ACMP_IntClear(ACMP_TypeDef *acmp, uint32_t flags)
994 {
995 #if defined(ACMP_HAS_SET_CLEAR)
996   acmp->IF_CLR = flags;
997 #else
998   acmp->IFC = flags;
999 #endif
1000 }
1001 
1002 /***************************************************************************//**
1003  * @brief
1004  *   Disable one or more ACMP interrupts.
1005  *
1006  * @param[in] acmp
1007  *   A pointer to the ACMP peripheral register block.
1008  *
1009  * @param[in] flags
1010  *   ACMP interrupt sources to disable. Use a bitwise logic OR combination of
1011  *   valid interrupt flags for the ACMP module. The flags can be, for instance,
1012  *   ACMP_IEN_EDGE or ACMP_IEN_WARMUP.
1013  ******************************************************************************/
ACMP_IntDisable(ACMP_TypeDef * acmp,uint32_t flags)1014 __STATIC_INLINE void ACMP_IntDisable(ACMP_TypeDef *acmp, uint32_t flags)
1015 {
1016   BUS_RegMaskedClear(&(acmp->IEN), flags);
1017 }
1018 
1019 /***************************************************************************//**
1020  * @brief
1021  *   Enable one or more ACMP interrupts.
1022  *
1023  * @note
1024  *   Depending on the use, a pending interrupt may already be set prior to
1025  *   enabling the interrupt. Consider using ACMP_IntClear() prior to enabling
1026  *   if a pending interrupt should be ignored.
1027  *
1028  * @param[in] acmp
1029  *   A pointer to the ACMP peripheral register block.
1030  *
1031  * @param[in] flags
1032  *   ACMP interrupt sources to enable. Use a bitwise logic OR combination of
1033  *   valid interrupt flags for the ACMP module. The flags can be, for instance,
1034  *   ACMP_IEN_EDGE or ACMP_IEN_WARMUP.
1035  ******************************************************************************/
ACMP_IntEnable(ACMP_TypeDef * acmp,uint32_t flags)1036 __STATIC_INLINE void ACMP_IntEnable(ACMP_TypeDef *acmp, uint32_t flags)
1037 {
1038 #if defined(ACMP_HAS_SET_CLEAR)
1039   acmp->IEN_SET = flags;
1040 #else
1041   acmp->IEN |= flags;
1042 #endif
1043 }
1044 
1045 /***************************************************************************//**
1046  * @brief
1047  *   Get pending ACMP interrupt flags.
1048  *
1049  * @note
1050  *   This function does not clear event bits.
1051  *
1052  * @param[in] acmp
1053  *   A pointer to the ACMP peripheral register block.
1054  *
1055  * @return
1056  *   Pending ACMP interrupt sources. A bitwise logic OR combination of valid
1057  *   interrupt flags for the ACMP module. The pending interrupt sources can be,
1058  *   for instance, ACMP_IF_EDGE or ACMP_IF_WARMUP.
1059  ******************************************************************************/
ACMP_IntGet(ACMP_TypeDef * acmp)1060 __STATIC_INLINE uint32_t ACMP_IntGet(ACMP_TypeDef *acmp)
1061 {
1062   return acmp->IF;
1063 }
1064 
1065 /***************************************************************************//**
1066  * @brief
1067  *   Get enabled and pending ACMP interrupt flags.
1068  *   Useful for handling more interrupt sources in the same interrupt handler.
1069  *
1070  * @param[in] acmp
1071  *   A pointer to the ACMP peripheral register block.
1072  *
1073  * @note
1074  *   This function does not clear interrupt flags.
1075  *
1076  * @return
1077  *   Pending and enabled ACMP interrupt sources.
1078  *   The return value is the bitwise AND combination of
1079  *   - the OR combination of enabled interrupt sources in ACMPx_IEN_nnn
1080  *     register (ACMPx_IEN_nnn) and
1081  *   - the OR combination of valid interrupt flags of the ACMP module
1082  *     (ACMPx_IF_nnn).
1083  ******************************************************************************/
ACMP_IntGetEnabled(ACMP_TypeDef * acmp)1084 __STATIC_INLINE uint32_t ACMP_IntGetEnabled(ACMP_TypeDef *acmp)
1085 {
1086   uint32_t tmp;
1087 
1088   /* Store ACMPx->IEN in a temporary variable to define the explicit order
1089    * of volatile accesses. */
1090   tmp = acmp->IEN;
1091 
1092   /* Bitwise AND of pending and enabled interrupts. */
1093   return acmp->IF & tmp;
1094 }
1095 
1096 /***************************************************************************//**
1097  * @brief
1098  *   Set one or more pending ACMP interrupts from software.
1099  *
1100  * @param[in] acmp
1101  *   A pointer to the ACMP peripheral register block.
1102  *
1103  * @param[in] flags
1104  *   ACMP interrupt sources to set as pending. Use a bitwise logic OR
1105  *   combination of valid interrupt flags for the ACMP module. The flags can be,
1106  *   for instance, ACMP_IFS_EDGE or ACMP_IFS_WARMUP.
1107  ******************************************************************************/
ACMP_IntSet(ACMP_TypeDef * acmp,uint32_t flags)1108 __STATIC_INLINE void ACMP_IntSet(ACMP_TypeDef *acmp, uint32_t flags)
1109 {
1110 #if defined(ACMP_HAS_SET_CLEAR)
1111   acmp->IF_SET = flags;
1112 #else
1113   acmp->IFS = flags;
1114 #endif
1115 }
1116 
1117 #if defined(_ACMP_INPUTCTRL_MASK)
1118 /***************************************************************************//**
1119  * @brief
1120  *   Convert GPIO port/pin to ACMP input selection.
1121  *
1122  * @param[in] port
1123  *   GPIO port
1124  *
1125  * @param[in] pin
1126  *   GPIO pin
1127  *
1128  * @return
1129  *   ACMP input selection
1130  ******************************************************************************/
ACMP_PortPinToInput(GPIO_Port_TypeDef port,uint8_t pin)1131 __STATIC_INLINE ACMP_Channel_TypeDef ACMP_PortPinToInput(GPIO_Port_TypeDef port, uint8_t pin)
1132 {
1133   uint32_t input = (((uint32_t) port + (_ACMP_INPUTCTRL_POSSEL_PA0 >> 4)) << 4) | pin;
1134 
1135   return (ACMP_Channel_TypeDef) input;
1136 }
1137 #endif
1138 
1139 /***************************************************************************//**
1140  * @brief
1141  *   Get state of ACMP output value
1142  *
1143  * @param[in] acmp
1144  *   A pointer to the ACMP peripheral register block.
1145  *
1146  * @return
1147  *   State of ACMP output value
1148  ******************************************************************************/
ACMP_OutputGet(ACMP_TypeDef * acmp)1149 __STATIC_INLINE bool ACMP_OutputGet(ACMP_TypeDef *acmp)
1150 {
1151   /* Waiting for ACMP is ready*/
1152 #if defined(ACMP_STATUS_ACMPRDY)
1153   while (!(acmp->STATUS & ACMP_STATUS_ACMPRDY)) ;
1154 #elif defined(ACMP_STATUS_ACMPACT)
1155   while (!(acmp->STATUS & ACMP_STATUS_ACMPACT)) ;
1156 #endif
1157 
1158   return (acmp->STATUS & ACMP_STATUS_ACMPOUT);
1159 }
1160 
1161 /** @} (end addtogroup acmp) */
1162 
1163 #ifdef __cplusplus
1164 }
1165 #endif
1166 
1167 #endif /* defined(ACMP_COUNT) && (ACMP_COUNT > 0) */
1168 #endif /* EM_ACMP_H */
1169