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)
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]);
231 measurementComplete =
false;
238 while ( measurementComplete ==
false )
255 #if defined(CAPSENSE_CHANNELS)
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;
Clock management unit (CMU) API.
#define TIMER_CTRL_CLKSEL_CC1
uint32_t CAPSENSE_getVal(uint8_t channel)
Get the current channelValue for a channel.
void ACMP_Disable(ACMP_TypeDef *acmp)
Disables the ACMP.
#define TIMER_CTRL_PRESC_DIV512
#define ACMP_CAPSENSE_INIT_DEFAULT
static volatile uint8_t currentChannel
void ACMP_CapsenseChannelSet(ACMP_TypeDef *acmp, ACMP_Channel_TypeDef channel)
Sets the ACMP channel used for capacative sensing.
bool CAPSENSE_getPressed(uint8_t channel)
Get the state of the Gecko Button.
CMSIS Cortex-M Peripheral Access Layer for Silicon Laboratories microcontroller devices.
#define TIMER_CC_CTRL_INSEL_PRS
#define TIMER_CC_CTRL_ICEVCTRL_RISING
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.
void ACMP_Enable(ACMP_TypeDef *acmp)
Enables the ACMP.
#define TIMER_CC_CTRL_PRSSEL_PRSCH0
int32_t CAPSENSE_getSliderPosition(void)
Get the position of the slider.
#define PRS_CH_CTRL_EDSEL_POSEDGE
__STATIC_INLINE void EMU_EnterEM1(void)
Enter energy mode 1 (EM1).
void ACMP_CapsenseInit(ACMP_TypeDef *acmp, const ACMP_CapsenseInit_TypeDef *init)
Sets up the ACMP for use in capacative sense applications.
void TIMER0_IRQHandler(void)
TIMER0 interrupt handler.
void CMU_ClockEnable(CMU_Clock_TypeDef clock, bool enable)
Enable/disable a clock.
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_MODE_INPUTCAPTURE
#define TIMER_CTRL_PRESC_DIV1024
#define TIMER_CC_CTRL_ICEDGE_BOTH
static volatile uint32_t channelValues[LESENSE_CHANNELS]
This vector stores the latest read values from LESENSE.
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.