Capacitive sensor support

nRF5 SDK v12.2.0

Module for using a capacitive sensor on low-energy level. More...

Data Structures

struct nrf_drv_csense_config_t
Module initializing structure. More...
struct nrf_drv_csense_evt_t
Structure holding event parameters. More...

Macros

#define MAX_ANALOG_INPUTS 8
Maximum number of analog inputs.

Typedefs

typedef void(* nrf_drv_csense_event_handler_t )( nrf_drv_csense_evt_t *p_event_struct)
Csense events handler. Called from conversion handler. More...

Functions

ret_code_t nrf_drv_csense_init ( nrf_drv_csense_config_t const *p_config, nrf_drv_csense_event_handler_t event_handler)
Function for initializing the module. More...
ret_code_t nrf_drv_csense_uninit (void)
Function for unintializing the capacitive sensor. Clears mask of enabled channels. More...
void nrf_drv_csense_channels_enable (uint8_t channels_mask)
Function for enabling analog channels for the capacitive sensor. More...
void nrf_drv_csense_channels_disable (uint8_t channels_mask)
Function for disabling analog channels of the capacitive sensor. More...
uint16_t nrf_drv_csense_channel_read (uint8_t csense_channel)
Function for getting last read value from an analog channel. More...
ret_code_t nrf_drv_csense_sample (void)
Function for triggering a measurement on all enabled analog channels. Handler will be called on every completed measurement. More...
bool nrf_drv_csense_is_busy (void)
Function for checking if module is busy. More...

Detailed Description

Module for using a capacitive sensor on low-energy level.

Typedef Documentation

typedef void(* nrf_drv_csense_event_handler_t)( nrf_drv_csense_evt_t *p_event_struct)

Csense events handler. Called from conversion handler.

Parameters
[in] event_struct Structure holding event parameters.

Function Documentation

uint16_t nrf_drv_csense_channel_read ( uint8_t csense_channel )

Function for getting last read value from an analog channel.

Parameters
[in] csense_channel Number of the channel to get value from.
Returns
Analog value measured on the channel.
void nrf_drv_csense_channels_disable ( uint8_t channels_mask )

Function for disabling analog channels of the capacitive sensor.

Parameters
[in] channels_mask Mask of analog channels to be enabled.
void nrf_drv_csense_channels_enable ( uint8_t channels_mask )

Function for enabling analog channels for the capacitive sensor.

Parameters
[in] channels_mask Mask of analog channels to be enabled.
ret_code_t nrf_drv_csense_init ( nrf_drv_csense_config_t const * p_config ,
nrf_drv_csense_event_handler_t event_handler
)

Function for initializing the module.

After calling function module is in initialized state and all channels are disabled, nrf_drv_csense_channels_enable function needs to be called. Initializes all modules needed by capacitive sensor library: ADC for NRF51 or TIMERs, PPIs and COMP for NRF52.

Parameters
[in] p_config Structure for initializing module.
[in] event_handler Event handler for capacitor sensor events.
Return values
NRF_ERROR_INVALID_PARAM Invalid parameter.
NRF_ERROR_NO_MEM Timer operations queue was full.
NRF_ERROR_INTERNAL Error occurred during timers, PPI's or COMP initialization.
NRF_SUCCESS Module was initialized successfully.
See Also
nrf_drv_csense_channels_enable
bool nrf_drv_csense_is_busy ( void )

Function for checking if module is busy.

Returns
True if busy or false if not busy.
ret_code_t nrf_drv_csense_sample ( void )

Function for triggering a measurement on all enabled analog channels. Handler will be called on every completed measurement.

Return values
NRF_ERROR_BUSY If module was busy or ADC module is in use and was busy.
NRF_SUCCESS If measurement was triggered successfully.
ret_code_t nrf_drv_csense_uninit ( void )

Function for unintializing the capacitive sensor. Clears mask of enabled channels.

Returns
Values returned by nrf_drv_ppi_channel_free .