ACMP - Analog Comparator
Description
Analog comparator (ACMP) Peripheral API.
The Analog Comparator is used to compare voltage of two analog inputs with a digital output indicating which input voltage is higher. Inputs can either be one of the selectable internal references or from external pins. Response time and current consumption can be configured by altering the current supply to the comparator.
ACMP is available down to EM3 and is able to wake up the system when input signals pass a certain threshold. Use ACMP_IntEnable() to enable an edge interrupt to use this functionality.
This example shows how to use the em_acmp.h API for comparing an input pin to an internal 2.5 V reference voltage.
- Note
- ACMP can also be used to compare two separate input pins.
ACMP also contains specialized hardware for capacitive sensing. This module contains the ACMP_CapsenseInit() function to initialize ACMP for capacitive sensing and the ACMP_CapsenseChannelSet() function to select the current capsense channel.
For applications that require capacitive sensing it is recommended to use a library, such as cslib, which is provided by Silicon Labs.
Data Structures |
|
struct | ACMP_CapsenseInit_TypeDef |
Capsense initialization structure.
|
|
struct | ACMP_Init_TypeDef |
ACMP initialization structure.
|
|
Functions |
|
void | ACMP_CapsenseInit (ACMP_TypeDef *acmp, const ACMP_CapsenseInit_TypeDef *init) |
Set up ACMP for use in capacitive sense applications.
|
|
void | ACMP_CapsenseChannelSet (ACMP_TypeDef *acmp, ACMP_Channel_TypeDef channel) |
Set the ACMP channel used for capacitive sensing.
|
|
void | ACMP_ChannelSet (ACMP_TypeDef *acmp, ACMP_Channel_TypeDef negSel, ACMP_Channel_TypeDef posSel) |
Set which channels should be used in ACMP comparisons.
|
|
void | ACMP_Disable (ACMP_TypeDef *acmp) |
Disable ACMP.
|
|
void | ACMP_Enable (ACMP_TypeDef *acmp) |
Enable ACMP.
|
|
void | ACMP_GPIOSetup (ACMP_TypeDef *acmp, GPIO_Port_TypeDef port, unsigned int pin, bool enable, bool invert) |
Sets up GPIO output from the ACMP.
|
|
void | ACMP_Init (ACMP_TypeDef *acmp, const ACMP_Init_TypeDef *init) |
Initialize ACMP.
|
|
void | ACMP_Reset (ACMP_TypeDef *acmp) |
Reset ACMP to the same state that it was in after a hardware reset.
|
|
void | ACMP_IntClear (ACMP_TypeDef *acmp, uint32_t flags) |
Clear one or more pending ACMP interrupts.
|
|
void | ACMP_IntDisable (ACMP_TypeDef *acmp, uint32_t flags) |
Disable one or more ACMP interrupts.
|
|
void | ACMP_IntEnable (ACMP_TypeDef *acmp, uint32_t flags) |
Enable one or more ACMP interrupts.
|
|
uint32_t | ACMP_IntGet (ACMP_TypeDef *acmp) |
Get pending ACMP interrupt flags.
|
|
uint32_t | ACMP_IntGetEnabled (ACMP_TypeDef *acmp) |
Get enabled and pending ACMP interrupt flags.
|
|
void | ACMP_IntSet (ACMP_TypeDef *acmp, uint32_t flags) |
Set one or more pending ACMP interrupts from software.
|
|
ACMP_Channel_TypeDef | ACMP_PortPinToInput ( GPIO_Port_TypeDef port, uint8_t pin) |
Convert GPIO port/pin to ACMP input selection.
|
|
Macros |
|
#define | ACMP_CAPSENSE_INIT_DEFAULT |
A default configuration for capacitive sense mode initialization.
|
|
#define | ACMP_INIT_DEFAULT |
Default configuration for ACMP regular initialization.
|
|
Enumerations |
|
enum |
ACMP_CapsenseResistor_TypeDef
{
acmpResistor0 = _ACMP_INPUTCTRL_CSRESSEL_RES0, acmpResistor1 = _ACMP_INPUTCTRL_CSRESSEL_RES1, acmpResistor2 = _ACMP_INPUTCTRL_CSRESSEL_RES2, acmpResistor3 = _ACMP_INPUTCTRL_CSRESSEL_RES3, acmpResistor4 = _ACMP_INPUTCTRL_CSRESSEL_RES4, acmpResistor5 = _ACMP_INPUTCTRL_CSRESSEL_RES5, acmpResistor6 = _ACMP_INPUTCTRL_CSRESSEL_RES6 } |
Resistor values used for the internal capacative sense resistor.
|
|
enum |
ACMP_HysteresisLevel_TypeDef
{
acmpHysteresisDisabled = _ACMP_CFG_HYST_DISABLED, acmpHysteresis10Sym = _ACMP_CFG_HYST_SYM10MV, acmpHysteresis20Sym = _ACMP_CFG_HYST_SYM20MV, acmpHysteresis30Sym = _ACMP_CFG_HYST_SYM30MV, acmpHysteresis10Pos = _ACMP_CFG_HYST_POS10MV, acmpHysteresis20Pos = _ACMP_CFG_HYST_POS20MV, acmpHysteresis30Pos = _ACMP_CFG_HYST_POS30MV, acmpHysteresis10Neg = _ACMP_CFG_HYST_NEG10MV, acmpHysteresis20Neg = _ACMP_CFG_HYST_NEG20MV, acmpHysteresis30Neg = _ACMP_CFG_HYST_NEG30MV } |
Hysteresis level.
|
|
enum |
ACMP_InputRange_TypeDef
{
acmpInputRangeFull = _ACMP_CFG_INPUTRANGE_FULL, acmpInputRangeReduced = _ACMP_CFG_INPUTRANGE_REDUCED } |
Adjust ACMP performance for a given input voltage range.
|
|
enum |
ACMP_Accuracy_TypeDef
{
acmpAccuracyLow = _ACMP_CFG_ACCURACY_LOW, acmpAccuracyHigh = _ACMP_CFG_ACCURACY_HIGH } |
ACMP accuracy mode.
|
|
enum |
ACMP_Channel_TypeDef
{
acmpInputVSS = _ACMP_INPUTCTRL_POSSEL_VSS, acmpInputVREFDIVAVDD = _ACMP_INPUTCTRL_POSSEL_VREFDIVAVDD, acmpInputVREFDIVAVDDLP = _ACMP_INPUTCTRL_POSSEL_VREFDIVAVDDLP, acmpInputVREFDIV1V25 = _ACMP_INPUTCTRL_POSSEL_VREFDIV1V25, acmpInputVREFDIV1V25LP = _ACMP_INPUTCTRL_POSSEL_VREFDIV1V25LP, acmpInputVREFDIV2V5 = _ACMP_INPUTCTRL_POSSEL_VREFDIV2V5, acmpInputVREFDIV2V5LP = _ACMP_INPUTCTRL_POSSEL_VREFDIV2V5LP, acmpInputVSENSE01DIV4 = _ACMP_INPUTCTRL_POSSEL_VSENSE01DIV4, acmpInputVSENSE01DIV4LP = _ACMP_INPUTCTRL_POSSEL_VSENSE01DIV4LP, acmpInputVSENSE11DIV4 = _ACMP_INPUTCTRL_POSSEL_VSENSE11DIV4, acmpInputVSENSE11DIV4LP = _ACMP_INPUTCTRL_POSSEL_VSENSE11DIV4LP, acmpInputCAPSENSE = _ACMP_INPUTCTRL_NEGSEL_CAPSENSE, acmpInputPA0 = _ACMP_INPUTCTRL_POSSEL_PA0, acmpInputPA1 = _ACMP_INPUTCTRL_POSSEL_PA1, acmpInputPA2 = _ACMP_INPUTCTRL_POSSEL_PA2, acmpInputPA3 = _ACMP_INPUTCTRL_POSSEL_PA3, |