34 #include "caplesenseconfig.h"
43 0, 0, 0, 0, 0, 0, 0, 0,
45 0, 0, 0, 0, 0, 0, 0, 0
56 1, 1, 1, 1, 1, 1, 1, 1,
58 1, 1, 1, 1, 1, 1, 1, 1
65 static const bool channelsInUse[LESENSE_CHANNELS] = LESENSE_CAPSENSE_CH_IN_USE;
152 .lowPowerReferenceEnabled =
false,
177 static bool init =
true;
180 static uint16_t capsenseCalibrateVals[4];
197 .storeScanRes =
false,
323 for (i = 0U; i < CAPLESENSE_NUMOF_SLIDERS; i++)
418 channel = SLIDER_PART0_CHANNEL;
421 channel = SLIDER_PART1_CHANNEL;
424 channel = SLIDER_PART2_CHANNEL;
427 channel = SLIDER_PART3_CHANNEL;
467 uint32_t minVal = 236;
471 uint32_t interpol[6] = { 255, 255, 255, 255, 255, 255 };
472 uint32_t channelPattern[] = { 0, SLIDER_PART0_CHANNEL + 1,
473 SLIDER_PART1_CHANNEL + 1,
474 SLIDER_PART2_CHANNEL + 1,
475 SLIDER_PART3_CHANNEL + 1 };
485 for (i = 1; i < CAPLESENSE_NUMOF_SLIDERS + 1; i++)
491 if (interpol[i] < minVal)
493 minVal = interpol[i];
503 position = (minPos - 1) << 4;
506 position -= ((256 - interpol[minPos - 1]) << 3)
507 / (256 - interpol[minPos]);
510 position += ((256 - interpol[minPos + 1]) << 3)
511 / (256 - interpol[minPos]);
Clock management unit (CMU) API.
__STATIC_INLINE uint32_t LESENSE_IntGetEnabled(void)
Get enabled and pending LESENSE interrupt flags.
void CMU_ClockSelectSet(CMU_Clock_TypeDef clock, CMU_Select_TypeDef ref)
Select reference clock/oscillator used for a clock branch.
__STATIC_INLINE void LESENSE_IntClear(uint32_t flags)
Clear one or more pending LESENSE interrupts.
static __INLINE void SystemCoreClockUpdate(void)
Update CMSIS SystemCoreClock variable.
uint32_t CAPLESENSE_getVal(uint8_t channel)
Get the current channelValue for a channel.
void LESENSE_ChannelAllConfig(LESENSE_ChAll_TypeDef const *confChAll)
Configure all (16) LESENSE sensor channels.
Emlib peripheral API "assert" implementation.
void LESENSE_ChannelThresSet(uint8_t const chIdx, uint16_t const acmpThres, uint16_t const cntThres)
Set LESENSE channel threshold parameters.
void CAPLESENSE_Sleep(void)
Send the capacative sense system to sleep mode.
uint32_t CAPLESENSE_getNormalizedVal(uint8_t channel)
Get the current normalized channelValue for a channel.
static volatile uint8_t currentChannel
__STATIC_INLINE uint32_t INT_Enable(void)
Enable interrupts.
void EMU_EnterEM2(bool restore)
Enter energy mode 2 (EM2).
uint32_t LESENSE_ScanFreqSet(uint32_t refFreq, uint32_t const scanFreq)
Set scan frequency for periodic scanning.
static void(* lesenseScanCb)(void)
static void(* lesenseChCb)(void)
void LESENSE_ResultBufferClear(void)
Clear result buffer.
CMSIS Cortex-M Peripheral Access Layer for Silicon Laboratories microcontroller devices.
void CAPLESENSE_setupCallbacks(void(*scanCb)(void), void(*chCb)(void))
LESENSE callback setup.
void LESENSE_IRQHandler(void)
LESENSE interrupt handler.
void CAPLESENSE_setupACMP(void)
Setup the ACMP.
Interrupt enable/disable unit API.
void CAPLESENSE_setupGPIO(void)
Setup the GPIO.
__STATIC_INLINE void LESENSE_IntDisable(uint32_t flags)
Disable one or more LESENSE interrupts.
void GPIO_DriveModeSet(GPIO_Port_TypeDef port, GPIO_DriveMode_TypeDef mode)
Sets the drive mode for a GPIO port.
void GPIO_PinModeSet(GPIO_Port_TypeDef port, unsigned int pin, GPIO_Mode_TypeDef mode, unsigned int out)
Set the mode for a GPIO pin.
__STATIC_INLINE uint32_t LESENSE_ScanResultDataBufferGet(uint32_t idx)
Get data from the result data buffer.
void ACMP_CapsenseInit(ACMP_TypeDef *acmp, const ACMP_CapsenseInit_TypeDef *init)
Sets up the ACMP for use in capacative sense applications.
General Purpose IO (GPIO) peripheral API.
void LESENSE_ClkDivSet(LESENSE_ChClk_TypeDef const clk, LESENSE_ClkPresc_TypeDef const clkDiv)
Set clock division for LESENSE timers.
__STATIC_INLINE uint32_t LESENSE_StatusGet(void)
Get the current status of LESENSE.
void CAPLESENSE_setupCMU(void)
Setup the CMU.
void CAPLESENSE_setupLESENSE(bool sleep)
Setup the LESENSE for capavitive sensing.
void CMU_ClockEnable(CMU_Clock_TypeDef clock, bool enable)
Enable/disable a clock.
#define LESENSE_STATUS_BUFHALFFULL
void LESENSE_Init(LESENSE_Init_TypeDef const *init, bool const reqReset)
Initialize the LESENSE module.
static const bool channelsInUse[LESENSE_CHANNELS]
A bit vector which represents the channels to iterate through.
int32_t CAPLESENSE_getSliderPosition(void)
Get the position of the slider.
Analog Comparator (ACMP) peripheral API.
Energy management unit (EMU) peripheral API.
LESENSE_CoreCtrlDesc_TypeDef coreCtrl
LESENSE_ScanMode_TypeDef scanStart
__STATIC_INLINE uint32_t LESENSE_ScanResultDataGet(void)
Get the oldest unread data from the result buffer.
static volatile uint32_t channelValues[LESENSE_CHANNELS]
This vector stores the latest read values from LESENSE.
Low Energy Sensor (LESENSE) peripheral API.
__STATIC_INLINE uint32_t INT_Disable(void)
Disable interrupts.
void CAPLESENSE_Init(bool sleep)
Initializes the capacative sense system without LESENSE.
void LESENSE_ScanStart(void)
Start scanning of sensors.
void LESENSE_ScanStop(void)
Stop scanning of sensors.
static volatile uint32_t channelMaxValues[LESENSE_CHANNELS]
This stores the maximum values seen by a channel.
uint8_t CAPLESENSE_getSegmentChannel(uint8_t capSegment)
Get the channelValue for a sensor segment.
void ACMP_GPIOSetup(ACMP_TypeDef *acmp, uint32_t location, bool enable, bool invert)
Sets up GPIO output from the ACMP.
__STATIC_INLINE void LESENSE_IntEnable(uint32_t flags)
Enable one or more LESENSE interrupts.
#define LESENSE_STATUS_SCANACTIVE
void CMU_ClockDivSet(CMU_Clock_TypeDef clock, CMU_ClkDiv_TypeDef div)
Set clock divisor/prescaler.