LESENSE - Low Energy Sensor

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_CoreCtrlDesc_TypeDef
 Core control (LESENSE_CTRL/CFG) descriptor structure.
 
struct  LESENSE_TimeCtrlDesc_TypeDef
 LESENSE timing control descriptor structure.
 
struct  LESENSE_PerCtrlDesc_TypeDef
 LESENSE peripheral control descriptor structure.
 
struct  LESENSE_DecCtrlDesc_TypeDef
 LESENSE decoder control descriptor structure.
 
struct  LESENSE_Init_TypeDef
 LESENSE module initialization structure.
 
struct  LESENSE_ChDesc_TypeDef
 Channel descriptor structure.
 
struct  LESENSE_ChAll_TypeDef
 Configuration structure for all the scan channels.
 
struct  LESENSE_AltExDesc_TypeDef
 Alternate excitation descriptor structure.
 
struct  LESENSE_ConfAltEx_TypeDef
 Configuration structure for the alternate excitation.
 
struct  LESENSE_DecStCond_TypeDef
 Decoder state condition descriptor structure.
 
struct  LESENSE_DecStDesc_TypeDef
 Decoder state x configuration structure.
 
struct  LESENSE_DecStAll_TypeDef
 Configuration structure for decoder.
 

Functions

void LESENSE_Init (const LESENSE_Init_TypeDef *init, bool reqReset)
 Initialize the LESENSE module.
 
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.
 
void LESENSE_StartDelaySet (uint8_t startDelay)
 Set the start delay of the sensor interaction on each channel.
 
void LESENSE_ClkDivSet (LESENSE_ChClk_TypeDef clk, LESENSE_ClkPresc_TypeDef clkDiv)
 Set the clock division for LESENSE timers.
 
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_AltExConfig (const LESENSE_ConfAltEx_TypeDef *confAltEx)
 Configure the LESENSE alternate excitation modes.
 
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_ChannelTimingSet (uint8_t chIdx, uint8_t exTime, uint8_t sampleDelay, uint16_t measDelay)
 Set LESENSE channel timing parameters.
 
void LESENSE_ChannelThresSet (uint8_t chIdx, uint16_t acmpThres, uint16_t cntThres)
 Set LESENSE channel threshold parameters.
 
void LESENSE_ChannelSlidingWindow (uint8_t chIdx, uint32_t windowSize, uint32_t initValue)
 Configure a Sliding Window evaluation mode for a specific channel.
 
void LESENSE_ChannelStepDetection (uint8_t chIdx, uint32_t stepSize, uint32_t initValue)
 Configure the step detection evaluation mode for a specific channel.
 
void LESENSE_WindowSizeSet (uint32_t windowSize)
 Set the window size for all LESENSE channels.
 
void LESENSE_StepSizeSet (uint32_t stepSize)
 Set the step size for all LESENSE channels.
 
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.
 
void LESENSE_DecoderStateSet (uint32_t decSt)
 Set the LESENSE decoder state.
 
uint32_t LESENSE_DecoderStateGet (void)
 Get the current state of the LESENSE decoder.
 
void LESENSE_DecoderPrsOut (bool enable, uint32_t decMask, uint32_t decVal)
 Enable or disable the PRS output from the LESENSE decoder.
 
void LESENSE_ScanStart (void)
 Start scanning sensors.
 
void LESENSE_ScanStop (void)
 Stop scanning sensors.
 
void LESENSE_DecoderStart (void)
 Start the LESENSE decoder.
 
void LESENSE_ResultBufferClear (void)
 Clear the result buffer.
 
void LESENSE_Reset (void)
 Reset the LESENSE module.
 
void LESENSE_DecoderStop (void)
 Stop LESENSE decoder.
 
uint32_t LESENSE_StatusGet (void)
 Get the current status of LESENSE.
 
void LESENSE_StatusWait (uint32_t flag)
 Wait until status of LESENSE is equal to what was requested.
 
uint32_t LESENSE_ChannelActiveGet (void)
 Get the currently active channel index.
 
uint32_t LESENSE_ScanResultGet (void)
 Get the latest scan comparison result (1 bit / channel).
 
uint32_t LESENSE_ScanResultDataGet (void)
 Get the oldest unread data from the result buffer.
 
uint32_t LESENSE_ScanResultDataBufferGet (uint32_t idx)
 Get data from the result data buffer.
 
uint32_t LESENSE_SensorStateGet (void)
 Get the current state of the LESENSE sensor.
 
void LESENSE_IntClear (uint32_t flags)
 Clear one or more pending LESENSE interrupts.
 
void LESENSE_IntEnable (uint32_t flags)
 Enable one or more LESENSE interrupts.
 
void LESENSE_IntDisable (uint32_t flags)
 Disable one or more LESENSE interrupts.
 
void LESENSE_IntSet (uint32_t flags)
 Set one or more pending LESENSE interrupts from SW.
 
uint32_t LESENSE_IntGet (void)
 Get pending LESENSE interrupt flags.
 
uint32_t LESENSE_IntGetEnabled (void)
 Get enabled and pending LESENSE interrupt flags.
 

Macros

#define LESENSE_NUM_DECODER_STATES   (_LESENSE_DECSTATE_DECSTATE_MASK + 1)
 Number of decoder states supported by current device.
 
#define LESENSE_NUM_CHANNELS   16
 Number of LESENSE channels.
 
#define LESENSE_CORECTRL_DESC_DEFAULT
 Default configuration for LESENSE_CtrlDesc_TypeDef structure.
 
#define LESENSE_TIMECTRL_DESC_DEFAULT
 Default configuration for LESENSE_TimeCtrlDesc_TypeDef structure.
 
#define LESENSE_PERCTRL_DESC_DEFAULT
 Default configuration for LESENSE_PerCtrl_TypeDef structure.
 
#define LESENSE_DECCTRL_DESC_DEFAULT
 Default configuration for LESENSE_PerCtrl_TypeDef structure.
 
#define LESENSE_INIT_DEFAULT
 Default configuration for LESENSE_Init_TypeDef structure.
 
#define LESENSE_CH_CONF_DEFAULT
 Default configuration for the scan channel.
 
#define LESENSE_SCAN_CONF_DEFAULT
 Default configuration for all the sensor channels.
 
#define LESENSE_ALTEX_CH_CONF_DEFAULT
 Default configuration for the alternate excitation channel.
 
#define LESENSE_ALTEX_CONF_DEFAULT
 Default configuration for all the alternate excitation channels.
 
#define LESENSE_ST_CONF_DEFAULT
 Default configuration for the decoder state condition.
 
#define LESENSE_DECODER_CONF_DEFAULT
 Default configuration for all decoder states.
 

Enumerations

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
}
 Clock divisors for controlling the prescaling factor of the period counter.
 
enum  LESENSE_ScanMode_TypeDef {
  lesenseScanStartPeriodic = LESENSE_CTRL_SCANMODE_PERIODIC,
  lesenseScanStartOneShot = LESENSE_CTRL_SCANMODE_ONESHOT,
  lesenseScanStartPRS = LESENSE_CTRL_SCANMODE_PRS
}
 Scan modes.
 
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
}
 PRS sources.
 
enum  LESENSE_AltExMap_TypeDef {
  lesenseAltExMapALTEX = _LESENSE_CTRL_ALTEXMAP_ALTEX,
  lesenseAltExMapCH = _LESENSE_CTRL_ALTEXMAP_CH
}
 Locations of the alternate excitation function.
 
enum  LESENSE_BufTrigLevel_TypeDef {
  lesenseBufTrigHalf = LESENSE_CTRL_BUFIDL_HALFFULL,
  lesenseBufTrigFull = LESENSE_CTRL_BUFIDL_FULL
}
 Result buffer interrupt and DMA trigger levels.
 
enum  LESENSE_DMAWakeUp_TypeDef {
  lesenseDMAWakeUpDisable = LESENSE_CTRL_DMAWU_DISABLE,
  lesenseDMAWakeUpBufValid = LESENSE_CTRL_DMAWU_BUFDATAV,
  lesenseDMAWakeUpBufLevel = LESENSE_CTRL_DMAWU_BUFLEVEL
}
 Modes of operation for DMA wakeup from EM2.
 
enum  LESENSE_BiasMode_TypeDef {
  lesenseBiasModeDutyCycle = LESENSE_BIASCTRL_BIASMODE_DUTYCYCLE,
  lesenseBiasModeHighAcc = LESENSE_BIASCTRL_BIASMODE_HIGHACC,
  lesenseBiasModeDontTouch = LESENSE_BIASCTRL_BIASMODE_DONTTOUCH
}
 Bias modes.
 
enum  LESENSE_ScanConfSel_TypeDef {
  lesenseScanConfDirMap = LESENSE_CTRL_SCANCONF_DIRMAP,
  lesenseScanConfInvMap = LESENSE_CTRL_SCANCONF_INVMAP,
  lesenseScanConfToggle = LESENSE_CTRL_SCANCONF_TOGGLE,
  lesenseScanConfDecDef = LESENSE_CTRL_SCANCONF_DECDEF
}
 Scan configuration.
 
enum  LESENSE_ControlDACData_TypeDef {
  lesenseDACIfData = _LESENSE_PERCTRL_DACCH0DATA_DACDATA,
  lesenseThres = _LESENSE_PERCTRL_DACCH0DATA_THRES
}
 DAC CHx data control configuration.
 
enum  LESENSE_ControlACMP_TypeDef {
  lesenseACMPModeDisable = _LESENSE_PERCTRL_ACMP0MODE_DISABLE,
  lesenseACMPModeMux = _LESENSE_PERCTRL_ACMP0MODE_MUX,
  lesenseACMPModeMuxThres = _LESENSE_PERCTRL_ACMP0MODE_MUXTHRES
}
 ACMPx control configuration.
 
enum  LESENSE_WarmupMode_TypeDef {
  lesenseWarmupModeNormal = LESENSE_PERCTRL_WARMUPMODE_NORMAL,
  lesenseWarmupModeACMP = LESENSE_PERCTRL_WARMUPMODE_KEEPACMPWARM,
  lesenseWarmupModeDAC = LESENSE_PERCTRL_WARMUPMODE_KEEPDACWARM,
  lesenseWarmupModeKeepWarm = LESENSE_PERCTRL_WARMUPMODE_KEEPACMPDACWARM
}
 Warm up modes.
 
enum  LESENSE_DecInput_TypeDef {
  lesenseDecInputSensorSt = LESENSE_DECCTRL_INPUT_SENSORSTATE,
  lesenseDecInputPRS = LESENSE_DECCTRL_INPUT_PRS
}
 Decoder input source configuration.
 
enum  LESENSE_ChSampleMode_TypeDef {
  lesenseSampleModeCounter = 0x0 << _LESENSE_CH_INTERACT_SAMPLE_SHIFT,
  lesenseSampleModeACMP = LESENSE_CH_INTERACT_SAMPLE_ACMP,
  lesenseSampleModeADC = LESENSE_CH_INTERACT_SAMPLE_ADC,
  lesenseSampleModeADCDiff = LESENSE_CH_INTERACT_SAMPLE_ADCDIFF
}
 Compare source selection for sensor sampling.
 
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,
  lesenseSetIntBothEdges = LESENSE_CH_INTERACT_SETIF_BOTHEDGES
}
 Interrupt generation setup for CHx interrupt flag.
 
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
}
 Channel pin mode for the excitation phase of the scan sequence.
 
enum  LESENSE_ChPinIdleMode_TypeDef {
  lesenseChPinIdleDis = _LESENSE_IDLECONF_CH0_DISABLE,
  lesenseChPinIdleHigh = _LESENSE_IDLECONF_CH0_HIGH,
  lesenseChPinIdleLow = _LESENSE_IDLECONF_CH0_LOW,
  lesenseChPinIdleDACC = _LESENSE_IDLECONF_CH0_DAC
}
 Channel pin mode for the idle phase of scan sequence.
 
enum  LESENSE_ChClk_TypeDef {
  lesenseClkLF = _LESENSE_CH_INTERACT_EXCLK_LFACLK,
  lesenseClkHF = _LESENSE_CH_INTERACT_EXCLK_AUXHFRCO
}
 Clock used for excitation and sample delay timing.
 
enum  LESENSE_ChCompMode_TypeDef {
  lesenseCompModeLess = LESENSE_CH_EVAL_COMP_LESS,
  lesenseCompModeGreaterOrEq = LESENSE_CH_EVAL_COMP_GE
}
 Compare modes for counter comparison.
 
enum  LESENSE_ChEvalMode_TypeDef {
  lesenseEvalModeThreshold = _LESENSE_CH_EVAL_MODE_THRES,
  lesenseEvalModeSlidingWindow = _LESENSE_CH_EVAL_MODE_SLIDINGWIN,
  lesenseEvalModeStepDetection = _LESENSE_CH_EVAL_MODE_STEPDET
}
 Sensor evaluation modes.
 
enum  LESENSE_AltExPinIdle_TypeDef {
  lesenseAltExPinIdleDis = _LESENSE_ALTEXCONF_IDLECONF0_DISABLE,
  lesenseAltExPinIdleHigh = _LESENSE_ALTEXCONF_IDLECONF0_HIGH,
  lesenseAltExPinIdleLow = _LESENSE_ALTEXCONF_IDLECONF0_LOW
}
 Idle phase configuration of the alternate excitation channels.
 
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
}
 Transition action modes.
 

Function Documentation

◆ LESENSE_Init()

void LESENSE_Init ( const LESENSE_Init_TypeDef init,
bool  reqReset 
)