Configures whether system goes to sleep between scans in active mode. 1 means that the system is in free run mode and will not go to sleep. 0 means that the system will take a single scan within an active mode scan period and will then enter sleep once CSLIB_lowPowerUpdate() is called. The system will stay asleep until the next active mode scan period begins.

Sets whether the system is allowed to ever use sleep mode scanning. If set to 0, the system will always remain in active mode. If set to 1, the system is allowed to perform sleep mode scanning when conditions permit it.

Enumeration Type Documentation

Defines all noise characterization states the CSLIB will use for characterization.

Enumerator

low

Interference should have negligible impact on sensing.

mid

Interference forces system to qualify touches conservatively.

high

Interference forces entrance into no confidence mode if enabled.

Definition at line 400 of file cslib.h.

Function Documentation

uint8_t CSLIB_anySensorDebounceActive

(

void

)

Checks to see if any enabled sensor is debounce active

Checks to see if any enabled sensor is qualified active, meaning that the data from the sensor on this input has risen above the active threshold for a consecutive number of samples equaling at least the value defined by DEF_DEBOUNCE_COUNTS.

Returns

1 if any enabled sensor is debounce active, 0 otherwise

uint8_t CSLIB_anySensorSingleActive

(

void

)

Checks to see if any enabled sensor is single active

This function checks the SINGLE_ACTIVE_MASK in the sensor node structure for all enabled sensors. If any sensor's SINGLE_ACTIVE_MASK is set, meaning that the sensor is a candidate active sensor, the the function returns TRUE. Otherwise it returns FALSE.

Returns

1 if any sensor is active, 0 otherwise

void CSLIB_baselineInitDisableCB

(

void

)

Restore capacitive sensing config to operational state

This function reverts any baseline-related capactive sensing config.

void CSLIB_baselineInitEnableCB

(

void

)

Modify capacitive sense config for baseline initialization

Saves configuration state and makes device-level modifications appropriate to baseline initialization using the scanSensor() function.

void CSLIB_checkTimerCB

(

void

)

Check wake sources

This function examines the system timer to check for wake events.

Check wake sources

This callback function examines the system timer to check for wake events.

void CSLIB_configureSensorForActiveModeCB

(

void

)

Callback to confiure sensors for active mode

Callback routine to configure sensors for active mode scanning.

void CSLIB_configureSensorForSleepModeCB

(

void

)

Callback to configure sensors for sleep mode

Callback routine used if low power mode is included in build, this function configures the capacitive sensing block and inputs for sleep mode.

void CSLIB_configureTimerForActiveModeCB

(

void

)

Callback to configure timer for active mode scanning

Configures the timer to initiate a scan as defined by active mode scan period.

void CSLIB_configureTimerForSleepModeCB

(

void

)

Configure timer for sleep mode

If low power mode is included in build, this function sets the wake-up event to the sleep mode scan period.

void CSLIB_enterLowPowerStateCB

(

void

)

Callback to enter low power mode

If low power mode is included in build, this function mode-switches the core to a low power state.

uint16_t CSLIB_getNoiseAdjustedSensorData

(

uint8_t

index

)

Returns raw or filtered sensor data, based on characterized interference

Parameters

index

Sensor node element whose data is to be read

This function either returns the newest raw data for a sensor, or the newest filtered data for a sensor, depending on which data type the interference characterization algorithm determines to be necessary to show current sensor state. In low interference environments, raw data will be returned. In higher interference states, filtered data will be returned.

Returns

sensor data from sensor node struct defined index

uint16_t CSLIB_getNormalizedDelta

(

uint8_t

sensor_index,

uint16_t

flood_level

)

Get baseline-adjusted, noise-adjusted touch delta

Parameters

sensor_index

Index into sensor node struct

flood_level

additional value that can be subtracted in addition to baseline

Returns value that is raw or filtered data minus the sensor's baseline. flood_level can be used to remove additional margin along with baseline.

This function calls into the library, which in turn calls into the device layer functions initializing the sensing and timing hardware used during capacitive sensing conversions.

void CSLIB_initLibrary

(

void

)

Initializes capacitive sensing state variables

This function resets all state variables in the sensor node struct and library-internal state variables to default.

uint8_t CSLIB_isSensorDebounceActive

(

uint8_t

index

)

Checks if a sensor is debounce active

Parameters

index

into sensor node element to be checked

This checks to see if any enabled sensor is a qualified active sensor.

Returns

1 if element selected by index is debounce active, 0 otherwise

uint8_t CSLIB_isSensorSingleActive

(

uint8_t

index

)

Checks if a sensor is single active

Parameters

index

into sensor node element to be checked

This checks to see if any enabled sensor is a candidate active sensor.

Returns

1 if element selected by index is single active, 0 otherwise

void CSLIB_lowPowerUpdate

(

void

)

Checks timing and possibly enters low power mode

This function checks the time in the system relative to active mode scan period timing. It should be called in the firmware project's main() while(1) loop.

If FREE_RUN_SETTING is set to 0, the function will enter low power until the next active mode scan period.

If FREE_RUN_SETTING is set to 1, the function will exit, allowing for another iteration in the main() loop.

If CSLIB_lowPowerUpdate() finds that no qualified touches have been found in a time specified by COUNTS_BEFORE_SLEEP multiplied by ACTIVE_MODE_SCAN_PERIOD, the function initializes the system to run in its sleep scanning mode and enters a low power state.

uint16_t CSLIB_nodeGetRaw

(

uint8_t

sensorIndex,

uint8_t

bufferIndex

)

Reads a node structure sensor's raw buffer value

Parameters

sensorIndex

The element of the sensor node structure

bufferIndex

The element inside the sensor node element's raw data buffer

This function can be used to read values in the raw data buffer at bufferIndex of an enabled sensor specified by sensorIndex.

This function is used by the device layer of code that interfaces with capacitive sensing hardware. When CSLIB_update() calls into the device layer to convert a new sample set using scanSensor(), the device layer implementation of scanSensor() should use this routine to push newly converted samples into the sensor node structure for processing within the library.

void CSLIB_resetSensorStruct

(

uint8_t

sensorIndex,

uint16_t

fillValue

)

Resets an element of the sensor node struct back to defaults

Parameters

sensorIndex

index of sensor node struct to reset

fillValue

value to be used when filling raw data buffer

This function is called during initialization to reset the sensor at node sensorIndex back to back to its power-on state.

uint32_t CSLIB_scanSensorCB

(

uint8_t

index

)

Performs capacitive sensing conversion on a sensor

Parameters

index

The sensor to be scanned, corresponds to sensor node struct

This device layer function is called from within library code after CSLIB_update() is called in the main loop. The function is responsible for any configuration of the capacitive sensing block necessary to perform the scan.

This function should be called in a firmware project's main() loop. The function will execute a capacitive sensing scan sequence, filter samples, examine samples for qualified touches, and update other state variables.