35 #if defined(ACMP_COUNT) && (ACMP_COUNT > 0)
61 #define ACMP_REF_VALID(ref) ((ref) == ACMP0)
62 #elif (ACMP_COUNT == 2)
63 #define ACMP_REF_VALID(ref) (((ref) == ACMP0) || ((ref) == ACMP1))
65 #error Undefined number of analog comparators (ACMP).
70 #if defined(_ACMP_ROUTE_LOCATION_LOC3)
71 #define _ACMP_ROUTE_LOCATION_MAX _ACMP_ROUTE_LOCATION_LOC3
72 #elif defined(_ACMP_ROUTE_LOCATION_LOC2)
73 #define _ACMP_ROUTE_LOCATION_MAX _ACMP_ROUTE_LOCATION_LOC2
74 #elif defined(_ACMP_ROUTE_LOCATION_LOC1)
75 #define _ACMP_ROUTE_LOCATION_MAX _ACMP_ROUTE_LOCATION_LOC1
76 #elif defined(_ACMP_ROUTELOC0_OUTLOC_LOC31)
77 #define _ACMP_ROUTE_LOCATION_MAX _ACMP_ROUTELOC0_OUTLOC_LOC31
79 #error Undefined max route locations
112 EFM_ASSERT(ACMP_REF_VALID(acmp));
115 #if defined(_ACMP_INPUTSEL_VDDLEVEL_MASK)
118 EFM_ASSERT(init->vddLevelLow < 64);
119 EFM_ASSERT(init->vddLevelHigh < 64);
132 #if defined(_ACMP_CTRL_WARMTIME_MASK)
138 #
if defined(_ACMP_CTRL_ACCURACY_MASK)
139 | ACMP_CTRL_ACCURACY_HIGH
143 #if defined(_ACMP_HYSTERESIS0_MASK)
144 acmp->HYSTERESIS0 = (init->vddLevelHigh << _ACMP_HYSTERESIS0_DIVVA_SHIFT)
145 | (init->hysteresisLevel_0 << _ACMP_HYSTERESIS0_HYST_SHIFT);
146 acmp->HYSTERESIS1 = (init->vddLevelLow << _ACMP_HYSTERESIS1_DIVVA_SHIFT)
147 | (init->hysteresisLevel_1 << _ACMP_HYSTERESIS1_HYST_SHIFT);
162 | ACMP_INPUTSEL_VASEL_VDD
163 | ACMP_INPUTSEL_NEGSEL_VADIV
188 EFM_ASSERT(ACMP_REF_VALID(acmp));
190 #if defined(_ACMP_INPUTSEL_POSSEL_CH7)
193 #elif defined(_ACMP_INPUTSEL_POSSEL_BUS4XCH31)
195 EFM_ASSERT(channel <= _ACMP_INPUTSEL_POSSEL_BUS4XCH31);
213 EFM_ASSERT(ACMP_REF_VALID(acmp));
228 EFM_ASSERT(ACMP_REF_VALID(acmp));
233 #if defined(_ACMP_EXTIFCTRL_MASK)
250 void ACMP_ExternalInputSelect(
ACMP_TypeDef *acmp, ACMP_ExternalInput_Typedef aport)
252 acmp->EXTIFCTRL = (aport << _ACMP_EXTIFCTRL_APORTSEL_SHIFT)
254 while (!(acmp->
STATUS & ACMP_STATUS_EXTIFACT))
273 EFM_ASSERT(ACMP_REF_VALID(acmp));
277 #if defined(_ACMP_HYSTERESIS0_HYST_MASK)
278 acmp->HYSTERESIS0 = _ACMP_HYSTERESIS0_RESETVALUE;
279 acmp->HYSTERESIS1 = _ACMP_HYSTERESIS1_RESETVALUE;
308 EFM_ASSERT(ACMP_REF_VALID(acmp));
311 EFM_ASSERT(location <= _ACMP_ROUTE_LOCATION_MAX);
317 #if defined(_ACMP_ROUTE_MASK)
321 #if defined(_ACMP_ROUTELOC0_MASK)
322 acmp->ROUTELOC0 = location << _ACMP_ROUTELOC0_OUTLOC_SHIFT;
323 acmp->ROUTEPEN = enable ? ACMP_ROUTEPEN_OUTPEN : 0;
344 EFM_ASSERT(ACMP_REF_VALID(acmp));
347 #if defined(_ACMP_INPUTSEL_NEGSEL_DAC0CH1)
348 EFM_ASSERT(negSel <= _ACMP_INPUTSEL_NEGSEL_DAC0CH1);
349 #elif defined(_ACMP_INPUTSEL_NEGSEL_CAPSENSE)
353 #if defined(_ACMP_INPUTSEL_POSSEL_CH7)
377 EFM_ASSERT(ACMP_REF_VALID(acmp));
395 #if defined(_ACMP_CTRL_INPUTRANGE_MASK)
396 | (init->inputRange << _ACMP_CTRL_INPUTRANGE_SHIFT)
398 #
if defined(_ACMP_CTRL_ACCURACY_MASK)
399 | (init->accuracy << _ACMP_CTRL_ACCURACY_SHIFT)
401 #
if defined(_ACMP_CTRL_PWRSEL_MASK)
402 | (init->powerSource << _ACMP_CTRL_PWRSEL_SHIFT)
413 #
if defined(_ACMP_INPUTSEL_VLPSEL_MASK)
414 | (init->vlpInput << _ACMP_INPUTSEL_VLPSEL_SHIFT)
428 #if defined(_ACMP_INPUTSEL_VASEL_MASK)
440 void ACMP_VASetup(
ACMP_TypeDef *acmp,
const ACMP_VAConfig_TypeDef *vaconfig)
442 EFM_ASSERT(vaconfig->div0 < 64);
443 EFM_ASSERT(vaconfig->div1 < 64);
446 vaconfig->input << _ACMP_INPUTSEL_VASEL_SHIFT);
448 vaconfig->div0 << _ACMP_HYSTERESIS0_DIVVA_SHIFT);
450 vaconfig->div1 << _ACMP_HYSTERESIS1_DIVVA_SHIFT);
454 #if defined(_ACMP_INPUTSEL_VBSEL_MASK)
466 void ACMP_VBSetup(
ACMP_TypeDef *acmp,
const ACMP_VBConfig_TypeDef *vbconfig)
468 EFM_ASSERT(vbconfig->div0 < 64);
469 EFM_ASSERT(vbconfig->div1 < 64);
472 vbconfig->input << _ACMP_INPUTSEL_VBSEL_SHIFT);
474 vbconfig->div0 << _ACMP_HYSTERESIS0_DIVVB_SHIFT);
476 vbconfig->div1 << _ACMP_HYSTERESIS1_DIVVB_SHIFT);
ACMP_CapsenseResistor_TypeDef resistor
#define _ACMP_CTRL_IRISE_SHIFT
void ACMP_Disable(ACMP_TypeDef *acmp)
Disables the ACMP.
ACMP_HysteresisLevel_TypeDef hysteresisLevel
#define _ACMP_CTRL_GPIOINV_MASK
Emlib peripheral API "assert" implementation.
RAM and peripheral bit-field set and clear API.
#define _ACMP_CTRL_BIASPROG_SHIFT
#define _ACMP_INPUTSEL_RESETVALUE
void ACMP_CapsenseChannelSet(ACMP_TypeDef *acmp, ACMP_Channel_TypeDef channel)
Sets the ACMP channel used for capacative sensing.
bool interruptOnRisingEdge
#define ACMP_INPUTSEL_NEGSEL_CAPSENSE
#define _ACMP_CTRL_HYSTSEL_SHIFT
#define _ACMP_CTRL_RESETVALUE
#define _ACMP_CTRL_INACTVAL_SHIFT
#define _ACMP_CTRL_EN_SHIFT
void ACMP_Enable(ACMP_TypeDef *acmp)
Enables the ACMP.
#define _ACMP_CTRL_HALFBIAS_MASK
#define _ACMP_INPUTSEL_VDDLEVEL_MASK
#define _ACMP_INPUTSEL_POSSEL_CH7
#define _ACMP_INPUTSEL_VDDLEVEL_SHIFT
bool lowPowerReferenceEnabled
#define _ACMP_ROUTE_ACMPPEN_SHIFT
bool lowPowerReferenceEnabled
ACMP_WarmTime_TypeDef warmTime
void ACMP_ChannelSet(ACMP_TypeDef *acmp, ACMP_Channel_TypeDef negSel, ACMP_Channel_TypeDef posSel)
Sets which channels should be used in ACMP comparisons.
#define _ACMP_IEN_RESETVALUE
void ACMP_CapsenseInit(ACMP_TypeDef *acmp, const ACMP_CapsenseInit_TypeDef *init)
Sets up the ACMP for use in capacative sense applications.
void ACMP_Reset(ACMP_TypeDef *acmp)
Reset ACMP to same state as after a HW reset.
ACMP_WarmTime_TypeDef warmTime
#define _ACMP_CTRL_FULLBIAS_SHIFT
#define _ACMP_CTRL_IFALL_SHIFT
#define _ACMP_INPUTSEL_LPREF_MASK
#define _ACMP_CTRL_HALFBIAS_SHIFT
#define _ACMP_CTRL_WARMTIME_MASK
#define _ACMP_INPUTSEL_LPREF_SHIFT
Analog Comparator (ACMP) peripheral API.
#define _ACMP_INPUTSEL_POSSEL_SHIFT
#define _ACMP_INPUTSEL_NEGSEL_SHIFT
__STATIC_INLINE void BUS_RegMaskedWrite(volatile uint32_t *addr, uint32_t mask, uint32_t val)
Perform peripheral register masked clear and value write.
bool interruptOnFallingEdge
#define _ACMP_ROUTE_LOCATION_SHIFT
#define _ACMP_CTRL_WARMTIME_SHIFT
__STATIC_INLINE void BUS_RegBitWrite(volatile uint32_t *addr, unsigned int bit, unsigned int val)
Perform a single-bit write operation on a peripheral register.
#define _ACMP_CTRL_BIASPROG_MASK
void ACMP_Init(ACMP_TypeDef *acmp, const ACMP_Init_TypeDef *init)
Initialize ACMP.
#define _ACMP_INPUTSEL_NEGSEL_CAPSENSE
#define _ACMP_CTRL_GPIOINV_SHIFT
void ACMP_GPIOSetup(ACMP_TypeDef *acmp, uint32_t location, bool enable, bool invert)
Sets up GPIO output from the ACMP.
#define ACMP_INPUTSEL_CSRESEN
#define _ACMP_INPUTSEL_CSRESSEL_SHIFT
#define _ACMP_INPUTSEL_NEGSEL_MASK
#define _ACMP_INPUTSEL_POSSEL_MASK
ACMP_HysteresisLevel_TypeDef hysteresisLevel
#define _ACMP_CTRL_HYSTSEL_MASK