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)
123 EFM_ASSERT((uint32_t)init->
perCtrl.dacPresc < 32U);
134 #if defined(_LESENSE_TIMCTRL_AUXSTARTUP_MASK)
152 #
if defined(_LESENSE_CTRL_ACMP0INV_MASK)
172 #if defined(_LESENSE_PERCTRL_DACCH0CONV_MASK)
173 | ((uint32_t)init->
perCtrl.dacCh0ConvMode << _LESENSE_PERCTRL_DACCH0CONV_SHIFT)
174 | ((uint32_t)init->
perCtrl.dacCh0OutMode << _LESENSE_PERCTRL_DACCH0OUT_SHIFT)
175 | ((uint32_t)init->
perCtrl.dacCh1ConvMode << _LESENSE_PERCTRL_DACCH1CONV_SHIFT)
176 | ((uint32_t)init->
perCtrl.dacCh1OutMode << _LESENSE_PERCTRL_DACCH1OUT_SHIFT)
177 | ((uint32_t)init->
perCtrl.dacPresc << _LESENSE_PERCTRL_DACPRESC_SHIFT)
178 | (uint32_t)init->
perCtrl.dacRef
186 #if defined(_LESENSE_PERCTRL_DACCONVTRIG_MASK)
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)));
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)
661 case lesenseAltExMapACMP:
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)
1100 #if defined(_LESENSE_PRSCTRL_MASK)
1284 #if defined(_LESENSE_EVALCTRL_MASK)
1293 #if defined(_LESENSE_ROUTE_MASK)
1294 LESENSE->ROUTE = _LESENSE_ROUTE_RESETVALUE;
Clock management unit (CMU) API.
#define _LESENSE_CH_TIMING_EXTIME_SHIFT
#define _LESENSE_IDLECONF_RESETVALUE
#define _LESENSE_CTRL_RESETVALUE
#define _LESENSE_CTRL_PRSSEL_SHIFT
LESENSE_PRSSel_TypeDef prsChSel3
LESENSE_TimeCtrlDesc_TypeDef timeCtrl
#define _LESENSE_TIMCTRL_LFPRESC_SHIFT
void LESENSE_AltExConfig(const LESENSE_ConfAltEx_TypeDef *confAltEx)
Configure the LESENSE alternate excitation modes.
LESENSE_ControlACMP_TypeDef acmp1Mode
#define LESENSE_NUM_CHANNELS
#define _LESENSE_CH_EVAL_MODE_MASK
void LESENSE_DecoderStart(void)
Start LESENSE decoder.
Emlib peripheral API "assert" implementation.
#define _LESENSE_TIMCTRL_LFPRESC_MASK
LESENSE_ControlDACData_TypeDef dacCh0Data
#define _LESENSE_DECCTRL_HYSTIRQ_SHIFT
LESENSE_DecStCond_TypeDef confA
#define _LESENSE_ST_TCONFA_NEXTSTATE_SHIFT
#define _LESENSE_PERCTRL_ACMP1MODE_SHIFT
#define _LESENSE_CH_EVAL_RESETVALUE
RAM and peripheral bit-field set and clear API.
#define _LESENSE_ST_TCONFB_SETIF_SHIFT
LESENSE_DecCtrlDesc_TypeDef decCtrl
#define LESENSE_CMD_DECODE
LESENSE_ControlDACData_TypeDef dacCh1Data
LESENSE_ChPinIdleMode_TypeDef chPinIdleMode
void LESENSE_Init(const LESENSE_Init_TypeDef *init, bool reqReset)
Initialize the LESENSE module.
#define _LESENSE_IEN_RESETVALUE
void LESENSE_DecoderPrsOut(bool enable, uint32_t decMask, uint32_t decCmp)
Enable or disable PRS output from the LESENSE decoder.
#define _LESENSE_DECCTRL_HYSTPRS2_SHIFT
#define _LESENSE_IFC_MASK
#define LESENSE_CMD_START
LESENSE_ChDesc_TypeDef Ch[LESENSE_NUM_CHANNELS]
void LESENSE_Reset(void)
Reset the LESENSE module.
#define _LESENSE_TIMCTRL_AUXSTARTUP_SHIFT
#define _LESENSE_EVALCTRL_RESETVALUE
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_TIMCTRL_PCTOP_SHIFT
#define _LESENSE_TIMCTRL_STARTDLY_SHIFT
#define _LESENSE_TIMCTRL_PCTOP_MASK
#define _LESENSE_ST_TCONFA_RESETVALUE
void LESENSE_ScanModeSet(LESENSE_ScanMode_TypeDef scanMode, bool start)
Set scan mode of the LESENSE channels.
LESENSE_AltExDesc_TypeDef AltEx[16]
void LESENSE_ChannelSlidingWindow(uint8_t chIdx, uint32_t windowSize, uint32_t initValue)
Configure Sliding Window evaluation mode for a specific channel.
#define _LESENSE_DECCTRL_ERRCHK_SHIFT
LESENSE_CH EFM32PG12B LESENSE CH.
#define _LESENSE_CH_EVAL_COMPTHRES_MASK
#define _LESENSE_ST_TCONFA_SETIF_SHIFT
LESENSE_PRSSel_TypeDef prsChSel0
#define _LESENSE_CH_EVAL_COMPTHRES_SHIFT
#define _LESENSE_PERCTRL_DACCH1DATA_SHIFT
#define _LESENSE_CH_INTERACT_RESETVALUE
#define _LESENSE_ROUTEPEN_RESETVALUE
#define _LESENSE_EVALCTRL_WINSIZE_MASK
#define _LESENSE_CH_INTERACT_SAMPLECLK_SHIFT
#define _LESENSE_CH_EVAL_SCANRESINV_SHIFT
#define _LESENSE_PRSCTRL_DECCMPVAL_SHIFT
void LESENSE_DecoderStateSet(uint32_t decSt)
Set LESENSE decoder state.
#define _LESENSE_ST_TCONFB_RESETVALUE
void LESENSE_WindowSizeSet(uint32_t windowSize)
Set the window size for all LESENSE channels.
#define _LESENSE_DECCTRL_HYSTPRS0_SHIFT
#define LESENSE_DECCTRL_DISABLE
#define _LESENSE_PERCTRL_DACCONVTRIG_SHIFT
#define _LESENSE_CTRL_DUALSAMPLE_SHIFT
LESENSE_PRSSel_TypeDef prsSel
LESENSE_DecStDesc_TypeDef St[LESENSE_NUM_DECODER_STATES]
#define _LESENSE_CH_TIMING_SAMPLEDLY_MASK
#define _LESENSE_CTRL_SCANMODE_MASK
#define _LESENSE_CH_EVAL_MODE_SHIFT
#define _LESENSE_TIMCTRL_AUXSTARTUP_MASK
LESENSE_ChClk_TypeDef exClk
#define _LESENSE_DECSTATE_DECSTATE_MASK
LESENSE_ChEvalMode_TypeDef evalMode
#define _LESENSE_CH_TIMING_SAMPLEDLY_SHIFT
void LESENSE_ChannelTimingSet(uint8_t chIdx, uint8_t exTime, uint8_t sampleDelay, uint16_t measDelay)
Set LESENSE channel timing parameters.
#define _LESENSE_CH_TIMING_EXTIME_MASK
#define _LESENSE_TIMCTRL_AUXPRESC_MASK
uint32_t LESENSE_ScanFreqSet(uint32_t refFreq, uint32_t scanFreq)
Set scan frequency for periodic scanning.
LESENSE_DMAWakeUp_TypeDef wakeupOnDMA
#define _LESENSE_PRSCTRL_DECCMPEN_SHIFT
#define LESENSE_SYNCBUSY_CMD
#define _LESENSE_PERCTRL_ACMP0INV_SHIFT
#define _LESENSE_PRSCTRL_RESETVALUE
LESENSE_ChCompMode_TypeDef compMode
#define _LESENSE_CTRL_STRSCANRES_SHIFT
#define _LESENSE_CH_INTERACT_EXCLK_SHIFT
#define _LESENSE_DECCTRL_PRSSEL0_SHIFT
void LESENSE_ClkDivSet(LESENSE_ChClk_TypeDef clk, LESENSE_ClkPresc_TypeDef clkDiv)
Set clock division for LESENSE timers.
LESENSE_PRSSel_TypeDef prsChSel2
#define _LESENSE_PERCTRL_ACMP0MODE_SHIFT
#define _LESENSE_DECCTRL_PRSSEL2_SHIFT
#define LESENSE_NUM_DECODER_STATES
#define _LESENSE_CH_EVAL_DECODE_SHIFT
void LESENSE_ChannelAllConfig(const LESENSE_ChAll_TypeDef *confChAll)
Configure all (16) LESENSE sensor channels.
#define LESENSE_CH_EVAL_MODE_SLIDINGWIN
LESENSE_PerCtrlDesc_TypeDef perCtrl
#define _LESENSE_CH_INTERACT_ALTEX_SHIFT
void LESENSE_ChannelConfig(const LESENSE_ChDesc_TypeDef *confCh, uint32_t chIdx)
Configure a single LESENSE sensor channel.
#define _LESENSE_PERCTRL_ACMP1INV_SHIFT
LESENSE_ScanConfSel_TypeDef scanConfSel
uint32_t LESENSE_DecoderStateGet(void)
Get the current state of the LESENSE decoder.
#define LESENSE_CH_EVAL_MODE_STEPDET
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_ACMP0INV_MASK
#define _LESENSE_TIMCTRL_PCPRESC_MASK
void LESENSE_StepSizeSet(uint32_t stepSize)
Set the step size for all LESENSE channels.
#define _LESENSE_TIMCTRL_PCPRESC_SHIFT
#define _LESENSE_ST_TCONFB_COMP_SHIFT
#define _LESENSE_ST_TCONFA_CHAIN_SHIFT
#define _LESENSE_PERCTRL_RESETVALUE
#define _LESENSE_ST_TCONFA_MASK_SHIFT
#define _LESENSE_TIMCTRL_AUXPRESC_SHIFT
#define _LESENSE_CTRL_ALTEXMAP_SHIFT
#define _LESENSE_BIASCTRL_RESETVALUE
LESENSE_DecStCond_TypeDef confB
LESENSE_ChClk_TypeDef sampleClk
LESENSE_CoreCtrlDesc_TypeDef coreCtrl
LESENSE_ScanMode_TypeDef scanStart
#define _LESENSE_CTRL_BUFOW_SHIFT
#define _LESENSE_ST_TCONFB_MASK_SHIFT
LESENSE_AltExMap_TypeDef altExMap
#define _LESENSE_CH_TIMING_MEASUREDLY_MASK
void LESENSE_DecoderStateConfig(const LESENSE_DecStDesc_TypeDef *confDecSt, uint32_t decSt)
Configure a single LESENSE decoder state.
#define _LESENSE_PRSCTRL_DECCMPMASK_SHIFT
LESENSE_DecInput_TypeDef decInput
#define _LESENSE_CH_TIMING_MEASUREDLY_SHIFT
Low Energy Sensor (LESENSE) peripheral API.
#define _LESENSE_CH_EVAL_STRSAMPLE_SHIFT
LESENSE_WarmupMode_TypeDef warmupMode
#define _LESENSE_DECCTRL_PRSSEL1_SHIFT
LESENSE_StTransAct_TypeDef prsAct
LESENSE_BiasMode_TypeDef biasMode
#define _LESENSE_DECCTRL_HYSTPRS1_SHIFT
LESENSE_AltExPinIdle_TypeDef idleConf
#define _LESENSE_CHEN_RESETVALUE
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.
#define _LESENSE_ST_TCONFA_COMP_SHIFT
#define _LESENSE_DECCTRL_RESETVALUE
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_CTRL_DEBUGRUN_SHIFT
#define _LESENSE_ALTEXCONF_RESETVALUE
void LESENSE_ScanStop(void)
Stop scanning of sensors.
uint32_t CMU_ClockFreqGet(CMU_Clock_TypeDef clock)
Get clock frequency for a clock point.
#define _LESENSE_DECCTRL_PRSCNT_SHIFT
#define _LESENSE_TIMCTRL_STARTDLY_MASK
#define _LESENSE_CH_TIMING_RESETVALUE
#define _LESENSE_DECCTRL_INTMAP_SHIFT
#define _LESENSE_ST_TCONFB_NEXTSTATE_SHIFT
void LESENSE_ChannelStepDetection(uint8_t chIdx, uint32_t stepSize, uint32_t initValue)
Configure step detection evaluation mode for a specific channel.
LESENSE_ChIntMode_TypeDef intMode
LESENSE_ChPinExMode_TypeDef chPinExMode
LESENSE_BufTrigLevel_TypeDef bufTrigLevel
LESENSE_PRSSel_TypeDef prsChSel1
#define LESENSE_CMD_CLEARBUF
LESENSE_ChSampleMode_TypeDef sampleMode
#define _LESENSE_DECCTRL_PRSSEL3_SHIFT
void LESENSE_DecoderStateAllConfig(const LESENSE_DecStAll_TypeDef *confDecStAll)
Configure all LESENSE decoder states.
#define _LESENSE_PERCTRL_DACCH0DATA_SHIFT