LESENSE

Detailed Description

Low Energy Sensor (LESENSE) Peripheral API.

This module contains functions to control the LESENSE peripheral of Silicon Labs 32-bit MCUs and SoCs. LESENSE is a low-energy sensor interface capable of autonomously collecting and processing data from multiple sensors even when in EM2.

Data Structures

struct LESENSE_AltExDesc_TypeDef
struct LESENSE_ChAll_TypeDef
struct LESENSE_ChDesc_TypeDef
struct LESENSE_ConfAltEx_TypeDef
struct LESENSE_CoreCtrlDesc_TypeDef
struct LESENSE_DecCtrlDesc_TypeDef
struct LESENSE_DecStAll_TypeDef
struct LESENSE_DecStCond_TypeDef
struct LESENSE_DecStDesc_TypeDef
struct LESENSE_Init_TypeDef
struct LESENSE_PerCtrlDesc_TypeDef
struct LESENSE_TimeCtrlDesc_TypeDef

Macros

#define LESENSE_ALTEX_CH_CONF_DEFAULT
#define LESENSE_ALTEX_CONF_DEFAULT
#define LESENSE_CH_CONF_DEFAULT
#define LESENSE_CORECTRL_DESC_DEFAULT
#define LESENSE_DECCTRL_DESC_DEFAULT
#define LESENSE_DECODER_CONF_DEFAULT
#define LESENSE_INIT_DEFAULT
#define LESENSE_NUM_CHANNELS 16
#define LESENSE_NUM_DECODER_STATES (_LESENSE_DECSTATE_DECSTATE_MASK + 1)
#define LESENSE_PERCTRL_DESC_DEFAULT
#define LESENSE_SCAN_CONF_DEFAULT
#define LESENSE_ST_CONF_DEFAULT
#define LESENSE_TIMECTRL_DESC_DEFAULT

Enumerations

enum LESENSE_AltExMap_TypeDef {
lesenseAltExMapALTEX = _LESENSE_CTRL_ALTEXMAP_ALTEX,
lesenseAltExMapACMP = _LESENSE_CTRL_ALTEXMAP_ACMP
}
enum LESENSE_AltExPinIdle_TypeDef {
lesenseAltExPinIdleDis = _LESENSE_ALTEXCONF_IDLECONF0_DISABLE,
lesenseAltExPinIdleHigh = _LESENSE_ALTEXCONF_IDLECONF0_HIGH,
lesenseAltExPinIdleLow = _LESENSE_ALTEXCONF_IDLECONF0_LOW
}
enum LESENSE_BiasMode_TypeDef {
lesenseBiasModeDutyCycle = LESENSE_BIASCTRL_BIASMODE_DUTYCYCLE,
lesenseBiasModeHighAcc = LESENSE_BIASCTRL_BIASMODE_HIGHACC,
lesenseBiasModeDontTouch = LESENSE_BIASCTRL_BIASMODE_DONTTOUCH
}
enum LESENSE_BufTrigLevel_TypeDef {
lesenseBufTrigHalf = LESENSE_CTRL_BUFIDL_HALFFULL,
lesenseBufTrigFull = LESENSE_CTRL_BUFIDL_FULL
}
enum LESENSE_ChClk_TypeDef {
lesenseClkLF = _LESENSE_CH_INTERACT_EXCLK_LFACLK,
lesenseClkHF = _LESENSE_CH_INTERACT_EXCLK_AUXHFRCO
}
enum LESENSE_ChCompMode_TypeDef {
lesenseCompModeLess = LESENSE_CH_EVAL_COMP_LESS,
lesenseCompModeGreaterOrEq = LESENSE_CH_EVAL_COMP_GE
}
enum LESENSE_ChIntMode_TypeDef {
lesenseSetIntNone = LESENSE_CH_INTERACT_SETIF_NONE,
lesenseSetIntLevel = LESENSE_CH_INTERACT_SETIF_LEVEL,
lesenseSetIntPosEdge = LESENSE_CH_INTERACT_SETIF_POSEDGE,
lesenseSetIntNegEdge = LESENSE_CH_INTERACT_SETIF_NEGEDGE
}
enum LESENSE_ChPinExMode_TypeDef {
lesenseChPinExDis = LESENSE_CH_INTERACT_EXMODE_DISABLE,
lesenseChPinExHigh = LESENSE_CH_INTERACT_EXMODE_HIGH,
lesenseChPinExLow = LESENSE_CH_INTERACT_EXMODE_LOW,
lesenseChPinExDACOut = LESENSE_CH_INTERACT_EXMODE_DACOUT
}
enum LESENSE_ChPinIdleMode_TypeDef {
lesenseChPinIdleDis = _LESENSE_IDLECONF_CH0_DISABLE,
lesenseChPinIdleHigh = _LESENSE_IDLECONF_CH0_HIGH,
lesenseChPinIdleLow = _LESENSE_IDLECONF_CH0_LOW,
lesenseChPinIdleDACCh0 = _LESENSE_IDLECONF_CH0_DACCH0,
lesenseChPinIdleDACCh1 = _LESENSE_IDLECONF_CH12_DACCH1
}
enum LESENSE_ChSampleMode_TypeDef {
lesenseSampleModeCounter = 0x0 << _LESENSE_CH_INTERACT_SAMPLE_SHIFT,
lesenseSampleModeACMP = LESENSE_CH_INTERACT_SAMPLE_ACMP
}
enum LESENSE_ClkPresc_TypeDef {
lesenseClkDiv_1 = 0,
lesenseClkDiv_2 = 1,
lesenseClkDiv_4 = 2,
lesenseClkDiv_8 = 3,
lesenseClkDiv_16 = 4,
lesenseClkDiv_32 = 5,
lesenseClkDiv_64 = 6,
lesenseClkDiv_128 = 7
}
enum LESENSE_ControlACMP_TypeDef {
lesenseACMPModeDisable = _LESENSE_PERCTRL_ACMP0MODE_DISABLE,
lesenseACMPModeMux = _LESENSE_PERCTRL_ACMP0MODE_MUX,
lesenseACMPModeMuxThres = _LESENSE_PERCTRL_ACMP0MODE_MUXTHRES
}
enum LESENSE_ControlDACConv_TypeDef {
lesenseDACConvModeDisable = _LESENSE_PERCTRL_DACCH0CONV_DISABLE,
lesenseDACConvModeContinuous = _LESENSE_PERCTRL_DACCH0CONV_CONTINUOUS,
lesenseDACConvModeSampleHold = _LESENSE_PERCTRL_DACCH0CONV_SAMPLEHOLD,
lesenseDACConvModeSampleOff = _LESENSE_PERCTRL_DACCH0CONV_SAMPLEOFF
}
enum LESENSE_ControlDACData_TypeDef {
lesenseDACIfData = _LESENSE_PERCTRL_DACCH0DATA_DACDATA,
lesenseACMPThres = _LESENSE_PERCTRL_DACCH0DATA_ACMPTHRES
}
enum LESENSE_ControlDACOut_TypeDef {
lesenseDACOutModeDisable = _LESENSE_PERCTRL_DACCH0OUT_DISABLE,
lesenseDACOutModePin = _LESENSE_PERCTRL_DACCH0OUT_PIN,
lesenseDACOutModeADCACMP = _LESENSE_PERCTRL_DACCH0OUT_ADCACMP,
lesenseDACOutModePinADCACMP = _LESENSE_PERCTRL_DACCH0OUT_PINADCACMP
}
enum LESENSE_DACRef_TypeDef {
lesenseDACRefVdd = LESENSE_PERCTRL_DACREF_VDD,
lesenseDACRefBandGap = LESENSE_PERCTRL_DACREF_BANDGAP
}
enum LESENSE_DecInput_TypeDef {
lesenseDecInputSensorSt = LESENSE_DECCTRL_INPUT_SENSORSTATE,
lesenseDecInputPRS = LESENSE_DECCTRL_INPUT_PRS
}
enum LESENSE_DMAWakeUp_TypeDef {
lesenseDMAWakeUpDisable = LESENSE_CTRL_DMAWU_DISABLE,
lesenseDMAWakeUpBufValid = LESENSE_CTRL_DMAWU_BUFDATAV,
lesenseDMAWakeUpBufLevel = LESENSE_CTRL_DMAWU_BUFLEVEL
}
enum LESENSE_PRSSel_TypeDef {
lesensePRSCh0 = 0,
lesensePRSCh1 = 1,
lesensePRSCh2 = 2,
lesensePRSCh3 = 3,
lesensePRSCh4 = 4,
lesensePRSCh5 = 5,
lesensePRSCh6 = 6,
lesensePRSCh7 = 7,
lesensePRSCh8 = 8,
lesensePRSCh9 = 9,
lesensePRSCh10 = 10,
lesensePRSCh11 = 11
}
enum LESENSE_ScanConfSel_TypeDef {
lesenseScanConfDirMap = LESENSE_CTRL_SCANCONF_DIRMAP,
lesenseScanConfInvMap = LESENSE_CTRL_SCANCONF_INVMAP,
lesenseScanConfToggle = LESENSE_CTRL_SCANCONF_TOGGLE,
lesenseScanConfDecDef = LESENSE_CTRL_SCANCONF_DECDEF
}
enum LESENSE_ScanMode_TypeDef {
lesenseScanStartPeriodic = LESENSE_CTRL_SCANMODE_PERIODIC,
lesenseScanStartOneShot = LESENSE_CTRL_SCANMODE_ONESHOT,
lesenseScanStartPRS = LESENSE_CTRL_SCANMODE_PRS
}
enum LESENSE_StTransAct_TypeDef {
lesenseTransActNone = LESENSE_ST_TCONFA_PRSACT_NONE,
lesenseTransActPRS0 = LESENSE_ST_TCONFA_PRSACT_PRS0,
lesenseTransActPRS1 = LESENSE_ST_TCONFA_PRSACT_PRS1,
lesenseTransActPRS01 = LESENSE_ST_TCONFA_PRSACT_PRS01,
lesenseTransActPRS2 = LESENSE_ST_TCONFA_PRSACT_PRS2,
lesenseTransActPRS02 = LESENSE_ST_TCONFA_PRSACT_PRS02,
lesenseTransActPRS12 = LESENSE_ST_TCONFA_PRSACT_PRS12,
lesenseTransActPRS012 = LESENSE_ST_TCONFA_PRSACT_PRS012,
lesenseTransActUp = LESENSE_ST_TCONFA_PRSACT_UP,
lesenseTransActDown = LESENSE_ST_TCONFA_PRSACT_DOWN,
lesenseTransActUpAndPRS2 = LESENSE_ST_TCONFA_PRSACT_UPANDPRS2,
lesenseTransActDownAndPRS2 = LESENSE_ST_TCONFA_PRSACT_DOWNANDPRS2
}
enum LESENSE_WarmupMode_TypeDef {
lesenseWarmupModeNormal = LESENSE_PERCTRL_WARMUPMODE_NORMAL,
lesenseWarmupModeACMP = LESENSE_PERCTRL_WARMUPMODE_KEEPACMPWARM,
lesenseWarmupModeDAC = LESENSE_PERCTRL_WARMUPMODE_KEEPDACWARM,
lesenseWarmupModeKeepWarm = LESENSE_PERCTRL_WARMUPMODE_KEEPACMPDACWARM
}

Functions

void LESENSE_AltExConfig (const LESENSE_ConfAltEx_TypeDef *confAltEx)
Configure the LESENSE alternate excitation modes.
__STATIC_INLINE uint32_t LESENSE_ChannelActiveGet (void)
Get the currently active channel index.
void LESENSE_ChannelAllConfig (const LESENSE_ChAll_TypeDef *confChAll)
Configure all (16) LESENSE sensor channels.
void LESENSE_ChannelConfig (const LESENSE_ChDesc_TypeDef *confCh, uint32_t chIdx)
Configure a single LESENSE sensor channel.
void LESENSE_ChannelEnable (uint8_t chIdx, bool enaScanCh, bool enaPin)
Enable/disable LESENSE scan channel and the pin assigned to it.
void LESENSE_ChannelEnableMask (uint16_t chMask, uint16_t pinMask)
Enable/disable LESENSE scan channel and the pin assigned to it.
void LESENSE_ChannelThresSet (uint8_t chIdx, uint16_t acmpThres, uint16_t cntThres)
Set LESENSE channel threshold parameters.
void LESENSE_ChannelTimingSet (uint8_t chIdx, uint8_t exTime, uint8_t sampleDelay, uint16_t measDelay)
Set LESENSE channel timing parameters.
void LESENSE_ClkDivSet ( LESENSE_ChClk_TypeDef clk, LESENSE_ClkPresc_TypeDef clkDiv)
Set the clock division for LESENSE timers.
void LESENSE_DecoderStart (void)
Start the LESENSE decoder.
void LESENSE_DecoderStateAllConfig (const LESENSE_DecStAll_TypeDef *confDecStAll)
Configure all LESENSE decoder states.
void LESENSE_DecoderStateConfig (const LESENSE_DecStDesc_TypeDef *confDecSt, uint32_t decSt)
Configure a single LESENSE decoder state.
uint32_t LESENSE_DecoderStateGet (void)
Get the current state of the LESENSE decoder.
void LESENSE_DecoderStateSet (uint32_t decSt)
Set the LESENSE decoder state.
__STATIC_INLINE void LESENSE_DecoderStop (void)
Stop LESENSE decoder.
void LESENSE_Init (const LESENSE_Init_TypeDef *init, bool reqReset)
Initialize the LESENSE module.
__STATIC_INLINE void LESENSE_IntClear (uint32_t flags)
Clear one or more pending LESENSE interrupts.
__STATIC_INLINE void LESENSE_IntDisable (uint32_t flags)
Disable one or more LESENSE interrupts.
__STATIC_INLINE void LESENSE_IntEnable (uint32_t flags)
Enable one or more LESENSE interrupts.
__STATIC_INLINE uint32_t LESENSE_IntGet (void)
Get pending LESENSE interrupt flags.
__STATIC_INLINE uint32_t LESENSE_IntGetEnabled (void)
Get enabled and pending LESENSE interrupt flags.
__STATIC_INLINE void LESENSE_IntSet (uint32_t flags)
Set one or more pending LESENSE interrupts from SW.
__STATIC_INLINE void LESENSE_RAMPowerDown (void)
Shut off the power to the LESENSE RAM, disables LESENSE.
void LESENSE_Reset (void)
Reset the LESENSE module.
void LESENSE_ResultBufferClear (void)
Clear the result buffer.
uint32_t LESENSE_ScanFreqSet (uint32_t refFreq, uint32_t scanFreq)
Set the scan frequency for periodic scanning.
void LESENSE_ScanModeSet ( LESENSE_ScanMode_TypeDef scanMode, bool start)
Set scan mode of the LESENSE channels.
__STATIC_INLINE uint32_t LESENSE_ScanResultDataBufferGet (uint32_t idx)
Get the data from result data buffer.
__STATIC_INLINE uint32_t LESENSE_ScanResultDataGet (void)
Get the oldest unread data from result buffer.
__STATIC_INLINE uint32_t LESENSE_ScanResultGet (void)
Get the latest scan comparison result (1 bit / channel).
void LESENSE_ScanStart (void)
Start scanning sensors.
void LESENSE_ScanStop (void)
Stop scanning sensors.
__STATIC_INLINE uint32_t LESENSE_SensorStateGet (void)
Get the current state of LESENSE sensor.
void LESENSE_StartDelaySet (uint8_t startDelay)
Set the start delay of the sensor interaction on each channel.
__STATIC_INLINE uint32_t LESENSE_StatusGet (void)
Get the current status of LESENSE.
__STATIC_INLINE void LESENSE_StatusWait (uint32_t flag)
Wait until status of LESENSE is equal to what was requested.

Macro Definition Documentation

#define LESENSE_ALTEX_CH_CONF_DEFAULT
Value:
{ \
false, /* Alternate excitation disabled.*/ \
lesenseAltExPinIdleDis, /* Alternate excitation pin is disabled in idle. */ \
false /* Excite only for corresponding channel. */ \
}

Default configuration for the alternate excitation channel.

Definition at line 962 of file em_lesense.h .

#define LESENSE_ALTEX_CONF_DEFAULT
Value:
{ \
lesenseAltExMapACMP, \
{ \
LESENSE_ALTEX_CH_CONF_DEFAULT, /* Alternate excitation channel 0. */ \
LESENSE_ALTEX_CH_CONF_DEFAULT, /* Alternate excitation channel 1. */ \
LESENSE_ALTEX_CH_CONF_DEFAULT, /* Alternate excitation channel 2. */ \
LESENSE_ALTEX_CH_CONF_DEFAULT, /* Alternate excitation channel 3. */ \
LESENSE_ALTEX_CH_CONF_DEFAULT, /* Alternate excitation channel 4. */ \
LESENSE_ALTEX_CH_CONF_DEFAULT, /* Alternate excitation channel 5. */ \
LESENSE_ALTEX_CH_CONF_DEFAULT, /* Alternate excitation channel 6. */ \
LESENSE_ALTEX_CH_CONF_DEFAULT, /* Alternate excitation channel 7. */ \
LESENSE_ALTEX_CH_CONF_DEFAULT, /* Alternate excitation channel 8. */ \
LESENSE_ALTEX_CH_CONF_DEFAULT, /* Alternate excitation channel 9. */ \
LESENSE_ALTEX_CH_CONF_DEFAULT, /* Alternate excitation channel 10. */ \
LESENSE_ALTEX_CH_CONF_DEFAULT, /* Alternate excitation channel 11. */ \
LESENSE_ALTEX_CH_CONF_DEFAULT, /* Alternate excitation channel 12. */ \
LESENSE_ALTEX_CH_CONF_DEFAULT, /* Alternate excitation channel 13. */ \
LESENSE_ALTEX_CH_CONF_DEFAULT, /* Alternate excitation channel 14. */ \
LESENSE_ALTEX_CH_CONF_DEFAULT /* Alternate excitation channel 15. */ \
} \
}

Default configuration for all the alternate excitation channels.

Definition at line 971 of file em_lesense.h .

#define LESENSE_CH_CONF_DEFAULT
Value:
{ \
false, /* Disable scan channel. */ \
false, /* Disable assigned pin on scan channel. */ \
false, /* Disable interrupts on channel. */ \
lesenseChPinExDis, /* Channel pin is disabled during excitation period. */ \
lesenseChPinIdleDis, /* Channel pin is disabled during idle period. */ \
false, /* Do not use alternate excitation pins for excitation. */ \
false, /* Disabled to shift results from this channel to decoder register. */ \
false, /* Disabled to invert scan result bit. */ \
false, /* Disabled to store counter value in result buffer. */ \
lesenseClkLF, /* Use LF clock for excitation timing. */ \
lesenseClkLF, /* Use LF clock for sample timing. */ \
0x00U, /* Excitation time is set to 0(+1) excitation clock cycles. */ \
0x00U, /* Sample delay is set to 0(+1) sample clock cycles. */ \
0x00U, /* Measure delay is set to 0 excitation clock cycles.*/ \
0x00U, /* ACMP threshold has been set to 0. */ \
lesenseSampleModeACMP, /* ACMP output will be used in comparison. */ \
lesenseSetIntNone, /* No interrupt is generated by the channel. */ \
0x00U, /* Counter threshold has bee set to 0x00. */ \
lesenseCompModeLess /* Compare mode has been set to trigger interrupt on "less". */ \
}

Default configuration for the scan channel.

Definition at line 874 of file em_lesense.h .

#define LESENSE_CORECTRL_DESC_DEFAULT
Value:
{ \
lesenseScanStartPeriodic, /* Start new scan each time the period counter overflows. */ \
lesensePRSCh0, /* Default PRS channel is selected. */ \
lesenseScanConfDirMap, /* Direct mapping SCANCONF register usage strategy. */ \
false, /* Do not invert ACMP0 output. */ \
false, /* Do not invert ACMP1 output. */ \
false, /* Disable dual sampling. */ \
true, /* Store scan result after each scan. */ \
true, /* Overwrite result buffer register even if it is full. */ \
lesenseBufTrigHalf, /* Trigger interrupt and DMA request if result buffer is half full. */ \
lesenseDMAWakeUpDisable, /* Do not wake up on DMA from EM2. */ \
lesenseBiasModeDontTouch, /* Do not touch bias configuration. */ \
true /* Keep LESENSE running in debug mode. */ \
}

Default configuration for LESENSE_CtrlDesc_TypeDef structure.

Definition at line 528 of file em_lesense.h .

#define LESENSE_DECCTRL_DESC_DEFAULT
Value:
{ \
lesenseDecInputSensorSt, /* SENSORSTATE register is used as input to decoder. */ \
0U, /* State 0 is the initial state of decoder. */ \
false, /* Disable check of current state. */ \
true, /* Enable channel x % 16 interrupt on state x change. */ \
true, /* Enable decoder hysteresis on PRS0 output. */ \
true, /* Enable decoder hysteresis on PRS1 output. */ \
true, /* Enable decoder hysteresis on PRS2 output. */ \
true, /* Enable decoder hysteresis on PRS3 output. */ \
false, /* Disable count mode on decoder PRS channels 0 and 1*/ \
lesensePRSCh0, /* PRS Channel 0 as input for bit 0 of LESENSE decoder. */ \
lesensePRSCh1, /* PRS Channel 1 as input for bit 1 of LESENSE decoder. */ \
lesensePRSCh2, /* PRS Channel 2 as input for bit 2 of LESENSE decoder. */ \
lesensePRSCh3, /* PRS Channel 3 as input for bit 3 of LESENSE decoder. */ \
}

Default configuration for LESENSE_PerCtrl_TypeDef structure.

Definition at line 717 of file em_lesense.h .

#define LESENSE_DECODER_CONF_DEFAULT
Value:
{ /* chain | Descriptor A | Descriptor B */ \
{ \
{ false , LESENSE_ST_CONF_DEFAULT , LESENSE_ST_CONF_DEFAULT }, /* Decoder state 0. */ \
{ false , LESENSE_ST_CONF_DEFAULT , LESENSE_ST_CONF_DEFAULT }, /* Decoder state 1. */ \
{ false , LESENSE_ST_CONF_DEFAULT , LESENSE_ST_CONF_DEFAULT }, /* Decoder state 2. */ \
{ false , LESENSE_ST_CONF_DEFAULT , LESENSE_ST_CONF_DEFAULT }, /* Decoder state 3. */ \
{ false , LESENSE_ST_CONF_DEFAULT , LESENSE_ST_CONF_DEFAULT }, /* Decoder state 4. */ \
{ false , LESENSE_ST_CONF_DEFAULT , LESENSE_ST_CONF_DEFAULT }, /* Decoder state 5. */ \
{ false , LESENSE_ST_CONF_DEFAULT , LESENSE_ST_CONF_DEFAULT }, /* Decoder state 6. */ \
{ false , LESENSE_ST_CONF_DEFAULT , LESENSE_ST_CONF_DEFAULT }, /* Decoder state 7. */ \
{ false , LESENSE_ST_CONF_DEFAULT , LESENSE_ST_CONF_DEFAULT }, /* Decoder state 8. */ \
{ false , LESENSE_ST_CONF_DEFAULT , LESENSE_ST_CONF_DEFAULT }, /* Decoder state 9. */ \
{ false , LESENSE_ST_CONF_DEFAULT , LESENSE_ST_CONF_DEFAULT }, /* Decoder state 10. */ \
{ false , LESENSE_ST_CONF_DEFAULT , LESENSE_ST_CONF_DEFAULT }, /* Decoder state 11. */ \
{ false , LESENSE_ST_CONF_DEFAULT , LESENSE_ST_CONF_DEFAULT }, /* Decoder state 12. */ \
{ false , LESENSE_ST_CONF_DEFAULT , LESENSE_ST_CONF_DEFAULT }, /* Decoder state 13. */ \
{ false , LESENSE_ST_CONF_DEFAULT , LESENSE_ST_CONF_DEFAULT }, /* Decoder state 14. */ \
{ false , LESENSE_ST_CONF_DEFAULT , LESENSE_ST_CONF_DEFAULT } /* Decoder state 15. */ \
} \
}
#define LESENSE_ST_CONF_DEFAULT
Definition: em_lesense.h:1042

Default configuration for all decoder states.

Definition at line 1074 of file em_lesense.h .

#define LESENSE_INIT_DEFAULT
Value:
{ \
.coreCtrl = LESENSE_CORECTRL_DESC_DEFAULT , /* Default core control parameters. */ \
.timeCtrl = LESENSE_TIMECTRL_DESC_DEFAULT , /* Default time control parameters. */ \
.perCtrl = LESENSE_PERCTRL_DESC_DEFAULT , /* Default peripheral control parameters. */ \
.decCtrl = LESENSE_DECCTRL_DESC_DEFAULT /* Default decoder control parameters. */ \
}
#define LESENSE_CORECTRL_DESC_DEFAULT
Definition: em_lesense.h:528
#define LESENSE_TIMECTRL_DESC_DEFAULT
Definition: em_lesense.h:558
#define LESENSE_DECCTRL_DESC_DEFAULT
Definition: em_lesense.h:717
#define LESENSE_PERCTRL_DESC_DEFAULT
Definition: em_lesense.h:638

Default configuration for LESENSE_Init_TypeDef structure.

Definition at line 750 of file em_lesense.h .

#define LESENSE_NUM_CHANNELS   16

Number of LESENSE channels.

Definition at line 58 of file em_lesense.h .

Referenced by LESENSE_ChannelAllConfig() , LESENSE_ChannelConfig() , LESENSE_ChannelThresSet() , and LESENSE_Reset() .

#define LESENSE_NUM_DECODER_STATES   (_LESENSE_DECSTATE_DECSTATE_MASK + 1)

Number of decoder states supported by current device.

Definition at line 55 of file em_lesense.h .

Referenced by LESENSE_DecoderStateAllConfig() , LESENSE_DecoderStateConfig() , and LESENSE_Reset() .

#define LESENSE_PERCTRL_DESC_DEFAULT
Value:
{ \
lesenseDACIfData, /* DAC channel 0 data is defined by DAC_CH0DATA register */ \
lesenseDACConvModeDisable, /* LESENSE does not control DAC CH0. */ \
lesenseDACOutModeDisable, /* DAC channel 0 output to pin disabled. */ \
lesenseDACIfData, /* DAC channel 1 data is defined by DAC_CH1DATA register */ \
lesenseDACConvModeDisable, /* LESENSE does not control DAC CH1. */ \
lesenseDACOutModeDisable, /* DAC channel 1 output to pin disabled. */ \
0U, /* DAC prescaling factor of 1 (0+1). */ \
lesenseDACRefVdd, /* DAC uses VDD reference. */ \
lesenseACMPModeMuxThres, /* LESENSE controls input mux and threshold value of ACMP0. */ \
lesenseACMPModeMuxThres, /* LESENSE controls input mux and threshold value of ACMP1. */ \
lesenseWarmupModeKeepWarm /* Keep both ACMPs and DAC powered up when LESENSE is idle. */ \
}

Default configuration for LESENSE_PerCtrl_TypeDef structure.

Definition at line 638 of file em_lesense.h .

#define LESENSE_SCAN_CONF_DEFAULT
Value:
{ \
{ \
LESENSE_CH_CONF_DEFAULT, /* Scan channel 0. */ \
LESENSE_CH_CONF_DEFAULT, /* Scan channel 1. */ \
LESENSE_CH_CONF_DEFAULT, /* Scan channel 2. */ \
LESENSE_CH_CONF_DEFAULT, /* Scan channel 3. */ \
LESENSE_CH_CONF_DEFAULT, /* Scan channel 4. */ \
LESENSE_CH_CONF_DEFAULT, /* Scan channel 5. */ \
LESENSE_CH_CONF_DEFAULT, /* Scan channel 6. */ \
LESENSE_CH_CONF_DEFAULT, /* Scan channel 7. */ \
LESENSE_CH_CONF_DEFAULT, /* Scan channel 8. */ \
LESENSE_CH_CONF_DEFAULT, /* Scan channel 9. */ \
LESENSE_CH_CONF_DEFAULT, /* Scan channel 10. */ \
LESENSE_CH_CONF_DEFAULT, /* Scan channel 11. */ \
LESENSE_CH_CONF_DEFAULT, /* Scan channel 12. */ \
LESENSE_CH_CONF_DEFAULT, /* Scan channel 13. */ \
LESENSE_CH_CONF_DEFAULT, /* Scan channel 14. */ \
LESENSE_CH_CONF_DEFAULT, /* Scan channel 15. */ \
} \
}

Default configuration for all the sensor channels.

Definition at line 899 of file em_lesense.h .

#define LESENSE_ST_CONF_DEFAULT
Value:
{ \
0x0FU, /* Compare value set to 0x0F. */ \
0x00U, /* All decoder inputs masked. */ \
0U, /* Next state is state 0. */ \
lesenseTransActNone, /* No PRS action performed on compare match. */ \
false /* No interrupt triggered on compare match. */ \
}

Default configuration for the decoder state condition.

Definition at line 1042 of file em_lesense.h .

#define LESENSE_TIMECTRL_DESC_DEFAULT
Value:
{ \
0U, /* No sensor interaction delay. */ \
false /* Do not delay the AUXHFRCO startup. */ \
}

Default configuration for LESENSE_TimeCtrlDesc_TypeDef structure.

Definition at line 558 of file em_lesense.h .

Enumeration Type Documentation

Locations of the alternate excitation function.

Enumerator
lesenseAltExMapALTEX

Alternate excitation is mapped to the LES_ALTEX pins.

lesenseAltExMapACMP

Alternate excitation is mapped to the pins of the other ACMP.

Definition at line 125 of file em_lesense.h .

Idle phase configuration of the alternate excitation channels.

Enumerator
lesenseAltExPinIdleDis

ALTEX output is disabled in idle phase. Note: This value could be used for all the alternate excitation channels.

lesenseAltExPinIdleHigh

ALTEX output is high in idle phase. Note: This value could be used for all the alternate excitation channels.

lesenseAltExPinIdleLow

ALTEX output is low in idle phase. Note: This value could be used for all the alternate excitation channels.

Definition at line 428 of file em_lesense.h .

Bias modes.

Enumerator
lesenseBiasModeDutyCycle

Duty cycle bias module between low power and high accuracy mode.

lesenseBiasModeHighAcc

Bias module is always in high accuracy mode.

lesenseBiasModeDontTouch

Bias module is controlled by EMU and not affected by the LESENSE.

Definition at line 165 of file em_lesense.h .

Result buffer interrupt and DMA trigger levels.

Enumerator
lesenseBufTrigHalf

DMA and interrupt flags are set when the result buffer is half-full.

lesenseBufTrigFull

DMA and interrupt flags set when the result buffer is full.

Definition at line 142 of file em_lesense.h .

Clock used for excitation and sample delay timing.

Enumerator
lesenseClkLF

LFACLK (LF clock) is used.

lesenseClkHF

AUXHFRCO (HF clock) is used.

Definition at line 383 of file em_lesense.h .

Compare modes for counter comparison.

Enumerator
lesenseCompModeLess

Comparison evaluates to 1 if sensor data is less than the counter threshold, or if ACMP output is 0.

lesenseCompModeGreaterOrEq

Comparison evaluates to 1 if sensor data is greater than, or equal to the counter threshold, or if the ACMP output is 1.

Definition at line 392 of file em_lesense.h .

Interrupt generation setup for CHx interrupt flag.

Enumerator
lesenseSetIntNone

No interrupt is generated.

lesenseSetIntLevel

Set interrupt flag if the sensor triggers.

lesenseSetIntPosEdge

Set interrupt flag on positive edge of the sensor state.

lesenseSetIntNegEdge

Set interrupt flag on negative edge of the sensor state.

Definition at line 324 of file em_lesense.h .

Channel pin mode for the excitation phase of the scan sequence.

Enumerator
lesenseChPinExDis

Channel pin is disabled.

lesenseChPinExHigh

Channel pin is configured as push-pull, driven HIGH.

lesenseChPinExLow

Channel pin is configured as push-pull, driven LOW.

lesenseChPinExDACOut

DAC output (only available on channel 0, 1, 2, 3, 12, 13, 14 and 15)

Definition at line 339 of file em_lesense.h .

Channel pin mode for the idle phase of scan sequence.

Enumerator
lesenseChPinIdleDis

Channel pin is disabled in idle phase. Note: This value could be used for all channels.

lesenseChPinIdleHigh

Channel pin is configured as push-pull, driven HIGH in idle phase. Note: This value could be used for all channels.

lesenseChPinIdleLow

Channel pin is configured as push-pull, driven LOW in idle phase. Note: This value could be used for all channels.

lesenseChPinIdleDACCh0

Channel pin is connected to DAC CH0 output in idle phase. Note: Only applies to channel 0, 1, 2, 3.

lesenseChPinIdleDACCh1

Channel pin is connected to DAC CH1 output in idle phase. Note: Only applies to channel 12, 13, 14, 15.

Definition at line 354 of file em_lesense.h .

Compare source selection for sensor sampling.

Enumerator
lesenseSampleModeCounter

Counter output will be used in comparison.

lesenseSampleModeACMP

ACMP output will be used in comparison.

Definition at line 307 of file em_lesense.h .

Clock divisors for controlling the prescaling factor of the period counter. Note: These enumeration values are used for different clock division related configuration parameters (hfPresc, lfPresc, pcPresc).

Enumerator
lesenseClkDiv_1

Divide clock by 1.

lesenseClkDiv_2

Divide clock by 2.

lesenseClkDiv_4

Divide clock by 4.

lesenseClkDiv_8

Divide clock by 8.

lesenseClkDiv_16

Divide clock by 16.

lesenseClkDiv_32

Divide clock by 32.

lesenseClkDiv_64

Divide clock by 64.

lesenseClkDiv_128

Divide clock by 128.

Definition at line 67 of file em_lesense.h .

ACMPx control configuration.

Enumerator
lesenseACMPModeDisable

LESENSE does not control ACMPx. Note: This value could be used for both ACMP0 and ACMP1.

lesenseACMPModeMux

LESENSE controls input mux of ACMPx. Note: This value could be used for both ACMP0 and ACMP1.

lesenseACMPModeMuxThres

LESENSE controls input mux of and threshold value of ACMPx. Note: This value could be used for both ACMP0 and ACMP1.

Definition at line 268 of file em_lesense.h .

DAC channel x conversion mode configuration.

Enumerator
lesenseDACConvModeDisable

LESENSE does not control the DAC channel x. Note: This value could be used for both DAC Ch0 and Ch1.

lesenseDACConvModeContinuous

DAC channel x is driven in continuous mode. Note: This value could be used for both DAC Ch0 and Ch1.

lesenseDACConvModeSampleHold

DAC channel x is driven in sample hold mode. Note: This value could be used for both DAC Ch0 and Ch1.

lesenseDACConvModeSampleOff

DAC channel x is driven in sample off mode. Note: This value could be used for both DAC Ch0 and Ch1.

Definition at line 216 of file em_lesense.h .

DAC CHx data control configuration.

Enumerator
lesenseDACIfData

DAC channel x data is defined by the DAC_CHxDATA register. Note: this value could be used for both DAC Ch0 and Ch1.

lesenseACMPThres

DAC channel x data is defined by the ACMPTHRES in LESENSE_CHx_INTERACT. Note: This value could be used for both DAC Ch0 and Ch1.

Definition at line 196 of file em_lesense.h .

DAC channel x output mode configuration.

Enumerator
lesenseDACOutModeDisable

DAC CHx output to pin and ACMP/ADC disabled. Note: This value could be used for both DAC Ch0 and Ch1.

lesenseDACOutModePin

DAC CHx output to pin enabled, output to ADC and ACMP disabled. Note: This value could be used for both DAC Ch0 and Ch1.

lesenseDACOutModeADCACMP

DAC CHx output to pin disabled, output to ADC and ACMP enabled. Note: This value could be used for both DAC Ch0 and Ch1.

lesenseDACOutModePinADCACMP

DAC CHx output to pin, ADC, and ACMP enabled. Note: This value could be used for both DAC Ch0 and Ch1.

Definition at line 237 of file em_lesense.h .

DAC reference configuration.

Enumerator
lesenseDACRefVdd

DAC uses VDD reference.

lesenseDACRefBandGap

DAC uses band gap reference.

Definition at line 258 of file em_lesense.h .

Decoder input source configuration.

Enumerator
lesenseDecInputSensorSt

SENSORSTATE register is used as input to the decoder.

lesenseDecInputPRS

PRS channels are used as input to the decoder.

Definition at line 298 of file em_lesense.h .

Modes of operation for DMA wakeup from EM2.

Enumerator
lesenseDMAWakeUpDisable

No DMA wakeup from EM2.

lesenseDMAWakeUpBufValid

DMA wakeup from EM2 when data is valid in the result buffer.

lesenseDMAWakeUpBufLevel

DMA wakeup from EM2 when the result buffer is full/half-full, depending on RESBIDL configuration in the LESENSE_CTRL register (selected by the resBufTrigLevel in LESENSE_ResBufTrigLevel_TypeDef descriptor structure).

Definition at line 151 of file em_lesense.h .

PRS sources. Note: These enumeration values are being used for different PRS related configuration parameters.

Enumerator
lesensePRSCh0

PRS channel 0.

lesensePRSCh1

PRS channel 1.

lesensePRSCh2

PRS channel 2.

lesensePRSCh3

PRS channel 3.

lesensePRSCh4

PRS channel 4.

lesensePRSCh5

PRS channel 5.

lesensePRSCh6

PRS channel 6.

lesensePRSCh7

PRS channel 7.

lesensePRSCh8

PRS channel 8.

lesensePRSCh9

PRS channel 9.

lesensePRSCh10

PRS channel 10.

lesensePRSCh11

PRS channel 11.

Definition at line 93 of file em_lesense.h .

Scan configuration.

Enumerator
lesenseScanConfDirMap

Channel configuration registers (CHx_CONF) used are directly mapped to the channel number.

lesenseScanConfInvMap

Channel configuration registers used are CHx+8_CONF for channels 0-7 and CHx-8_CONF for channels 8-15.

lesenseScanConfToggle

Channel configuration registers used toggles between CHX_SCANCONF and CHX+8_SCANCONF when channel x triggers.

lesenseScanConfDecDef

Decoder state defines the channel configuration register (CHx_CONF) to be used.

Definition at line 177 of file em_lesense.h .

Scan modes.

Enumerator
lesenseScanStartPeriodic

New scan is started each time the period counter overflows.

lesenseScanStartOneShot

Single scan is performed when LESENSE_ScanStart() is called.

lesenseScanStartPRS

New scan is triggered by pulse on PRS channel.

Definition at line 79 of file em_lesense.h .

Transition action modes.

Enumerator
lesenseTransActNone

No PRS pulses generated (if PRSCOUNT == 0). Do not count (if PRSCOUNT == 1).

lesenseTransActPRS0

Generate pulse on LESPRS0 (if PRSCOUNT == 0).

lesenseTransActPRS1

Generate pulse on LESPRS1 (if PRSCOUNT == 0).

lesenseTransActPRS01

Generate pulse on LESPRS0 and LESPRS1 (if PRSCOUNT == 0).

lesenseTransActPRS2

Generate pulse on LESPRS2 (for both PRSCOUNT == 0 and PRSCOUNT == 1).

lesenseTransActPRS02

Generate pulse on LESPRS0 and LESPRS2 (if PRSCOUNT == 0).

lesenseTransActPRS12

Generate pulse on LESPRS1 and LESPRS2 (if PRSCOUNT == 0).

lesenseTransActPRS012

Generate pulse on LESPRS0, LESPRS1 and LESPRS2 (if PRSCOUNT == 0).

lesenseTransActUp

Count up (if PRSCOUNT == 1).

lesenseTransActDown

Count down (if PRSCOUNT == 1).

lesenseTransActUpAndPRS2

Count up and generate pulse on LESPRS2 (if PRSCOUNT == 1).

lesenseTransActDownAndPRS2

Count down and generate pulse on LESPRS2 (if PRSCOUNT == 1).

Definition at line 443 of file em_lesense.h .

Warm up modes. ACMP and DAC duty cycle mode configuration.

Enumerator
lesenseWarmupModeNormal

ACMPs and DACs are shut down when LESENSE is idle.

lesenseWarmupModeACMP

ACMPs are kept powered up when LESENSE is idle.

lesenseWarmupModeDAC

DAC is kept powered up when LESENSE is idle.

lesenseWarmupModeKeepWarm

ACMPs and DAC are kept powered up when LESENSE is idle.

Definition at line 283 of file em_lesense.h .

Function Documentation

void LESENSE_AltExConfig ( const LESENSE_ConfAltEx_TypeDef * confAltEx )

Configure the LESENSE alternate excitation modes.

This function configures the alternate excitation channels of the LESENSE interface. See the configuration parameter type definition ( LESENSE_ConfAltEx_TypeDef ) for more details.

Note
The useAltEx parameter must be true in the channel configuration structure ( LESENSE_ChDesc_TypeDef ) to use alternate excitation pins on the channel.
Parameters
[in] confAltEx A configuration structure for LESENSE alternate excitation pins.

Definition at line 603 of file em_lesense.c .

References LESENSE_ConfAltEx_TypeDef::AltEx , LESENSE_ConfAltEx_TypeDef::altExMap , LESENSE_AltExDesc_TypeDef::alwaysEx , BUS_RegBitWrite() , LESENSE_AltExDesc_TypeDef::enablePin , LESENSE_AltExDesc_TypeDef::idleConf , lesenseAltExMapACMP , and lesenseAltExMapALTEX .

__STATIC_INLINE uint32_t LESENSE_ChannelActiveGet ( void )

Get the currently active channel index.

Returns
Returns the value of the LESENSE_CHINDEX register that contains the index of currently active channel (0-15).

Definition at line 1255 of file em_lesense.h .

void LESENSE_ChannelAllConfig ( const LESENSE_ChAll_TypeDef * confChAll )

Configure all (16) LESENSE sensor channels.

This function configures all sensor channels of the LESENSE interface. See the configuration parameter type definition ( LESENSE_ChAll_TypeDef ) for more details.

Note
Channels can be configured individually using LESENSE_ChannelConfig() function. Notice that pins used by the LESENSE module must be properly configured by the user explicitly for LESENSE to work as intended. (When configuring pins, consider the sequence of the configuration to avoid unintended pulses/glitches on output pins.)
Parameters
[in] confChAll A configuration structure for all (16) LESENSE sensor channels.

Definition at line 464 of file em_lesense.c .

References LESENSE_ChAll_TypeDef::Ch , LESENSE_ChannelConfig() , and LESENSE_NUM_CHANNELS .

Referenced by CAPLESENSE_setupLESENSE() .

void LESENSE_ChannelConfig ( const LESENSE_ChDesc_TypeDef * confCh,
uint32_t chIdx
)

Configure a single LESENSE sensor channel.

This function configures a single sensor channel of the LESENSE interface. See the configuration parameter type definition ( LESENSE_ChDesc_TypeDef ) for more details.

Note
This function has been designed to minimize the effects of sensor channel reconfiguration while LESENSE is in operation. However, be aware of these effects and the right timing to call this function. Parameter useAltEx must be true in the channel configuration to use alternate excitation pins.
Parameters
[in] confCh A configuration structure for a single LESENSE sensor channel.
[in] chIdx A channel index to configure (0-15).

Definition at line 497 of file em_lesense.c .

References LESENSE_ChDesc_TypeDef::acmpThres , BUS_RegBitWrite() , LESENSE_ChDesc_TypeDef::chPinExMode , LESENSE_ChDesc_TypeDef::chPinIdleMode , LESENSE_ChDesc_TypeDef::cntThres , LESENSE_ChDesc_TypeDef::compMode , LESENSE_ChDesc_TypeDef::enaInt , LESENSE_ChDesc_TypeDef::enaPin , LESENSE_ChDesc_TypeDef::enaScanCh , LESENSE_ChDesc_TypeDef::exClk , LESENSE_ChDesc_TypeDef::exTime , LESENSE_ChDesc_TypeDef::intMode , LESENSE_ChDesc_TypeDef::invRes , LESENSE_ChannelThresSet() , LESENSE_ChannelTimingSet() , LESENSE_NUM_CHANNELS , lesenseChPinExDACOut , lesenseChPinIdleDACCh0 , lesenseChPinIdleDACCh1 , LESENSE_ChDesc_TypeDef::measDelay , LESENSE_ChDesc_TypeDef::sampleClk , LESENSE_ChDesc_TypeDef::sampleDelay , LESENSE_ChDesc_TypeDef::sampleMode , LESENSE_ChDesc_TypeDef::shiftRes , LESENSE_ChDesc_TypeDef::storeCntRes , and LESENSE_ChDesc_TypeDef::useAltEx .

Referenced by LESENSE_ChannelAllConfig() .

void LESENSE_ChannelEnable ( uint8_t chIdx,
bool enaScanCh,
bool enaPin
)

Enable/disable LESENSE scan channel and the pin assigned to it.

Use this function to enable/disable a selected LESENSE scan channel and the pin assigned to it.

Note
Users can enable/disable scan channels and the channel pin with the LESENSE_ChannelConfig() function, but only with a significant overhead. This simple function controls these parameters after the channel has been configured.
Parameters
[in] chIdx An identifier of the scan channel. A valid range: 0-15.
[in] enaScanCh Enable/disable the selected scan channel by setting this parameter to true/false respectively.
[in] enaPin Enable/disable the pin assigned to the channel selected by chIdx .

Definition at line 686 of file em_lesense.c .

References BUS_RegBitWrite() .

void LESENSE_ChannelEnableMask ( uint16_t chMask,
uint16_t pinMask
)

Enable/disable LESENSE scan channel and the pin assigned to it.

Use this function to enable/disable LESENSE scan channels and the pins assigned to them using a mask.

Note
Users can enable/disable scan channels and channel pins by using the LESENSE_ChannelAllConfig() function, but only with a significant overhead. This simple function controls these parameters after the channel has been configured.
Parameters
[in] chMask Set the corresponding bit to 1 to enable, 0 to disable the selected scan channel.
[in] pinMask Set the corresponding bit to 1 to enable, 0 to disable the pin on selected channel.

Definition at line 722 of file em_lesense.c .

void LESENSE_ChannelThresSet ( uint8_t chIdx,
uint16_t acmpThres,
uint16_t cntThres
)

Set LESENSE channel threshold parameters.

Use this function to set threshold parameters on a selected LESENSE channel.

Note
Users can configure the channel threshold parameters with the LESENSE_ChannelConfig() function, but only with a significant overhead. This simple function serves controls these parameters after the channel has been configured.
Parameters
[in] chIdx An identifier of the scan channel. A valid range is 0-15.
[in] acmpThres ACMP threshold.
  • If perCtrl.dacCh0Data or perCtrl.dacCh1Data is set to lesenseDACIfData , acmpThres defines the 12-bit DAC data in the corresponding data register of the DAC interface (DACn_CH0DATA and DACn_CH1DATA). In this case, the valid range is 0-4095 (12 bits).
  • If perCtrl.dacCh0Data or perCtrl.dacCh1Data is set to lesenseACMPThres , acmpThres defines the 6-bit Vdd scaling factor of ACMP negative input (VDDLEVEL in ACMP_INPUTSEL register). In this case, the valid range is 0-63 (6 bits).
[in] cntThres A decision threshold for counter comparison. A valid range is 0-65535 (16 bits).

Definition at line 812 of file em_lesense.c .

References LESENSE_NUM_CHANNELS .

Referenced by CAPLESENSE_setupLESENSE() , and LESENSE_ChannelConfig() .

void LESENSE_ChannelTimingSet ( uint8_t chIdx,
uint8_t exTime,
uint8_t sampleDelay,
uint16_t measDelay
)

Set LESENSE channel timing parameters.

Use this function to set timing parameters on a selected LESENSE channel.

Note
Users can configure the channel timing parameters with the LESENSE_ChannelConfig() function, but only with a significant overhead. This simple function controls these parameters after the channel has been configured.
Parameters
[in] chIdx An identifier of the scan channel. A valid range is 0-15.
[in] exTime An excitation time on chIdx. The excitation will last exTime+1 excitation clock cycles. A valid range is 0-63 (6 bits).
[in] sampleDelay Sample delay on chIdx. Sampling will occur after sampleDelay+1 sample clock cycles. A valid range is 0-127 (7 bits).
[in] measDelay A measure delay on chIdx. Sensor measuring is delayed for measDelay+1 excitation clock cycles. A valid range is 0-127 (7 bits).

Definition at line 758 of file em_lesense.c .

Referenced by LESENSE_ChannelConfig() .

void LESENSE_ClkDivSet ( LESENSE_ChClk_TypeDef clk,
LESENSE_ClkPresc_TypeDef clkDiv
)

Set the clock division for LESENSE timers.

Use this function to configure the clock division for the LESENSE timers used for excitation timing. The division setting is global but the clock source can be selected for each channel using LESENSE_ChannelConfig() function. See documentation for more details.

Note
If AUXHFRCO is used for excitation timing, LFACLK can't exceed 500 kHz. LFACLK can't exceed 50 kHz if the ACMP threshold level (ACMPTHRES) is not equal for all channels.
Parameters
[in] clk Select the clock to prescale.
  • lesenseClkHF - set AUXHFRCO clock divisor for HF timer.
  • lesenseClkLF - set LFACLKles clock divisor for LF timer.
[in] clkDiv The clock divisor value. A valid range depends on the clk value.

Definition at line 405 of file em_lesense.c .

References lesenseClkDiv_8 , lesenseClkHF , and lesenseClkLF .

Referenced by CAPLESENSE_setupLESENSE() .

void LESENSE_DecoderStart ( void )

Start the LESENSE decoder.

Note
This function will wait for any pending previous write operation to the CMD register to complete before accessing the CMD register. It will also wait for the write operation to the CMD register to complete before returning. Each write operation to the CMD register may take up to 3 LF clock cycles, so expect some delay. The user may implement a separate function to write multiple command bits in the CMD register in one single operation to optimize an application.

Definition at line 1167 of file em_lesense.c .

void LESENSE_DecoderStateAllConfig ( const LESENSE_DecStAll_TypeDef * confDecStAll )

Configure all LESENSE decoder states.

This function configures all the decoder states of the LESENSE interface. See the configuration parameter type definition ( LESENSE_DecStAll_TypeDef ) for more details.

Note
Decoder states can be configured individually using LESENSE_DecoderStateConfig() function.
Parameters
[in] confDecStAll A configuration structure for all (16 or 32) LESENSE decoder states.

Definition at line 973 of file em_lesense.c .

References LESENSE_DecoderStateConfig() , LESENSE_NUM_DECODER_STATES , and LESENSE_DecStAll_TypeDef::St .

void LESENSE_DecoderStateConfig ( const LESENSE_DecStDesc_TypeDef * confDecSt,
uint32_t decSt
)

Configure a single LESENSE decoder state.

This function configures a single decoder state of the LESENSE interface. See the configuration parameter type definition ( LESENSE_DecStDesc_TypeDef ) for more details.

Parameters
[in] confDecSt A configuration structure for a single LESENSE decoder state.
[in] decSt A decoder state index to configure (0-15) or (0-31) depending on the device.

Definition at line 999 of file em_lesense.c .

References LESENSE_DecStDesc_TypeDef::chainDesc , LESENSE_DecStCond_TypeDef::compMask , LESENSE_DecStCond_TypeDef::compVal , LESENSE_DecStDesc_TypeDef::confA , LESENSE_DecStDesc_TypeDef::confB , LESENSE_NUM_DECODER_STATES , LESENSE_DecStCond_TypeDef::nextState , LESENSE_DecStCond_TypeDef::prsAct , and LESENSE_DecStCond_TypeDef::setInt .

Referenced by LESENSE_DecoderStateAllConfig() .

uint32_t LESENSE_DecoderStateGet ( void )

Get the current state of the LESENSE decoder.

Returns
This function returns the value of the LESENSE_DECSTATE register that represents the current state of the LESENSE decoder.

Definition at line 1065 of file em_lesense.c .

void LESENSE_DecoderStateSet ( uint32_t decSt )

Set the LESENSE decoder state.

This function can be used for setting the initial state of the LESENSE decoder.

Note
Make sure the LESENSE decoder state is initialized by this function before enabling the decoder!
Parameters
[in] decSt A decoder state to set as the current state. A valid range is 0-15 or 0-31, depending on the device.

Definition at line 1050 of file em_lesense.c .

Referenced by LESENSE_Init() .

__STATIC_INLINE void LESENSE_DecoderStop ( void )

Stop LESENSE decoder.

Disables LESENSE decoder by setting the command to LESENSE_DECCTRL register.

Definition at line 1196 of file em_lesense.h .

void LESENSE_Init ( const LESENSE_Init_TypeDef * init,
bool reqReset
)

Initialize the LESENSE module.

This function configures the main parameters of the LESENSE interface. See the initialization parameter type definition ( LESENSE_Init_TypeDef ) for more details.

Note
LESENSE_Init() is designed to initialize LESENSE once in an operation cycle. Be aware of the effects of reconfiguration if using this function from multiple sources in your code. This function has not been designed to be re-entrant. Requesting reset by setting reqReset to true is required in each reset or power-on cycle to configure the default values of the RAM mapped LESENSE registers. Notice that GPIO pins used by the LESENSE module must be properly configured by the user explicitly for the LESENSE to work as intended. (When configuring pins, one should remember to consider the sequence of configuration to avoid unintended pulses/glitches on output pins.)
Parameters
[in] init The LESENSE initialization structure.
[in] reqReset Request to call LESENSE_Reset() first to initialize all LESENSE registers with default values.

Definition at line 115 of file em_lesense.c .

References LESENSE_PerCtrlDesc_TypeDef::acmp0Mode , LESENSE_PerCtrlDesc_TypeDef::acmp1Mode , LESENSE_CoreCtrlDesc_TypeDef::biasMode , LESENSE_CoreCtrlDesc_TypeDef::bufOverWr , LESENSE_CoreCtrlDesc_TypeDef::bufTrigLevel , LESENSE_DecCtrlDesc_TypeDef::chkState , LESENSE_Init_TypeDef::coreCtrl , LESENSE_PerCtrlDesc_TypeDef::dacCh0ConvMode , LESENSE_PerCtrlDesc_TypeDef::dacCh0Data , LESENSE_PerCtrlDesc_TypeDef::dacCh0OutMode , LESENSE_PerCtrlDesc_TypeDef::dacCh1ConvMode , LESENSE_PerCtrlDesc_TypeDef::dacCh1Data , LESENSE_PerCtrlDesc_TypeDef::dacCh1OutMode , LESENSE_PerCtrlDesc_TypeDef::dacPresc , LESENSE_PerCtrlDesc_TypeDef::dacRef , LESENSE_CoreCtrlDesc_TypeDef::debugRun , LESENSE_Init_TypeDef::decCtrl , LESENSE_DecCtrlDesc_TypeDef::decInput , LESENSE_TimeCtrlDesc_TypeDef::delayAuxStartup , LESENSE_CoreCtrlDesc_TypeDef::dualSample , LESENSE_DecCtrlDesc_TypeDef::hystIRQ , LESENSE_DecCtrlDesc_TypeDef::hystPRS0 , LESENSE_DecCtrlDesc_TypeDef::hystPRS1 , LESENSE_DecCtrlDesc_TypeDef::hystPRS2 , LESENSE_DecCtrlDesc_TypeDef::initState , LESENSE_DecCtrlDesc_TypeDef::intMap , LESENSE_CoreCtrlDesc_TypeDef::invACMP0 , LESENSE_CoreCtrlDesc_TypeDef::invACMP1 , LESENSE_DecoderStateSet() , LESENSE_Reset() , LESENSE_ScanModeSet() , LESENSE_StartDelaySet() , LESENSE_Init_TypeDef::perCtrl , LESENSE_DecCtrlDesc_TypeDef::prsChSel0 , LESENSE_DecCtrlDesc_TypeDef::prsChSel1 , LESENSE_DecCtrlDesc_TypeDef::prsChSel2 , LESENSE_DecCtrlDesc_TypeDef::prsChSel3 , LESENSE_DecCtrlDesc_TypeDef::prsCount , LESENSE_CoreCtrlDesc_TypeDef::prsSel , LESENSE_CoreCtrlDesc_TypeDef::scanConfSel , LESENSE_CoreCtrlDesc_TypeDef::scanStart , LESENSE_TimeCtrlDesc_TypeDef::startDelay , LESENSE_CoreCtrlDesc_TypeDef::storeScanRes , LESENSE_Init_TypeDef::timeCtrl , LESENSE_CoreCtrlDesc_TypeDef::wakeupOnDMA , and LESENSE_PerCtrlDesc_TypeDef::warmupMode .

Referenced by CAPLESENSE_setupLESENSE() .

__STATIC_INLINE void LESENSE_IntClear ( uint32_t flags )

Clear one or more pending LESENSE interrupts.

Parameters
[in] flags Pending LESENSE interrupt sources to clear. Use a set of interrupt flags OR-ed together to clear multiple interrupt sources of LESENSE module (LESENSE_IF_nnn).

Definition at line 1357 of file em_lesense.h .

Referenced by CAPLESENSE_setupLESENSE() , and LESENSE_IRQHandler() .

__STATIC_INLINE void LESENSE_IntDisable ( uint32_t flags )

Disable one or more LESENSE interrupts.

Parameters
[in] flags LESENSE interrupt sources to disable. Use a set of interrupt flags OR-ed together to disable multiple interrupt sources of LESENSE module (LESENSE_IF_nnn).

Definition at line 1385 of file em_lesense.h .

Referenced by CAPLESENSE_setupLESENSE() .

__STATIC_INLINE void LESENSE_IntEnable ( uint32_t flags )

Enable one or more LESENSE interrupts.

Parameters
[in] flags LESENSE interrupt sources to enable. Use a set of interrupt flags OR-ed together to enable multiple interrupt sources of LESENSE module (LESENSE_IF_nnn).

Definition at line 1371 of file em_lesense.h .

Referenced by CAPLESENSE_setupLESENSE() .

__STATIC_INLINE uint32_t LESENSE_IntGet ( void )

Get pending LESENSE interrupt flags.

Note
Event bits are not cleared by the use of this function.
Returns
Pending LESENSE interrupt sources. The OR combination of valid interrupt flags of the LESENSE module (LESENSE_IF_nnn).

Definition at line 1415 of file em_lesense.h .

__STATIC_INLINE uint32_t LESENSE_IntGetEnabled ( void )

Get enabled and pending LESENSE interrupt flags.

Useful for handling more interrupt sources in the same interrupt handler.

Note
Event bits are not cleared by the use of this function.
Returns
Pending and enabled LESENSE interrupt sources. Return value is the bitwise AND combination of
  • the OR combination of enabled interrupt sources in LESENSE_IEN_nnn register (LESENSE_IEN_nnn) and
  • the OR combination of valid interrupt flags of LESENSE module (LESENSE_IF_nnn).

Definition at line 1438 of file em_lesense.h .

Referenced by LESENSE_IRQHandler() .

__STATIC_INLINE void LESENSE_IntSet ( uint32_t flags )

Set one or more pending LESENSE interrupts from SW.

Parameters
[in] flags LESENSE interrupt sources to set to pending. Use a set of interrupt flags OR-ed together to set multiple interrupt sources of LESENSE module (LESENSE_IFS_nnn).

Definition at line 1399 of file em_lesense.h .

__STATIC_INLINE void LESENSE_RAMPowerDown ( void )

Shut off the power to the LESENSE RAM, disables LESENSE.

Shuts off the LESENSE RAM in order to decrease leakage current of MCU if LESENSE is not used in your application.

Note
Warning! Once LESENSE RAM is powered down, it cannot be powered up again.

Definition at line 1341 of file em_lesense.h .

void LESENSE_Reset ( void )

Reset the LESENSE module.

Use this function to reset LESENSE registers.

Note
Resetting LESENSE registers is required in each reset or power-on cycle to configure the default values of the RAM mapped LESENSE registers. LESENSE_Reset() can be called on initialization by setting the reqReset parameter to true in LESENSE_Init() .

Definition at line 1224 of file em_lesense.c .

References LESENSE_NUM_CHANNELS , and LESENSE_NUM_DECODER_STATES .

Referenced by LESENSE_Init() .

void LESENSE_ResultBufferClear ( void )

Clear the result buffer.

Note
This function will wait for any pending previous write operation to the CMD register to complete before accessing the CMD register. It will also wait for the write operation to the CMD register to complete before returning. Each write operation to the CMD register may take up to 3 LF clock cycles, so expect some delay. The user may implement a separate function to write multiple command bits in the CMD register in one single operation to optimize an application.

Definition at line 1196 of file em_lesense.c .

Referenced by CAPLESENSE_setupLESENSE() .

uint32_t LESENSE_ScanFreqSet ( uint32_t refFreq,
uint32_t scanFreq
)

Set the scan frequency for periodic scanning.

This function only applies to LESENSE if a period counter is used as a trigger for scan start. The calculation is based on the following formula: Fscan = LFACLKles / ((1+PCTOP)*2^PCPRESC)

Note
Note that the calculation does not necessarily result in the requested scan frequency due to integer division. Check the return value for the resulted scan frequency.
Parameters
[in] refFreq Select reference LFACLK clock frequency in Hz. If set to 0, the current clock frequency is being used as a reference.
[in] scanFreq Set the desired scan frequency in Hz.
Returns
Frequency in Hz calculated and set by this function. Users can use this to compare the requested and set values.

Definition at line 247 of file em_lesense.c .

References CMU_ClockFreqGet() , cmuClock_LESENSE , and lesenseClkDiv_128 .

Referenced by CAPLESENSE_setupLESENSE() .

void LESENSE_ScanModeSet ( LESENSE_ScanMode_TypeDef scanMode,
bool start
)

Set scan mode of the LESENSE channels.

This function configures how the scan start is triggered. It can be used for re-configuring the scan mode while running the application but it is also used by LESENSE_Init() for initialization.

Note
Users can configure the scan mode by LESENSE_Init() function, but only with a significant overhead. This simple function serves the purpose of controlling this parameter after the channel has been configured. Be aware of the effects of the non-atomic Read-Modify-Write cycle.
Parameters
[in] scanMode Select the location to map LESENSE alternate excitation channels.
  • lesenseScanStartPeriodic - A new scan is started each time the period counter overflows.
  • lesenseScanStartOneShot - A single scan is performed when LESENSE_ScanStart() is called.
  • lesenseScanStartPRS - A new scan is triggered by pulse on the PRS channel.
[in] start If true, LESENSE_ScanStart() is immediately issued after configuration.

Definition at line 325 of file em_lesense.c .

References LESENSE_ScanStart() .

Referenced by LESENSE_Init() .

__STATIC_INLINE uint32_t LESENSE_ScanResultDataBufferGet ( uint32_t idx )

Get the data from result data buffer.

Note
Make sure that the STORERES bit is set in LESENSE_CHx_EVAL, or the STRSCANRES bit is set in LESENSE_CTRL; otherwise, returns the undefined value.
Parameters
[in] idx Result data buffer index. Valid range: 0-15.
Returns
Returns the selected word from the result data buffer.

Definition at line 1309 of file em_lesense.h .

Referenced by CAPLESENSE_setupLESENSE() .

__STATIC_INLINE uint32_t LESENSE_ScanResultDataGet ( void )

Get the oldest unread data from result buffer.

Note
Make sure that the STORERES bit is set in LESENSE_CHx_EVAL, or the STRSCANRES bit is set in LESENSE_CTRL; otherwise, returns the undefined value.
Returns
Returns the value of LESENSE_RESDATA register that contains the oldest unread counter result from result buffer.

Definition at line 1289 of file em_lesense.h .

Referenced by LESENSE_IRQHandler() .

__STATIC_INLINE uint32_t LESENSE_ScanResultGet ( void )

Get the latest scan comparison result (1 bit / channel).

Returns
Returns the value of the LESENSE_SCANRES register that contains the comparison result of last scan on all channels. Bit x is set if a comparison triggered on channel x, which means that LESENSE counter met the comparison criteria set in LESENSE_CHx_EVAL by COMPMODE and CNTTHRES.

Definition at line 1271 of file em_lesense.h .

void LESENSE_ScanStart ( void )

Start scanning sensors.

Note
This function will wait for any pending previous write operation to the CMD register to complete before accessing the CMD register. It will also wait for the write operation to the CMD register to complete before returning. Each write operation to the CMD register may take up to 3 LF clock cycles, so expect some delay. The user may implement a separate function to write multiple command bits in the CMD register in one single operation to optimize an application.

Definition at line 1106 of file em_lesense.c .

Referenced by CAPLESENSE_setupLESENSE() , and LESENSE_ScanModeSet() .

void LESENSE_ScanStop ( void )

Stop scanning sensors.

Note
This function will wait for any pending previous write operation to the CMD register to complete before accessing the CMD register. It will also wait for the write operation to the CMD register to complete before returning. Each write operation to the CMD register may take up to 3 LF clock cycles, so the user should expect some delay. The user may implement a separate function to write multiple command bits in the CMD register in one single operation in order to optimize an application.
If issued during a scan, the command takes effect after scan completion.

Definition at line 1138 of file em_lesense.c .

Referenced by CAPLESENSE_setupLESENSE() .

__STATIC_INLINE uint32_t LESENSE_SensorStateGet ( void )

Get the current state of LESENSE sensor.

Returns
Returns the value of LESENSE_SENSORSTATE register that represents the current state of the LESENSE sensor.

Definition at line 1323 of file em_lesense.h .

void LESENSE_StartDelaySet ( uint8_t startDelay )

Set the start delay of the sensor interaction on each channel.

This function sets the start delay of the sensor interaction on each channel. It can be used for adjusting the start delay while running the application but it is also used by LESENSE_Init() for initialization.

Note
Users can configure the start delay by LESENSE_Init() function, but only with a significant overhead. This simple function serves the purpose of controlling this parameter after the channel has been configured. Be aware of the effects of the non-atomic Read-Modify-Write cycle.
Parameters
[in] startDelay A number of LFACLK cycles to delay. A valid range: 0-3 (2 bit).

Definition at line 364 of file em_lesense.c .

Referenced by LESENSE_Init() .

__STATIC_INLINE uint32_t LESENSE_StatusGet ( void )

Get the current status of LESENSE.

Returns
Returns the value of the LESENSE_STATUS register that contains the OR combination of the following status bits:
  • LESENSE_STATUS_RESV - Result data valid. Set when data is available in result buffer. Cleared when buffer is empty.
  • LESENSE_STATUS_RESFULL - Result buffer full. Set when result buffer is full.
  • LESENSE_STATUS_RUNNING - LESENSE is active.
  • LESENSE_STATUS_SCANACTIVE - LESENSE is currently interfacing sensors.

Definition at line 1216 of file em_lesense.h .

Referenced by CAPLESENSE_setupLESENSE() .

__STATIC_INLINE void LESENSE_StatusWait ( uint32_t flag )

Wait until status of LESENSE is equal to what was requested.

Polls LESENSE_STATUS register and waits until requested combination of flags are set.

Parameters
[in] flag The OR combination of the following status bits:
  • LESENSE_STATUS_BUFDATAV - Result data valid. Set when data is available in result buffer. Cleared when buffer is empty.
  • LESENSE_STATUS_BUFHALFFULL - Result buffer half full. Set when result buffer is half full.
  • LESENSE_STATUS_BUFFULL - Result buffer full. Set when result buffer is full.
  • LESENSE_STATUS_RUNNING - LESENSE is active.
  • LESENSE_STATUS_SCANACTIVE - LESENSE is currently interfacing sensors.
  • LESENSE_STATUS_DACACTIVE - The DAC interface is currently active.

Definition at line 1241 of file em_lesense.h .