35 #if defined(LESENSE_COUNT) && (LESENSE_COUNT > 0)
41 #if !defined(UINT32_MAX)
42 #define UINT32_MAX ((uint32_t)(0xFFFFFFFF))
63 #if defined(_LESENSE_ROUTE_MASK)
64 #define GENERIC_LESENSE_ROUTE LESENSE->ROUTE
66 #define GENERIC_LESENSE_ROUTE LESENSE->ROUTEPEN
69 #if defined(_SILICON_LABS_32B_SERIES_0)
71 #define DACOUT_SUPPORT 0xF00F
74 #define DACOUT_SUPPORT 0x34B0
122 #if defined(_LESENSE_PERCTRL_DACPRESC_MASK)
134 #if defined(_LESENSE_TIMCTRL_AUXSTARTUP_MASK)
136 LESENSE->TIMCTRL = (
LESENSE->TIMCTRL & (~_LESENSE_TIMCTRL_AUXSTARTUP_MASK))
172 #if defined(_LESENSE_PERCTRL_DACCH0CONV_MASK)
182 #
if defined(_LESENSE_PERCTRL_ACMP0INV_MASK)
186 #if defined(_LESENSE_PERCTRL_DACCONVTRIG_MASK)
187 | ((uint32_t)init->
perCtrl.dacScan << _LESENSE_PERCTRL_DACCONVTRIG_SHIFT)
250 uint32_t pcPresc = 0UL;
251 uint32_t clkDiv = 1UL;
252 uint32_t pcTop = 63UL;
253 uint32_t calcScanFreq;
266 EFM_ASSERT(refFreq < ((uint32_t)UINT32_MAX / 128UL));
269 EFM_ASSERT((scanFreq > 0U) && (scanFreq <= refFreq));
274 while ((refFreq / ((uint32_t)scanFreq * clkDiv) > (pcTop + 1UL))
278 clkDiv = (uint32_t)1UL << pcPresc;
282 pcTop = ((uint32_t)refFreq / ((uint32_t)scanFreq * clkDiv)) - 1UL;
297 calcScanFreq = ((uint32_t)refFreq / ((uint32_t)(1UL + pcTop) * clkDiv));
340 tmp |= (uint32_t)scanMode;
377 EFM_ASSERT(startDelay < 4U);
521 #if defined(_SILICON_LABS_32B_SERIES_0)
532 EFM_ASSERT((0x1 << chIdx) & DACOUT_SUPPORT);
535 #if defined(_LESENSE_IDLECONF_CH0_DACCH0)
540 && (chIdx != 15U))));
551 tmp = (
LESENSE->IDLECONF & ~((uint32_t)0x3UL << (chIdx * 2UL)));
581 #
if defined(_LESENSE_CH_EVAL_MODE_MASK)
582 | ((uint32_t)confCh->evalMode << _LESENSE_CH_EVAL_MODE_SHIFT)
637 for (i = 0U; i < 8U; ++i)
649 tmp = (
LESENSE->ALTEXCONF & ~((uint32_t)0x3UL << (i * 2UL)));
650 tmp |= ((uint32_t)confAltEx->
AltEx[i].
idleConf << (i * 2UL));
660 #if defined(_LESENSE_CTRL_ALTEXMAP_ACMP)
663 case lesenseAltExMapCH:
666 for (i = 0U; i < 16U; ++i)
750 GENERIC_LESENSE_ROUTE = pinMask;
790 #if defined(_SILICON_LABS_32B_SERIES_0)
845 EFM_ASSERT(acmpThres < 4096U);
851 tmp =
LESENSE->CH[chIdx].INTERACT & ~(0xFFF);
853 tmp |= (uint32_t)acmpThres;
855 LESENSE->CH[chIdx].INTERACT = tmp;
866 #if defined(_LESENSE_CH_EVAL_MODE_MASK)
892 void LESENSE_ChannelSlidingWindow(uint8_t chIdx,
898 LESENSE_WindowSizeSet(windowSize);
901 | LESENSE_CH_EVAL_MODE_SLIDINGWIN;
929 void LESENSE_ChannelStepDetection(uint8_t chIdx,
935 LESENSE_StepSizeSet(stepSize);
938 | LESENSE_CH_EVAL_MODE_STEPDET;
958 void LESENSE_WindowSizeSet(uint32_t windowSize)
960 LESENSE->EVALCTRL = (
LESENSE->EVALCTRL & ~_LESENSE_EVALCTRL_WINSIZE_MASK)
977 void LESENSE_StepSizeSet(uint32_t stepSize)
979 LESENSE_WindowSizeSet(stepSize);
1100 #if defined(_LESENSE_PRSCTRL_MASK)
1115 void LESENSE_DecoderPrsOut(
bool enable, uint32_t decMask, uint32_t decVal)
1117 LESENSE->PRSCTRL = (enable << _LESENSE_PRSCTRL_DECCMPEN_SHIFT)
1118 | (decMask << _LESENSE_PRSCTRL_DECCMPMASK_SHIFT)
1119 | (decVal << _LESENSE_PRSCTRL_DECCMPVAL_SHIFT);
1284 #if defined(_LESENSE_EVALCTRL_MASK)
1285 LESENSE->EVALCTRL = _LESENSE_EVALCTRL_RESETVALUE;
1286 LESENSE->PRSCTRL = _LESENSE_PRSCTRL_RESETVALUE;
1293 #if defined(_LESENSE_ROUTE_MASK)
1296 LESENSE->ROUTEPEN = _LESENSE_ROUTEPEN_RESETVALUE;
#define _LESENSE_CH_EVAL_STRSAMPLE_SHIFT
Clock management unit (CMU) API.
#define LESENSE_CMD_DECODE
LESENSE_PRSSel_TypeDef prsChSel3
LESENSE_TimeCtrlDesc_TypeDef timeCtrl
void LESENSE_AltExConfig(const LESENSE_ConfAltEx_TypeDef *confAltEx)
Configure the LESENSE alternate excitation modes.
LESENSE_ControlACMP_TypeDef acmp1Mode
#define LESENSE_NUM_CHANNELS
#define _LESENSE_ST_TCONFA_RESETVALUE
#define _LESENSE_CH_INTERACT_ALTEX_SHIFT
#define _LESENSE_CTRL_BUFOW_SHIFT
void LESENSE_DecoderStart(void)
Start LESENSE decoder.
Emlib peripheral API "assert" implementation.
LESENSE_ControlDACData_TypeDef dacCh0Data
#define _LESENSE_ST_TCONFB_NEXTSTATE_SHIFT
LESENSE_DecStCond_TypeDef confA
RAM and peripheral bit-field set and clear API.
LESENSE_DecCtrlDesc_TypeDef decCtrl
LESENSE_ControlDACData_TypeDef dacCh1Data
LESENSE_ChPinIdleMode_TypeDef chPinIdleMode
void LESENSE_Init(const LESENSE_Init_TypeDef *init, bool reqReset)
Initialize the LESENSE module.
LESENSE_ChDesc_TypeDef Ch[LESENSE_NUM_CHANNELS]
void LESENSE_Reset(void)
Reset the LESENSE module.
#define _LESENSE_CHEN_RESETVALUE
#define LESENSE_CMD_CLEARBUF
void LESENSE_ResultBufferClear(void)
Clear result buffer.
void LESENSE_ChannelThresSet(uint8_t chIdx, uint16_t acmpThres, uint16_t cntThres)
Set LESENSE channel threshold parameters.
#define _LESENSE_CTRL_DEBUGRUN_SHIFT
#define _LESENSE_ST_TCONFA_NEXTSTATE_SHIFT
#define _LESENSE_TIMCTRL_LFPRESC_MASK
void LESENSE_ScanModeSet(LESENSE_ScanMode_TypeDef scanMode, bool start)
Set scan mode of the LESENSE channels.
LESENSE_AltExDesc_TypeDef AltEx[16]
LESENSE_CH EFM32GG LESENSE CH.
LESENSE_PRSSel_TypeDef prsChSel0
#define _LESENSE_ST_TCONFA_SETIF_SHIFT
#define _LESENSE_CH_INTERACT_EXCLK_SHIFT
#define _LESENSE_CH_EVAL_COMPTHRES_MASK
LESENSE_ControlDACOut_TypeDef dacCh0OutMode
#define _LESENSE_TIMCTRL_PCPRESC_SHIFT
#define _LESENSE_CTRL_PRSSEL_SHIFT
void LESENSE_DecoderStateSet(uint32_t decSt)
Set LESENSE decoder state.
#define _LESENSE_CTRL_ALTEXMAP_SHIFT
#define _LESENSE_DECCTRL_PRSSEL2_SHIFT
#define LESENSE_SYNCBUSY_CMD
#define _LESENSE_PERCTRL_ACMP1MODE_SHIFT
LESENSE_PRSSel_TypeDef prsSel
LESENSE_DecStDesc_TypeDef St[LESENSE_NUM_DECODER_STATES]
#define _LESENSE_ALTEXCONF_RESETVALUE
LESENSE_ChClk_TypeDef exClk
#define _LESENSE_CH_TIMING_SAMPLEDLY_SHIFT
#define _LESENSE_CTRL_DUALSAMPLE_SHIFT
#define _LESENSE_ST_TCONFB_COMP_SHIFT
#define _LESENSE_IFC_MASK
#define _LESENSE_IEN_RESETVALUE
void LESENSE_ChannelTimingSet(uint8_t chIdx, uint8_t exTime, uint8_t sampleDelay, uint16_t measDelay)
Set LESENSE channel timing parameters.
#define _LESENSE_ST_TCONFA_MASK_SHIFT
#define _LESENSE_DECCTRL_ERRCHK_SHIFT
uint32_t LESENSE_ScanFreqSet(uint32_t refFreq, uint32_t scanFreq)
Set scan frequency for periodic scanning.
#define LESENSE_CMD_START
#define _LESENSE_CH_TIMING_EXTIME_MASK
#define _LESENSE_DECCTRL_HYSTPRS1_SHIFT
#define _LESENSE_PERCTRL_DACCH1DATA_SHIFT
LESENSE_DMAWakeUp_TypeDef wakeupOnDMA
#define _LESENSE_CTRL_SCANMODE_MASK
LESENSE_ControlDACConv_TypeDef dacCh1ConvMode
#define _LESENSE_ST_TCONFA_CHAIN_SHIFT
#define _LESENSE_TIMCTRL_AUXPRESC_MASK
#define _LESENSE_CH_TIMING_SAMPLEDLY_MASK
#define _LESENSE_DECCTRL_INTMAP_SHIFT
#define _LESENSE_TIMCTRL_PCTOP_MASK
#define _LESENSE_CH_INTERACT_RESETVALUE
LESENSE_ChCompMode_TypeDef compMode
void LESENSE_ClkDivSet(LESENSE_ChClk_TypeDef clk, LESENSE_ClkPresc_TypeDef clkDiv)
Set clock division for LESENSE timers.
#define _LESENSE_TIMCTRL_PCTOP_SHIFT
#define _LESENSE_IDLECONF_RESETVALUE
LESENSE_PRSSel_TypeDef prsChSel2
#define _LESENSE_ST_TCONFB_MASK_SHIFT
#define LESENSE_NUM_DECODER_STATES
LESENSE_DACRef_TypeDef dacRef
#define _LESENSE_PERCTRL_DACCH1OUT_SHIFT
void LESENSE_ChannelAllConfig(const LESENSE_ChAll_TypeDef *confChAll)
Configure all (16) LESENSE sensor channels.
#define _LESENSE_DECCTRL_HYSTIRQ_SHIFT
#define _LESENSE_TIMCTRL_LFPRESC_SHIFT
#define _LESENSE_CH_TIMING_MEASUREDLY_SHIFT
#define _LESENSE_DECCTRL_PRSSEL3_SHIFT
LESENSE_PerCtrlDesc_TypeDef perCtrl
#define _LESENSE_CTRL_ACMP0INV_MASK
void LESENSE_ChannelConfig(const LESENSE_ChDesc_TypeDef *confCh, uint32_t chIdx)
Configure a single LESENSE sensor channel.
#define _LESENSE_TIMCTRL_STARTDLY_MASK
LESENSE_ScanConfSel_TypeDef scanConfSel
uint32_t LESENSE_DecoderStateGet(void)
Get the current state of the LESENSE decoder.
#define _LESENSE_CTRL_ACMP0INV_SHIFT
#define _LESENSE_DECCTRL_HYSTPRS0_SHIFT
LESENSE_ControlACMP_TypeDef acmp0Mode
void LESENSE_ChannelEnable(uint8_t chIdx, bool enaScanCh, bool enaPin)
Enable/disable LESENSE scan channel and the pin assigned to it.
#define _LESENSE_PERCTRL_ACMP0MODE_SHIFT
#define _LESENSE_PERCTRL_DACCH1CONV_SHIFT
#define _LESENSE_DECCTRL_PRSSEL1_SHIFT
LESENSE_ControlDACConv_TypeDef dacCh0ConvMode
LESENSE_ControlDACOut_TypeDef dacCh1OutMode
#define _LESENSE_CH_EVAL_SCANRESINV_SHIFT
#define _LESENSE_CH_EVAL_DECODE_SHIFT
LESENSE_DecStCond_TypeDef confB
LESENSE_ChClk_TypeDef sampleClk
LESENSE_CoreCtrlDesc_TypeDef coreCtrl
LESENSE_ScanMode_TypeDef scanStart
#define _LESENSE_CH_TIMING_RESETVALUE
#define _LESENSE_TIMCTRL_AUXPRESC_SHIFT
#define _LESENSE_PERCTRL_DACCH0DATA_SHIFT
LESENSE_AltExMap_TypeDef altExMap
#define _LESENSE_CTRL_ACMP1INV_SHIFT
#define _LESENSE_DECCTRL_PRSSEL0_SHIFT
#define _LESENSE_PERCTRL_DACCH0CONV_SHIFT
#define _LESENSE_CH_EVAL_COMPTHRES_SHIFT
void LESENSE_DecoderStateConfig(const LESENSE_DecStDesc_TypeDef *confDecSt, uint32_t decSt)
Configure a single LESENSE decoder state.
#define _LESENSE_PERCTRL_DACCH0OUT_SHIFT
#define _LESENSE_BIASCTRL_RESETVALUE
#define _LESENSE_CH_EVAL_RESETVALUE
LESENSE_DecInput_TypeDef decInput
#define _LESENSE_CTRL_RESETVALUE
#define _LESENSE_CH_INTERACT_SAMPLECLK_SHIFT
#define _LESENSE_TIMCTRL_STARTDLY_SHIFT
Low Energy Sensor (LESENSE) peripheral API.
LESENSE_WarmupMode_TypeDef warmupMode
LESENSE_StTransAct_TypeDef prsAct
LESENSE_BiasMode_TypeDef biasMode
LESENSE_AltExPinIdle_TypeDef idleConf
#define _LESENSE_PERCTRL_DACPRESC_SHIFT
void LESENSE_ChannelEnableMask(uint16_t chMask, uint16_t pinMask)
Enable/disable LESENSE scan channel and the pin assigned to it.
__STATIC_INLINE void BUS_RegBitWrite(volatile uint32_t *addr, unsigned int bit, unsigned int val)
Perform a single-bit write operation on a peripheral register.
void LESENSE_StartDelaySet(uint8_t startDelay)
Set start delay of sensor interaction on each channel.
void LESENSE_ScanStart(void)
Start scanning of sensors.
#define _LESENSE_DECCTRL_RESETVALUE
#define _LESENSE_ST_TCONFA_COMP_SHIFT
void LESENSE_ScanStop(void)
Stop scanning of sensors.
#define _LESENSE_TIMCTRL_PCPRESC_MASK
uint32_t CMU_ClockFreqGet(CMU_Clock_TypeDef clock)
Get clock frequency for a clock point.
#define _LESENSE_ROUTE_RESETVALUE
#define _LESENSE_PERCTRL_RESETVALUE
#define LESENSE_DECCTRL_DISABLE
#define _LESENSE_ST_TCONFB_SETIF_SHIFT
#define _LESENSE_DECCTRL_PRSCNT_SHIFT
#define _LESENSE_CTRL_STRSCANRES_SHIFT
#define _LESENSE_DECCTRL_HYSTPRS2_SHIFT
#define _LESENSE_CH_TIMING_MEASUREDLY_MASK
LESENSE_ChIntMode_TypeDef intMode
LESENSE_ChPinExMode_TypeDef chPinExMode
LESENSE_BufTrigLevel_TypeDef bufTrigLevel
LESENSE_PRSSel_TypeDef prsChSel1
#define _LESENSE_ST_TCONFB_RESETVALUE
LESENSE_ChSampleMode_TypeDef sampleMode
#define _LESENSE_CH_TIMING_EXTIME_SHIFT
#define _LESENSE_DECSTATE_DECSTATE_MASK
void LESENSE_DecoderStateAllConfig(const LESENSE_DecStAll_TypeDef *confDecStAll)
Configure all LESENSE decoder states.