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.
uint32_t CAPSENSE_getVal(uint8_t channel)
Get the current channelValue for a channel.
void ACMP_Disable(ACMP_TypeDef *acmp)
Disables the ACMP.
#define ACMP_CAPSENSE_INIT_DEFAULT
static volatile uint8_t currentChannel
#define TIMER_CC_CTRL_INSEL_PRS
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.
#define TIMER_CTRL_PRESC_DIV1024
CMSIS Cortex-M Peripheral Access Layer for Silicon Laboratories microcontroller devices.
#define TIMER_CC_CTRL_ICEVCTRL_RISING
#define TIMER_CC_CTRL_MODE_INPUTCAPTURE
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.
int32_t CAPSENSE_getSliderPosition(void)
Get the position of the slider.
__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.
#define TIMER_CTRL_PRESC_DIV512
void TIMER0_IRQHandler(void)
TIMER0 interrupt handler.
void CMU_ClockEnable(CMU_Clock_TypeDef clock, bool enable)
Enable/disable a clock.
#define TIMER_CTRL_CLKSEL_CC1
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_PRSSEL_PRSCH0
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.
#define PRS_CH_CTRL_EDSEL_POSEDGE
static volatile uint32_t channelMaxValues[LESENSE_CHANNELS]
This stores the maximum values seen by a channel.
#define TIMER_CC_CTRL_ICEDGE_BOTH