caplesense.c File Reference

Capacitive sense driver.

License

Copyright 2018 Silicon Laboratories Inc. www.silabs.com

SPDX-License-Identifier: Zlib

The licensor of this software is Silicon Laboratories Inc.

This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software.

Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions:

  1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
  2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
  3. This notice may not be removed or altered from any source distribution.

Definition in file caplesense.c.

#include "em_device.h"
#include "caplesense.h"
#include "em_emu.h"
#include "em_acmp.h"
#include "em_assert.h"
#include "em_cmu.h"
#include "em_gpio.h"
#include "em_core.h"
#include "em_lesense.h"
#include "caplesenseconfig.h"

Functions

uint32_t CAPLESENSE_getNormalizedVal (uint8_t channel)
 Get the current normalized channelValue for a channel.
 
uint8_t CAPLESENSE_getSegmentChannel (uint8_t capSegment)
 Get the channelValue for a sensor segment.
 
int32_t CAPLESENSE_getSliderPosition (void)
 Get the position of the slider.
 
uint32_t CAPLESENSE_getVal (uint8_t channel)
 Get the current channelValue for a channel.
 
void CAPLESENSE_Init (bool sleep)
 Initializes the capacative sense system without LESENSE.
 
void CAPLESENSE_setupACMP (void)
 Setup the ACMP.
 
void CAPLESENSE_setupCallbacks (void(*scanCb)(void), void(*chCb)(void))
 LESENSE callback setup.
 
void CAPLESENSE_setupCMU (void)
 Setup the CMU.
 
void CAPLESENSE_setupGPIO (void)
 Setup the GPIO.
 
void CAPLESENSE_setupLESENSE (bool sleep)
 Setup the LESENSE for capavitive sensing.
 
void CAPLESENSE_Sleep (void)
 Send the capacative sense system to sleep mode.
 
void LESENSE_IRQHandler (void)
 LESENSE interrupt handler.
 

Variables

static volatile uint32_t channelMaxValues [LESENSE_CHANNELS]
 This stores the maximum values seen by a channel.
 
static const bool channelsInUse [LESENSE_CHANNELS] = LESENSE_CAPSENSE_CH_IN_USE
 A bit vector which represents the channels to iterate through.
 
static volatile uint32_t channelValues [LESENSE_CHANNELS]
 This vector stores the latest read values from LESENSE.
 
static volatile uint8_t currentChannel
 
static void(* lesenseChCb )(void)
 
static void(* lesenseScanCb )(void)
 

Function Documentation

Variable Documentation

volatile uint32_t channelMaxValues[LESENSE_CHANNELS]
static
Initial value:
=
{
1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1
}

This stores the maximum values seen by a channel.

Parameters
LESENSE_CHANNELSVector of channels.

Definition at line 64 of file caplesense.c.

Referenced by CAPLESENSE_getNormalizedVal(), CAPLESENSE_getSliderPosition(), CAPSENSE_getNormalizedVal(), CAPSENSE_getPressed(), CAPSENSE_getSliderPosition(), LESENSE_IRQHandler(), and TIMER0_IRQHandler().

const bool channelsInUse[LESENSE_CHANNELS] = LESENSE_CAPSENSE_CH_IN_USE
static

A bit vector which represents the channels to iterate through.

Parameters
LESENSE_CHANNELSVector of channels.

Definition at line 76 of file caplesense.c.

Referenced by CAPLESENSE_setupLESENSE(), CAPSENSE_Sense(), and LESENSE_IRQHandler().

volatile uint32_t channelValues[LESENSE_CHANNELS]
static
Initial value:
=
{
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0
}

This vector stores the latest read values from LESENSE.

Parameters
LESENSE_CHANNELSVector of channels.

Definition at line 52 of file caplesense.c.

Referenced by CAPLESENSE_getNormalizedVal(), CAPLESENSE_getSliderPosition(), CAPLESENSE_getVal(), CAPSENSE_getNormalizedVal(), CAPSENSE_getPressed(), CAPSENSE_getSliderPosition(), CAPSENSE_getVal(), LESENSE_IRQHandler(), and TIMER0_IRQHandler().

volatile uint8_t currentChannel
static

The current channel we are sensing

Definition at line 94 of file caplesense.c.

Referenced by CAPSENSE_Sense(), LESENSE_IRQHandler(), and TIMER0_IRQHandler().

void(* lesenseChCb) (void)
static

Callback function for LESENSE interrupts.

Definition at line 91 of file caplesense.c.

Referenced by CAPLESENSE_setupCallbacks(), and LESENSE_IRQHandler().

void(* lesenseScanCb) (void)
static

Local variablesCallback function for LESENSE interrupts.

Definition at line 89 of file caplesense.c.

Referenced by CAPLESENSE_setupCallbacks(), and LESENSE_IRQHandler().