ACMP
[EM_Library]

Analog comparator (ACMP) Peripheral API. More...

Collaboration diagram for ACMP:

Data Structures

struct  ACMP_CapsenseInit_TypeDef
struct  ACMP_Init_TypeDef

Defines

#define ACMP_CAPSENSE_INIT_DEFAULT
#define ACMP_INIT_DEFAULT

Enumerations

enum  ACMP_CapsenseResistor_TypeDef {
  acmpResistor0 = _ACMP_INPUTSEL_CSRESSEL_RES0,
  acmpResistor1 = _ACMP_INPUTSEL_CSRESSEL_RES1,
  acmpResistor2 = _ACMP_INPUTSEL_CSRESSEL_RES2,
  acmpResistor3 = _ACMP_INPUTSEL_CSRESSEL_RES3
}
enum  ACMP_HysteresisLevel_TypeDef {
  acmpHysteresisLevel0 = _ACMP_CTRL_HYSTSEL_HYST0,
  acmpHysteresisLevel1 = _ACMP_CTRL_HYSTSEL_HYST1,
  acmpHysteresisLevel2 = _ACMP_CTRL_HYSTSEL_HYST2,
  acmpHysteresisLevel3 = _ACMP_CTRL_HYSTSEL_HYST3,
  acmpHysteresisLevel4 = _ACMP_CTRL_HYSTSEL_HYST4,
  acmpHysteresisLevel5 = _ACMP_CTRL_HYSTSEL_HYST5,
  acmpHysteresisLevel6 = _ACMP_CTRL_HYSTSEL_HYST6,
  acmpHysteresisLevel7 = _ACMP_CTRL_HYSTSEL_HYST7
}
enum  ACMP_WarmTime_TypeDef {
  acmpWarmTime4 = _ACMP_CTRL_WARMTIME_4CYCLES,
  acmpWarmTime8 = _ACMP_CTRL_WARMTIME_8CYCLES,
  acmpWarmTime16 = _ACMP_CTRL_WARMTIME_16CYCLES,
  acmpWarmTime32 = _ACMP_CTRL_WARMTIME_32CYCLES,
  acmpWarmTime64 = _ACMP_CTRL_WARMTIME_64CYCLES,
  acmpWarmTime128 = _ACMP_CTRL_WARMTIME_128CYCLES,
  acmpWarmTime256 = _ACMP_CTRL_WARMTIME_256CYCLES,
  acmpWarmTime512 = _ACMP_CTRL_WARMTIME_512CYCLES
}
enum  ACMP_Channel_TypeDef {
  acmpChannel0 = _ACMP_INPUTSEL_NEGSEL_CH0,
  acmpChannel1 = _ACMP_INPUTSEL_NEGSEL_CH1,
  acmpChannel2 = _ACMP_INPUTSEL_NEGSEL_CH2,
  acmpChannel3 = _ACMP_INPUTSEL_NEGSEL_CH3,
  acmpChannel4 = _ACMP_INPUTSEL_NEGSEL_CH4,
  acmpChannel5 = _ACMP_INPUTSEL_NEGSEL_CH5,
  acmpChannel6 = _ACMP_INPUTSEL_NEGSEL_CH6,
  acmpChannel7 = _ACMP_INPUTSEL_NEGSEL_CH7,
  acmpChannel1V25 = _ACMP_INPUTSEL_NEGSEL_1V25,
  acmpChannel2V5 = _ACMP_INPUTSEL_NEGSEL_2V5,
  acmpChannelVDD = _ACMP_INPUTSEL_NEGSEL_VDD
}

Functions

void ACMP_CapsenseInit (ACMP_TypeDef *acmp, const ACMP_CapsenseInit_TypeDef *init)
 Sets up the ACMP for use in capacative sense applications.
void ACMP_CapsenseChannelSet (ACMP_TypeDef *acmp, ACMP_Channel_TypeDef channel)
 Sets the ACMP channel used for capacative sensing.
void ACMP_ChannelSet (ACMP_TypeDef *acmp, ACMP_Channel_TypeDef negSel, ACMP_Channel_TypeDef posSel)
 Sets which channels should be used in ACMP comparisons.
void ACMP_Disable (ACMP_TypeDef *acmp)
 Disables the ACMP.
void ACMP_Enable (ACMP_TypeDef *acmp)
 Enables the ACMP.
void ACMP_GPIOSetup (ACMP_TypeDef *acmp, uint32_t location, bool enable, bool invert)
 Sets up GPIO output from the ACMP.
void ACMP_Init (ACMP_TypeDef *acmp, const ACMP_Init_TypeDef *init)
void ACMP_Reset (ACMP_TypeDef *acmp)
 Reset ACMP to same state as after a HW reset.
__STATIC_INLINE void ACMP_IntClear (ACMP_TypeDef *acmp, uint32_t flags)
 Clear one or more pending ACMP interrupts.
__STATIC_INLINE void ACMP_IntDisable (ACMP_TypeDef *acmp, uint32_t flags)
 Disable one or more ACMP interrupts.
__STATIC_INLINE void ACMP_IntEnable (ACMP_TypeDef *acmp, uint32_t flags)
 Enable one or more ACMP interrupts.
__STATIC_INLINE uint32_t ACMP_IntGet (ACMP_TypeDef *acmp)
 Get pending ACMP interrupt flags.
__STATIC_INLINE uint32_t ACMP_IntGetEnabled (ACMP_TypeDef *acmp)
 Get enabled and pending ACMP interrupt flags. Useful for handling more interrupt sources in the same interrupt handler.
__STATIC_INLINE void ACMP_IntSet (ACMP_TypeDef *acmp, uint32_t flags)
 Set one or more pending ACMP interrupts from SW.

Detailed Description

Analog comparator (ACMP) Peripheral API.


Define Documentation

#define ACMP_CAPSENSE_INIT_DEFAULT
Value:
{ false,              /* fullBias */                    \
    false,              /* halfBias */                    \
    0x7,                /* biasProg */                    \
    acmpWarmTime512,    /* 512 cycle warmup to be safe */ \
    acmpHysteresisLevel5,                                 \
    acmpResistor3,                                        \
    false,              /* low power reference */         \
    0x3D,               /* VDD level */                   \
    true                /* Enable after init. */          \
  }

Default config for capacitive sense mode initialization.

Definition at line 197 of file em_acmp.h.

#define ACMP_INIT_DEFAULT
Value:
{ false,              /* fullBias */                                        \
    false,              /* halfBias */                                        \
    0x7,                /* biasProg */                                        \
    false,              /* No interrupt on falling edge. */                   \
    false,              /* No interrupt on rising edge. */                    \
    acmpWarmTime512,    /* 512 cycle warmup to be safe */                     \
    acmpHysteresisLevel5,                                                     \
    false,              /* Disabled emitting inactive value during warmup. */ \
    false,              /* low power reference */                             \
    0x3D,               /* VDD level */                                       \
    true                /* Enable after init. */                              \
  }

Default config for ACMP regular initialization.

Definition at line 253 of file em_acmp.h.


Enumeration Type Documentation

Resistor values used for capacative sense. See the datasheet for your device for details on each resistor value.

Enumerator:
acmpResistor0 

resistor value 0

acmpResistor1 

resistor value 1

acmpResistor2 

resistor value 2

acmpResistor3 

resistor value 3

Definition at line 63 of file em_acmp.h.

ACMP inputs. Note that scaled VDD and bandgap references can only be used as negative inputs.

Enumerator:
acmpChannel0 

Channel 0

acmpChannel1 

Channel 1

acmpChannel2 

Channel 2

acmpChannel3 

Channel 3

acmpChannel4 

Channel 4

acmpChannel5 

Channel 5

acmpChannel6 

Channel 6

acmpChannel7 

Channel 7

acmpChannel1V25 

1.25V internal reference

acmpChannel2V5 

2.5V internal reference

acmpChannelVDD 

Scaled VDD reference

Definition at line 113 of file em_acmp.h.

Hysteresis level. See datasheet for your device for details on each level.

Enumerator:
acmpHysteresisLevel0 

Hysteresis level 0

acmpHysteresisLevel1 

Hysteresis level 1

acmpHysteresisLevel2 

Hysteresis level 2

acmpHysteresisLevel3 

Hysteresis level 3

acmpHysteresisLevel4 

Hysteresis level 4

acmpHysteresisLevel5 

Hysteresis level 5

acmpHysteresisLevel6 

Hysteresis level 6

acmpHysteresisLevel7 

Hysteresis level 7

Definition at line 77 of file em_acmp.h.

ACMP warmup time. The delay is measured in HFPERCLK cycles and should be at least 10 us.

Enumerator:
acmpWarmTime4 

4 HFPERCLK cycles warmup

acmpWarmTime8 

8 HFPERCLK cycles warmup

acmpWarmTime16 

16 HFPERCLK cycles warmup

acmpWarmTime32 

32 HFPERCLK cycles warmup

acmpWarmTime64 

64 HFPERCLK cycles warmup

acmpWarmTime128 

128 HFPERCLK cycles warmup

acmpWarmTime256 

256 HFPERCLK cycles warmup

acmpWarmTime512 

512 HFPERCLK cycles warmup

Definition at line 91 of file em_acmp.h.


Function Documentation

void ACMP_CapsenseChannelSet ( ACMP_TypeDef *  acmp,
ACMP_Channel_TypeDef  channel 
)

Sets the ACMP channel used for capacative sensing.

Note:
A basic example of capacative sensing can be found in the STK BSP (capsense demo).
Parameters:
[in] acmp Pointer to ACMP peripheral register block.
[in] channel The ACMP channel to use for capacative sensing (Possel).

Definition at line 143 of file em_acmp.c.

void ACMP_CapsenseInit ( ACMP_TypeDef *  acmp,
const ACMP_CapsenseInit_TypeDef init 
)

Sets up the ACMP for use in capacative sense applications.

This function sets up the ACMP for use in capacacitve sense applications. To use the capacative sense functionality in the ACMP you need to use the PRS output of the ACMP module to count the number of oscillations in the capacative sense circuit (possibly using a TIMER).

Note:
A basic example of capacative sensing can be found in the STK BSP (capsense demo).
Parameters:
[in] acmp Pointer to ACMP peripheral register block.
[in] init Pointer to initialization structure used to configure ACMP for capacative sensing operation.

Definition at line 96 of file em_acmp.c.

References ACMP_CapsenseInit_TypeDef::biasProg, BITBAND_Peripheral(), ACMP_CapsenseInit_TypeDef::enable, ACMP_CapsenseInit_TypeDef::fullBias, ACMP_CapsenseInit_TypeDef::halfBias, ACMP_CapsenseInit_TypeDef::hysteresisLevel, ACMP_CapsenseInit_TypeDef::lowPowerReferenceEnabled, ACMP_CapsenseInit_TypeDef::resistor, ACMP_CapsenseInit_TypeDef::vddLevel, and ACMP_CapsenseInit_TypeDef::warmTime.

Here is the call graph for this function:

void ACMP_ChannelSet ( ACMP_TypeDef *  acmp,
ACMP_Channel_TypeDef  negSel,
ACMP_Channel_TypeDef  posSel 
)

Sets which channels should be used in ACMP comparisons.

Parameters:
[in] acmp Pointer to the ACMP peripheral register block.
negSel Channel to use on the negative input to the ACMP.
posSel Channel to use on the positive input to the ACMP.

Definition at line 257 of file em_acmp.c.

void ACMP_Disable ( ACMP_TypeDef *  acmp  ) 

Disables the ACMP.

Parameters:
[in] acmp Pointer to ACMP peripheral register block.

Definition at line 160 of file em_acmp.c.

void ACMP_Enable ( ACMP_TypeDef *  acmp  ) 

Enables the ACMP.

Parameters:
[in] acmp Pointer to ACMP peripheral register block.

Definition at line 172 of file em_acmp.c.

void ACMP_GPIOSetup ( ACMP_TypeDef *  acmp,
uint32_t  location,
bool  enable,
bool  invert 
)

Sets up GPIO output from the ACMP.

Note:
GPIO must be enabled in the CMU before this function call, i.e.
CMU_ClockEnable(cmuClock_GPIO, true); 
Parameters:
[in] acmp Pointer to the ACMP peripheral register block.
location The pin location to use. See the datasheet for location to pin mappings.
enable Enable or disable pin output.
invert Invert output.

Definition at line 219 of file em_acmp.c.

void ACMP_Init ( ACMP_TypeDef *  acmp,
const ACMP_Init_TypeDef init 
)
Parameters:
[in] acmp Pointer to the ACMP peripheral register block.
[in] init Pointer to initialization structure used to configure ACMP for capacative sensing operation.

Definition at line 290 of file em_acmp.c.

References ACMP_Init_TypeDef::biasProg, BITBAND_Peripheral(), ACMP_Init_TypeDef::enable, ACMP_Init_TypeDef::fullBias, ACMP_Init_TypeDef::halfBias, ACMP_Init_TypeDef::hysteresisLevel, ACMP_Init_TypeDef::inactiveValue, ACMP_Init_TypeDef::interruptOnFallingEdge, ACMP_Init_TypeDef::interruptOnRisingEdge, ACMP_Init_TypeDef::lowPowerReferenceEnabled, ACMP_Init_TypeDef::vddLevel, and ACMP_Init_TypeDef::warmTime.

Here is the call graph for this function:

__STATIC_INLINE void ACMP_IntClear ( ACMP_TypeDef *  acmp,
uint32_t  flags 
)

Clear one or more pending ACMP interrupts.

Parameters:
[in] acmp Pointer to ACMP peripheral register block.
[in] flags Pending ACMP interrupt source to clear. Use a bitwise logic OR combination of valid interrupt flags for the ACMP module (ACMP_IF_nnn).

Definition at line 292 of file em_acmp.h.

__STATIC_INLINE void ACMP_IntDisable ( ACMP_TypeDef *  acmp,
uint32_t  flags 
)

Disable one or more ACMP interrupts.

Parameters:
[in] acmp Pointer to ACMP peripheral register block.
[in] flags ACMP interrupt sources to disable. Use a bitwise logic OR combination of valid interrupt flags for the ACMP module (ACMP_IF_nnn).

Definition at line 309 of file em_acmp.h.

__STATIC_INLINE void ACMP_IntEnable ( ACMP_TypeDef *  acmp,
uint32_t  flags 
)

Enable one or more ACMP interrupts.

Note:
Depending on the use, a pending interrupt may already be set prior to enabling the interrupt. Consider using ACMP_IntClear() prior to enabling if such a pending interrupt should be ignored.
Parameters:
[in] acmp Pointer to ACMP peripheral register block.
[in] flags ACMP interrupt sources to enable. Use a bitwise logic OR combination of valid interrupt flags for the ACMP module (ACMP_IF_nnn).

Definition at line 331 of file em_acmp.h.

__STATIC_INLINE uint32_t ACMP_IntGet ( ACMP_TypeDef *  acmp  ) 

Get pending ACMP interrupt flags.

Note:
The event bits are not cleared by the use of this function.
Parameters:
[in] acmp Pointer to ACMP peripheral register block.
Returns:
ACMP interrupt sources pending. A bitwise logic OR combination of valid interrupt flags for the ACMP module (ACMP_IF_nnn).

Definition at line 351 of file em_acmp.h.

__STATIC_INLINE uint32_t ACMP_IntGetEnabled ( ACMP_TypeDef *  acmp  ) 

Get enabled and pending ACMP interrupt flags. Useful for handling more interrupt sources in the same interrupt handler.

Parameters:
[in] acmp Pointer to ACMP peripheral register block.
Note:
Interrupt flags are not cleared by the use of this function.
Returns:
Pending and enabled ACMP interrupt sources. The return value is the bitwise AND combination of
  • the OR combination of enabled interrupt sources in ACMPx_IEN_nnn register (ACMPx_IEN_nnn) and
  • the OR combination of valid interrupt flags of the ACMP module (ACMPx_IF_nnn).

Definition at line 376 of file em_acmp.h.

__STATIC_INLINE void ACMP_IntSet ( ACMP_TypeDef *  acmp,
uint32_t  flags 
)

Set one or more pending ACMP interrupts from SW.

Parameters:
[in] acmp Pointer to ACMP peripheral register block.
[in] flags ACMP interrupt sources to set to pending. Use a bitwise logic OR combination of valid interrupt flags for the ACMP module (ACMP_IF_nnn).

Definition at line 400 of file em_acmp.h.

void ACMP_Reset ( ACMP_TypeDef *  acmp  ) 

Reset ACMP to same state as after a HW reset.

Note:
The ROUTE register is NOT reset by this function, in order to allow for centralized setup of this feature.
Parameters:
[in] acmp Pointer to the ACMP peripheral register block.

Definition at line 188 of file em_acmp.c.