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) 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 result buffer.
|
|
uint32_t | LESENSE_ScanResultDataBufferGet (uint32_t idx) |
Get the data from result data buffer.
|
|
uint32_t | LESENSE_SensorStateGet (void) |
Get the current state of 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 } |
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 } |
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
|
||
) |
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.
◆ LESENSE_ScanFreqSet()
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.
◆ LESENSE_ScanModeSet()
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.
◆ LESENSE_StartDelaySet()
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).
◆ LESENSE_ClkDivSet()
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.
◆ LESENSE_ChannelAllConfig()
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.
◆ LESENSE_ChannelConfig()
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).
◆ LESENSE_AltExConfig()
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.
◆ LESENSE_ChannelEnable()
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
.
◆ LESENSE_ChannelEnableMask()
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.
◆ LESENSE_ChannelTimingSet()
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).
◆ LESENSE_ChannelThresSet()
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).
◆ LESENSE_ChannelSlidingWindow()
void LESENSE_ChannelSlidingWindow | ( | uint8_t |
chIdx,
|
uint32_t |
windowSize,
|
||
uint32_t |
initValue
|
||
) |
Configure a Sliding Window evaluation mode for a specific channel.
This function will configure the evaluation mode, the initial sensor measurement (COMPTHRES), and the window size. For other channel-related configuration, see the LESENSE_ChannelConfig() function.
- Warning
- Note that the step size and window size configuration are global to all LESENSE channels and use the same register field in the hardware. This means that any windowSize configuration passed to this function will apply for all channels and override all other stepSize/windowSize configurations.
- Parameters
-
[in] chIdx
An identifier of the scan channel. A valid range is 0-15. [in] windowSize
A window size to be used on all channels. [in] initValue
The initial sensor value for the channel.
◆ LESENSE_ChannelStepDetection()
void LESENSE_ChannelStepDetection | ( | uint8_t |
chIdx,
|
uint32_t |
stepSize,
|
||
uint32_t |
initValue
|
||
) |
Configure the step detection evaluation mode for a specific channel.
This function will configure the evaluation mode, the initial sensor measurement (COMPTHRES) and the window size. For other channel-related configuration, see the LESENSE_ChannelConfig() function.
- Warning
- Note that the step size and window size configuration are global to all LESENSE channels and use the same register field in the hardware. This means that any stepSize configuration passed to this function will apply for all channels and override all other stepSize/windowSize configurations.
- Parameters
-
[in] chIdx
An identifier of the scan channel. A valid range is 0-15. [in] stepSize
A step size to be used on all channels. [in] initValue
The initial sensor value for the channel.
◆ LESENSE_WindowSizeSet()
void LESENSE_WindowSizeSet | ( | uint32_t |
windowSize
|
) |
Set the window size for all LESENSE channels.
The window size is used by all channels that are configured as lesenseEvalModeSlidingWindow .
- Warning
- The window size configuration is using the same register field as the step detection size. As a result, the window size configuration will have an effect on channels configured with the lesenseEvalModeStepDetection evaluation mode as well.
- Parameters
-
[in] windowSize
The window size to use for all channels.
◆ LESENSE_StepSizeSet()
void LESENSE_StepSizeSet | ( | uint32_t |
stepSize
|
) |
Set the step size for all LESENSE channels.
The step size is configured using the same register field as used to configure window size. Therefore, calling this function will overwrite any previously configured window size as done by the LESENSE_WindowSizeSet() function.
- Parameters
-
[in] stepSize
The step size to use for all channels.
◆ LESENSE_DecoderStateAllConfig()
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.
◆ LESENSE_DecoderStateConfig()
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.
◆ LESENSE_DecoderStateSet()
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.
◆ LESENSE_DecoderStateGet()
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.
◆ LESENSE_DecoderPrsOut()
void LESENSE_DecoderPrsOut | ( | bool |
enable,
|
uint32_t |
decMask,
|
||
uint32_t |
decVal
|
||
) |
Enable or disable the PRS output from the LESENSE decoder.
- Parameters
-
[in] enable
Enable/disable the PRS output from the LESENSE decoder. True to enable and false to disable. [in] decMask
A decoder state compare value mask. [in] decVal
A decoder state comparison value.
◆ LESENSE_ScanStart()
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.
◆ LESENSE_ScanStop()
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.
◆ LESENSE_DecoderStart()
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.
◆ LESENSE_ResultBufferClear()
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.
◆ LESENSE_Reset()
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() .
◆ LESENSE_DecoderStop()
|
inline |
Stop LESENSE decoder.
Disables LESENSE decoder by setting the command to LESENSE_DECCTRL register.
◆ LESENSE_StatusGet()
|
inline |
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.
◆ LESENSE_StatusWait()
|
inline |
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.
◆ LESENSE_ChannelActiveGet()
|
inline |
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).
◆ LESENSE_ScanResultGet()
|
inline |
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.
◆ LESENSE_ScanResultDataGet()
|
inline |
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.
◆ LESENSE_ScanResultDataBufferGet()
|
inline |
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.
◆ LESENSE_SensorStateGet()
|
inline |
Get the current state of LESENSE sensor.
- Returns
- Returns the value of LESENSE_SENSORSTATE register that represents the current state of the LESENSE sensor.
◆ LESENSE_IntClear()
|
inline |
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).
◆ LESENSE_IntEnable()
|
inline |
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).
◆ LESENSE_IntDisable()
|
inline |
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).
◆ LESENSE_IntSet()
|
inline |
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).
◆ LESENSE_IntGet()
|
inline |
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).
◆ LESENSE_IntGetEnabled()
|
inline |
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).
Macro Definition Documentation
◆ LESENSE_NUM_DECODER_STATES
#define LESENSE_NUM_DECODER_STATES (_LESENSE_DECSTATE_DECSTATE_MASK + 1) |
Number of decoder states supported by current device.
◆ LESENSE_NUM_CHANNELS
#define LESENSE_NUM_CHANNELS 16 |
Number of LESENSE channels.
◆ LESENSE_CORECTRL_DESC_DEFAULT
#define LESENSE_CORECTRL_DESC_DEFAULT |
Default configuration for LESENSE_CtrlDesc_TypeDef structure.
◆ LESENSE_TIMECTRL_DESC_DEFAULT
#define LESENSE_TIMECTRL_DESC_DEFAULT |
Default configuration for LESENSE_TimeCtrlDesc_TypeDef structure.
◆ LESENSE_PERCTRL_DESC_DEFAULT
#define LESENSE_PERCTRL_DESC_DEFAULT |
Default configuration for LESENSE_PerCtrl_TypeDef structure.
◆ LESENSE_DECCTRL_DESC_DEFAULT
#define LESENSE_DECCTRL_DESC_DEFAULT |
Default configuration for LESENSE_PerCtrl_TypeDef structure.
◆ LESENSE_INIT_DEFAULT
#define LESENSE_INIT_DEFAULT |
Default configuration for LESENSE_Init_TypeDef structure.
◆ LESENSE_CH_CONF_DEFAULT
#define LESENSE_CH_CONF_DEFAULT |
Default configuration for the scan channel.
◆ LESENSE_SCAN_CONF_DEFAULT
#define LESENSE_SCAN_CONF_DEFAULT |
Default configuration for all the sensor channels.
◆ LESENSE_ALTEX_CH_CONF_DEFAULT
#define LESENSE_ALTEX_CH_CONF_DEFAULT |
Default configuration for the alternate excitation channel.
◆ LESENSE_ALTEX_CONF_DEFAULT
#define LESENSE_ALTEX_CONF_DEFAULT |
Default configuration for all the alternate excitation channels.
◆ LESENSE_ST_CONF_DEFAULT
#define LESENSE_ST_CONF_DEFAULT |
Default configuration for the decoder state condition.
◆ LESENSE_DECODER_CONF_DEFAULT
#define LESENSE_DECODER_CONF_DEFAULT |
Default configuration for all decoder states.
Enumeration Type Documentation
◆ LESENSE_ClkPresc_TypeDef
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).
◆ LESENSE_ScanMode_TypeDef
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. |
◆ LESENSE_PRSSel_TypeDef
PRS sources.
Note: These enumeration values are being used for different PRS related configuration parameters.
◆ LESENSE_AltExMap_TypeDef
◆ LESENSE_BufTrigLevel_TypeDef
◆ LESENSE_DMAWakeUp_TypeDef
Modes of operation for DMA wakeup from EM2.
◆ LESENSE_BiasMode_TypeDef
◆ LESENSE_ScanConfSel_TypeDef
Scan configuration.
◆ LESENSE_ControlDACData_TypeDef
DAC CHx data control configuration.
◆ LESENSE_ControlACMP_TypeDef
ACMPx control configuration.
◆ LESENSE_WarmupMode_TypeDef
Warm up modes.
ACMP and DAC duty cycle mode configuration.
◆ LESENSE_DecInput_TypeDef
◆ LESENSE_ChSampleMode_TypeDef
Compare source selection for sensor sampling.
◆ LESENSE_ChIntMode_TypeDef
Interrupt generation setup for CHx interrupt flag.
◆ LESENSE_ChPinExMode_TypeDef
Channel pin mode for the excitation phase of the scan sequence.
◆ LESENSE_ChPinIdleMode_TypeDef
Channel pin mode for the idle phase of scan sequence.
◆ LESENSE_ChClk_TypeDef
◆ LESENSE_ChCompMode_TypeDef
Compare modes for counter comparison.
◆ LESENSE_ChEvalMode_TypeDef
Sensor evaluation modes.
Enumerator | |
---|---|
lesenseEvalModeThreshold |
Threshold comparison evaluation mode. In this mode, sensor data is compared to the configured threshold value. Two possible comparison operators can be used on sensor data, either >= (GE) or < (LT). Which operator to use is given using the LESENSE_ChDesc_TypeDef::compMode member. |
lesenseEvalModeSlidingWindow |
Sliding window evaluation mode. In this mode, sensor data is evaluated against upper and lower limits of a window range. The windows range is defined by a base value and a window size. |
lesenseEvalModeStepDetection |
Step detection evaluation mode. In this mode, the sensor data is compared to the sensor data from the previous measurement. Sensor evaluation will result in a "1" if the difference between current measurement and previous one is greater than a configurable "step size". If the difference is less than the configured step size then sensor evaluation will result in a "0". |
◆ LESENSE_AltExPinIdle_TypeDef
Idle phase configuration of the alternate excitation channels.
◆ LESENSE_StTransAct_TypeDef
Transition action modes.