30 static volatile bool measurementComplete;
32 #if defined(CAPSENSE_CH_IN_USE)
44 static const bool channelsInUse[ACMP_CHANNELS] = CAPSENSE_CH_IN_USE;
45 #elif defined(CAPSENSE_CHANNELS)
57 static const ACMP_Channel_TypeDef channelList[ACMP_CHANNELS] = CAPSENSE_CHANNELS;
64 #if !defined(NUM_SLIDER_CHANNELS)
65 #define NUM_SLIDER_CHANNELS 4
113 measurementComplete =
true;
168 uint32_t minVal = 224;
172 uint32_t interpol[(NUM_SLIDER_CHANNELS+2)];
173 for (i = 0; i < (NUM_SLIDER_CHANNELS+2); i++)
186 for (i = 1; i < (NUM_SLIDER_CHANNELS+1); i++)
192 if (interpol[i] < minVal)
194 minVal = interpol[i];
204 position = (minPos - 1) << 4;
207 position -= ((256 - interpol[minPos - 1]) << 3)
208 / (256 - interpol[minPos]);
211 position += ((256 - interpol[minPos + 1]) << 3)
212 / (256 - interpol[minPos]);
225 ACMP_CapsenseChannelSet(ACMP_CAPSENSE, channel);
231 measurementComplete =
false;
238 while ( measurementComplete ==
false )
253 ACMP_Enable(ACMP_CAPSENSE);
255 #if defined(CAPSENSE_CHANNELS)
276 ACMP_Disable(ACMP_CAPSENSE);
293 ACMP_CapsenseInit_TypeDef capsenseInit = ACMP_CAPSENSE_INIT_DEFAULT;
299 #if defined(ACMP_CAPSENSE_CMUCLOCK)
302 CMU->HFPERCLKEN0 |= ACMP_CAPSENSE_CLKEN;
325 | PRS_CH_CTRL_SOURCESEL_ACMP_CAPSENSE
326 | PRS_CH_CTRL_SIGSEL_ACMPOUT_CAPSENSE;
329 ACMP_CapsenseInit(ACMP_CAPSENSE, &capsenseInit);
Clock management unit (CMU) API.
#define TIMER_CTRL_PRESC_DIV512
uint32_t CAPSENSE_getVal(uint8_t channel)
Get the current channelValue for a channel.
static volatile uint8_t currentChannel
#define TIMER_CC_CTRL_PRSSEL_PRSCH0
#define PRS_CH_CTRL_EDSEL_POSEDGE
bool CAPSENSE_getPressed(uint8_t channel)
Get the state of the Gecko Button.
CMSIS Cortex-M Peripheral Access Layer for Silicon Laboratories microcontroller devices.
static void CAPSENSE_Measure(ACMP_Channel_TypeDef channel)
Start a capsense measurement of a specific channel and waits for it to complete.
void CAPSENSE_Init(void)
Initializes the capacitive sense system.
#define TIMER_CC_CTRL_ICEDGE_BOTH
int32_t CAPSENSE_getSliderPosition(void)
Get the position of the slider.
__STATIC_INLINE void EMU_EnterEM1(void)
Enter energy mode 1 (EM1).
#define TIMER_CTRL_CLKSEL_CC1
void TIMER0_IRQHandler(void)
TIMER0 interrupt handler.
void CMU_ClockEnable(CMU_Clock_TypeDef clock, bool enable)
Enable/disable a clock.
#define TIMER_CC_CTRL_ICEVCTRL_RISING
static const bool channelsInUse[LESENSE_CHANNELS]
A bit vector which represents the channels to iterate through.
Analog Comparator (ACMP) peripheral API.
Energy management unit (EMU) peripheral API.
#define TIMER_CC_CTRL_INSEL_PRS
#define TIMER_CTRL_PRESC_DIV1024
static volatile uint32_t channelValues[LESENSE_CHANNELS]
This vector stores the latest read values from LESENSE.
#define TIMER_CC_CTRL_MODE_INPUTCAPTURE
void CAPSENSE_Sense(void)
This function iterates through all the capsensors and reads and initiates a reading. Uses EM1 while waiting for the result from each sensor.
uint32_t CAPSENSE_getNormalizedVal(uint8_t channel)
Get the current normalized channelValue for a channel.
static volatile uint32_t channelMaxValues[LESENSE_CHANNELS]
This stores the maximum values seen by a channel.