EFM32 Wonder Gecko Software Documentation  efm32wg-doc-5.1.2
cslib.h
1 /******************************************************************************
2  * Copyright (c) 2016 by Silicon Laboratories Inc. All rights reserved.
3  *
4  * http://developer.silabs.com/legal/version/v11/Silicon_Labs_Software_License_Agreement.txt
5  *****************************************************************************/
6 
7 #ifndef _CSLIB_H
8 #define _CSLIB_H
9 
10 #define CSLIB_FW_VERSION 0x1300
11 
12 #include <stdint.h>
13 /**************************************************************************/
30 #define DEF_SENSOR_BUFFER_SIZE 2
32 
34 #define DEBOUNCE_ACTIVE_MASK 0x80
35 
37 #define SINGLE_ACTIVE_MASK 0x40
38 
39 
41 typedef union SI_UU32
42 {
43  uint32_t u32;
44  uint32_t s32;
45  uint16_t uu16[2];
46  uint16_t u16[2];
47  uint16_t s16[2];
48  uint8_t u8[4];
49  uint8_t s8[4];
50 } SI_UU32_t;
51 
53 typedef struct
54 {
56  uint16_t rawBuffer[DEF_SENSOR_BUFFER_SIZE];
58  uint16_t currentBaseline;
60  uint8_t touchDeltaDiv16;
62  uint8_t activeIndicator;
64  uint8_t debounceCounts;
66  signed char baselineAccumulator;
70 
71 /**************************************************************************/
81 uint8_t CSLIB_anySensorSingleActive(void);
82 
83 /**************************************************************************/
91 uint8_t CSLIB_isSensorSingleActive(uint8_t index);
92 
93 /**************************************************************************/
103 uint8_t CSLIB_anySensorDebounceActive(void);
104 
105 /**************************************************************************/
113 uint8_t CSLIB_isSensorDebounceActive(uint8_t index);
114 
115 /**************************************************************************/
128 void CSLIB_nodePushRaw(uint8_t index, uint16_t newValue);
129 
130 /**************************************************************************/
143 uint16_t CSLIB_nodeGetRaw(uint8_t sensorIndex, uint8_t bufferIndex);
144 
145 /**************************************************************************/
154 uint16_t CSLIB_getUnpackedTouchDelta(uint8_t index);
155 
156 /**************************************************************************/
165 void CSLIB_resetSensorStruct(uint8_t sensorIndex, uint16_t fillValue);
166 
167 
168 /**************************************************************************/
176 void CSLIB_initHardware(void);
177 
178 /**************************************************************************/
185 void CSLIB_initLibrary(void);
186 
187 /**************************************************************************/
195 void CSLIB_update(void);
196 
197 /**************************************************************************/
208 uint16_t scanSensor(uint8_t index);
209 
210 /**************************************************************************/
229 void CSLIB_lowPowerUpdate(void);
230 
231 /**************************************************************************/
244 uint16_t CSLIB_getNoiseAdjustedSensorData(uint8_t index);
245 
247 extern uint8_t noise_level;
248 
250 extern SensorStruct_t CSLIB_node[];
251 
253 extern uint8_t disable_sleep_and_stall;
254 
256 extern uint8_t CSLIB_numSensors;
257 
259 extern uint8_t CSLIB_sensorBufferSize;
260 
263 extern uint8_t CSLIB_buttonDebounce;
264 
266 extern uint16_t CSLIB_activeModePeriod;
267 
271 extern uint16_t CSLIB_systemNoiseAverage;
272 
274 extern uint16_t CSLIB_sleepModePeriod;
275 
277 extern uint16_t CSLIB_countsBeforeSleep;
278 
284 extern uint8_t CSLIB_freeRunSetting;
285 
289 extern uint8_t CSLIB_sleepModeEnable;
290 
293 #endif
294 
295 
void CSLIB_initHardware(void)
signed char baselineAccumulator
Tracks trend of CS values to determine whether baseline rises or falls.
Definition: cslib.h:66
uint8_t CSLIB_anySensorDebounceActive(void)
void CSLIB_resetSensorStruct(uint8_t sensorIndex, uint16_t fillValue)
uint8_t activeIndicator
Bit array showing whether touch is qualified on sensor, uses DEBOUNCE_ACTIVE_MASK.
Definition: cslib.h:62
void CSLIB_nodePushRaw(uint8_t index, uint16_t newValue)
void CSLIB_initLibrary(void)
unsigned short int u16
Definition: bmp280.h:283
uint8_t CSLIB_sensorBufferSize
Size of raw data buffers within sensor node struct elements, should not be changed.
uint16_t currentBaseline
Runtime estimate of untouched or inactive state of CS sensor input.
Definition: cslib.h:58
uint32_t s32
The 4-byte value as a 32-bit signed integer.
Definition: cslib.h:44
uint16_t scanSensor(uint8_t index)
uint8_t disable_sleep_and_stall
Bit that can be set to disable entrance to sleep, overriding timers.
uint16_t CSLIB_getNoiseAdjustedSensorData(uint8_t index)
SI_UU32_t expValue
Filtered CS value with 16 bits of LSBs.
Definition: cslib.h:68
uint16_t CSLIB_getUnpackedTouchDelta(uint8_t index)
uint16_t CSLIB_sleepModePeriod
Sets the scan period in ms for sleep mode scanning. Defaults to DEF_ACTIVE_MODE_PERIOD.
uint16_t CSLIB_activeModePeriod
Sets the scan period in ms for active mode scanning. Defaults to DEF_ACTIVE_MODE_PERIOD.
uint8_t CSLIB_sleepModeEnable
Sets whether the system is allowed to ever use sleep mode scanning. If set to 0, the system will alwa...
signed short int s16
Definition: bmp280.h:277
void CSLIB_lowPowerUpdate(void)
uint8_t debounceCounts
Stores consecutive CS values above or below active or inactive threshold.
Definition: cslib.h:64
unsigned char u8
Definition: bmp280.h:282
void CSLIB_update(void)
uint32_t u32
The 4-byte value as a 32-bit unsigned integer.
Definition: cslib.h:43
uint8_t noise_level
Stores interference characterization level, 0 being lowest and 3 being highest.
SensorStruct_t CSLIB_node[]
Sensor node data structure.
uint16_t CSLIB_countsBeforeSleep
Sets the number of consecutive scans without a single qualified touch before entering sleep mode...
uint8_t CSLIB_isSensorDebounceActive(uint8_t index)
uint16_t CSLIB_nodeGetRaw(uint8_t sensorIndex, uint8_t bufferIndex)
uint16_t uu16[2]
The 4-byte value as a SI_UU16_t.
Definition: cslib.h:45
union SI_UU32 SI_UU32_t
Union used to address upper bytes of 32-bit exponential average easily.
uint8_t touchDeltaDiv16
Describes the expected difference between untouched and touched CS value.
Definition: cslib.h:60
Union used to address upper bytes of 32-bit exponential average easily.
Definition: cslib.h:41
uint8_t CSLIB_anySensorSingleActive(void)
uint8_t CSLIB_freeRunSetting
Configures whether system goes to sleep between scans in active mode. 1 means that the system is in f...
uint8_t CSLIB_buttonDebounce
Sets the number of consecutive values above/below threshold before button is qualified/disqualified. Defaults to DEF_BUTTON_DEBOUNCE.
uint16_t CSLIB_systemNoiseAverage
Describes average interference seen as a percentage of the average touch delta. 100 would mean that a...
uint8_t CSLIB_isSensorSingleActive(uint8_t index)
uint8_t CSLIB_numSensors
Size of the sensor node struct, should only be changed at compile time by editing DEF_NUM_SENSORS...
#define DEF_SENSOR_BUFFER_SIZE
Defines the depth of the raw buffer. Note: this value should not be changed.
Definition: cslib.h:31
Stores all runtime values for an enabled capacitive sensor.
Definition: cslib.h:53
signed char s8
Definition: bmp280.h:276