nRF5 SDK v15.0.0
Modules | Data Structures | Macros | Typedefs | Enumerations | Functions
Capacitive sensor library

Module for using the capacitive sensor library with support for many instances of sliders, wheels, and buttons. More...

Modules

 Capacitive sensor module configuration
 
 Capacitive sensor macros
 A set of macros to facilitate creation of a new capacitive sensor instance.
 

Data Structures

struct  nrf_csense_slider_evt_t
 Structure with slider event data including the measured step. More...
 
union  nrf_csense_evt_param_t
 Event data union for nrf_csense events. More...
 
struct  nrf_csense_evt_t
 Structure with event parameters. More...
 

Macros

#define NRF_CSENSE_GET_INSTANCE_ID(instance)   (&instance)
 Macro for returning the address of a variable.
 
#define NRF_CSENSE_BUTTON_DEF(name, p1)   NRF_CSENSE_INTERNAL_BUTTON_DEF(name, p1)
 Statically allocate memory for the instance of a capacitive sensor. More...
 
#define NRF_CSENSE_SLIDER_2_DEF(name, steps_no, p1, p2)   NRF_CSENSE_INTERNAL_SLIDER_2_DEF(name, steps_no, p1, p2)
 Macro for creating a 2-pad slider instance. More...
 
#define NRF_CSENSE_SLIDER_3_DEF(name, steps_no, p1, p2, p3)   NRF_CSENSE_INTERNAL_SLIDER_3_DEF(name, steps_no, p1, p2, p3)
 Macro for creating a 3-pad slider instance. More...
 
#define NRF_CSENSE_SLIDER_4_DEF(name, steps_no, p1, p2, p3, p4)   NRF_CSENSE_INTERNAL_SLIDER_4_DEF(name, steps_no, p1, p2, p3, p4)
 Macro for creating a 4-pad slider instance. More...
 
#define NRF_CSENSE_SLIDER_5_DEF(name, steps_no, p1, p2, p3, p4, p5)   NRF_CSENSE_INTERNAL_SLIDER_5_DEF(name, steps_no, p1, p2, p3, p4, p5)
 Macro for creating a 5-pad slider instance. More...
 
#define NRF_CSENSE_WHEEL_3_DEF(name, steps_no, p1, p2, p3)   NRF_CSENSE_INTERNAL_WHEEL_3_DEF(name, steps_no, p1, p2, p3)
 Macro for creating a 3-pad wheel instance. More...
 
#define NRF_CSENSE_WHEEL_4_DEF(name, steps_no, p1, p2, p3, p4)   NRF_CSENSE_INTERNAL_WHEEL_4_DEF(name, steps_no, p1, p2, p3, p4)
 Macro for creating a 4-pad wheel instance. More...
 
#define NRF_CSENSE_WHEEL_5_DEF(name, steps_no, p1, p2, p3, p4, p5)   NRF_CSENSE_INTERNAL_WHEEL_5_DEF(name, steps_no, p1, p2, p3, p4, p5)
 Macro for creating a 5-pad wheel instance. More...
 

Typedefs

typedef void(* nrf_csense_event_handler_t )(nrf_csense_evt_t *p_evt)
 Capacitive sensor handler type.
 

Enumerations

enum  nrf_csense_evt_type_t {
  NRF_CSENSE_BTN_EVT_PRESSED,
  NRF_CSENSE_BTN_EVT_RELEASED,
  NRF_CSENSE_SLIDER_EVT_PRESSED,
  NRF_CSENSE_SLIDER_EVT_RELEASED,
  NRF_CSENSE_SLIDER_EVT_DRAGGED
}
 Enum for nrf_csense events. More...
 

Functions

__STATIC_INLINE void nrf_csense_instance_context_set (nrf_csense_instance_t *const p_instance, void *p_context)
 Function for setting a handler of the instance. More...
 
ret_code_t nrf_csense_init (nrf_csense_event_handler_t event_handler, uint32_t ticks)
 Function for initializing the module. After initialization, no instances are enabled. More...
 
ret_code_t nrf_csense_uninit (void)
 Function for uninitializing the module. More...
 
ret_code_t nrf_csense_add (nrf_csense_instance_t *const p_instance)
 Function for adding an instance of capacitive sensor to a linked list. More...
 
ret_code_t nrf_csense_enable (nrf_csense_instance_t *const p_instance)
 Function for enabling a single instance. More...
 
ret_code_t nrf_csense_disable (nrf_csense_instance_t *const p_instance)
 Function for disabling an instance. More...
 
ret_code_t nrf_csense_ticks_set (uint32_t ticks)
 Function for setting ticks between next measurements. More...
 
ret_code_t nrf_csense_steps_set (nrf_csense_instance_t *const p_instance, uint16_t steps)
 Function for setting steps of an instance. More...
 

Detailed Description

Module for using the capacitive sensor library with support for many instances of sliders, wheels, and buttons.

Macro Definition Documentation

#define NRF_CSENSE_BUTTON_DEF (   name,
  p1 
)    NRF_CSENSE_INTERNAL_BUTTON_DEF(name, p1)

Statically allocate memory for the instance of a capacitive sensor.

Parameters
[in,out]nameName of the capacitive sensor instance that will be created.
[in]p1Pair of two arguments: threshold and analog_input_number. Must be passed as (analog_input_number, threshold).
#define NRF_CSENSE_SLIDER_2_DEF (   name,
  steps_no,
  p1,
  p2 
)    NRF_CSENSE_INTERNAL_SLIDER_2_DEF(name, steps_no, p1, p2)

Macro for creating a 2-pad slider instance.

Parameters
[in,out]nameName of the capacitive sensor instance that will be created.
[in]steps_noNumber of relative pads. It means that the slider in its handler will give values (1, steps_no).
[in]p1Pair of two arguments: threshold and analog_input_number. Must be passed as (analog_input_number, threshold).
[in]p2Pair of two arguments: threshold and analog_input_number. Must be passed as (analog_input_number, threshold).
#define NRF_CSENSE_SLIDER_3_DEF (   name,
  steps_no,
  p1,
  p2,
  p3 
)    NRF_CSENSE_INTERNAL_SLIDER_3_DEF(name, steps_no, p1, p2, p3)

Macro for creating a 3-pad slider instance.

Parameters
[in,out]nameName of the capacitive sensor instance that will be created.
[in]steps_noNumber of relative pads. It means that the slider in its handler will give values (1, steps_no).
[in]p1Pair of two arguments: threshold and analog_input_number. Must be passed as (analog_input_number, threshold).
[in]p2Pair of two arguments: threshold and analog_input_number. Must be passed as (analog_input_number, threshold).
[in]p3Pair of two arguments: threshold and analog_input_number. Must be passed as (analog_input_number, threshold).
#define NRF_CSENSE_SLIDER_4_DEF (   name,
  steps_no,
  p1,
  p2,
  p3,
  p4 
)    NRF_CSENSE_INTERNAL_SLIDER_4_DEF(name, steps_no, p1, p2, p3, p4)

Macro for creating a 4-pad slider instance.

Parameters
[in,out]nameName of the capacitive sensor instance that will be created.
[in]steps_noNumber of relative pads. It means that the slider in its handler will give values (1, steps_no).
[in]p1Pair of two arguments: threshold and analog_input_number. Must be passed as (analog_input_number, threshold).
[in]p2Pair of two arguments: threshold and analog_input_number. Must be passed as (analog_input_number, threshold).
[in]p3Pair of two arguments: threshold and analog_input_number. Must be passed as (analog_input_number, threshold).
[in]p4Pair of two arguments: threshold and analog_input_number. Must be passed as (analog_input_number, threshold).
#define NRF_CSENSE_SLIDER_5_DEF (   name,
  steps_no,
  p1,
  p2,
  p3,
  p4,
  p5 
)    NRF_CSENSE_INTERNAL_SLIDER_5_DEF(name, steps_no, p1, p2, p3, p4, p5)

Macro for creating a 5-pad slider instance.

Parameters
[in,out]nameName of the capacitive sensor instance that will be created.
[in]steps_noNumber of relative pads. It means that the slider in its handler will give values (1, steps_no).
[in]p1Pair of two arguments: threshold and analog_input_number. Must be passed as (analog_input_number, threshold).
[in]p2Pair of two arguments: threshold and analog_input_number. Must be passed as (analog_input_number, threshold).
[in]p3Pair of two arguments: threshold and analog_input_number. Must be passed as (analog_input_number, threshold).
[in]p4Pair of two arguments: threshold and analog_input_number. Must be passed as (analog_input_number, threshold).
[in]p5Pair of two arguments: threshold and analog_input_number. Must be passed as (analog_input_number, threshold).
#define NRF_CSENSE_WHEEL_3_DEF (   name,
  steps_no,
  p1,
  p2,
  p3 
)    NRF_CSENSE_INTERNAL_WHEEL_3_DEF(name, steps_no, p1, p2, p3)

Macro for creating a 3-pad wheel instance.

Parameters
[in,out]nameName of the capacitive sensor instance that will be created.
[in]steps_noNumber of relative pads. It means that the slider in its handler will give values (1, steps_no).
[in]p1Pair of two arguments: threshold and analog_input_number. Must be passed as (analog_input_number, threshold).
[in]p2Pair of two arguments: threshold and analog_input_number. Must be passed as (analog_input_number, threshold).
[in]p3Pair of two arguments: threshold and analog_input_number. Must be passed as (analog_input_number, threshold).
#define NRF_CSENSE_WHEEL_4_DEF (   name,
  steps_no,
  p1,
  p2,
  p3,
  p4 
)    NRF_CSENSE_INTERNAL_WHEEL_4_DEF(name, steps_no, p1, p2, p3, p4)

Macro for creating a 4-pad wheel instance.

Parameters
[in,out]nameName of the capacitive sensor instance that will be created.
[in]steps_noNumber of relative pads. It means that the slider in its handler will give values (1, steps_no).
[in]p1Pair of two arguments: threshold and analog_input_number. Must be passed as (analog_input_number, threshold).
[in]p2Pair of two arguments: threshold and analog_input_number. Must be passed as (analog_input_number, threshold).
[in]p3Pair of two arguments: threshold and analog_input_number. Must be passed as (analog_input_number, threshold).
[in]p4Pair of two arguments: threshold and analog_input_number. Must be passed as (analog_input_number, threshold).
#define NRF_CSENSE_WHEEL_5_DEF (   name,
  steps_no,
  p1,
  p2,
  p3,
  p4,
  p5 
)    NRF_CSENSE_INTERNAL_WHEEL_5_DEF(name, steps_no, p1, p2, p3, p4, p5)

Macro for creating a 5-pad wheel instance.

Parameters
[in,out]nameName of the capacitive sensor instance that will be created.
[in]steps_noNumber of relative pads. It means that the slider in its handler will give values (1, steps_no).
[in]p1Pair of two arguments: threshold and analog_input_number. Must be passed as (analog_input_number, threshold).
[in]p2Pair of two arguments: threshold and analog_input_number. Must be passed as (analog_input_number, threshold).
[in]p3Pair of two arguments: threshold and analog_input_number. Must be passed as (analog_input_number, threshold).
[in]p4Pair of two arguments: threshold and analog_input_number. Must be passed as (analog_input_number, threshold).
[in]p5Pair of two arguments: threshold and analog_input_number. Must be passed as (analog_input_number, threshold).

Enumeration Type Documentation

Enum for nrf_csense events.

Enumerator
NRF_CSENSE_BTN_EVT_PRESSED 

Event for pad pressed.

NRF_CSENSE_BTN_EVT_RELEASED 

Event for pad released.

NRF_CSENSE_SLIDER_EVT_PRESSED 

Event for pad pressed.

NRF_CSENSE_SLIDER_EVT_RELEASED 

Event for pad released.

NRF_CSENSE_SLIDER_EVT_DRAGGED 

Event for pad dragged.

Function Documentation

ret_code_t nrf_csense_add ( nrf_csense_instance_t *const  p_instance)

Function for adding an instance of capacitive sensor to a linked list.

The function calls nrf_csense_enable to enable the instance that was added to the linked list.

Parameters
[in]p_instancePointer to the capacitive sensor instance. It is saved by the module and is used whenever the instance is referred.
Returns
Values returned by nrf_csense_enable.
ret_code_t nrf_csense_disable ( nrf_csense_instance_t *const  p_instance)

Function for disabling an instance.

Parameters
[in]p_instancePointer to the instance to be disabled.
Return values
NRF_ERROR_INVALID_PARAMIf the instance was already disabled.
NRF_SUCCESSIf the instance was disabled successfully.
ret_code_t nrf_csense_enable ( nrf_csense_instance_t *const  p_instance)

Function for enabling a single instance.

Parameters
[in,out]p_instancePointer to the capacitive sensor instance. It is saved by the module and is used whenever the instance is referred.
Returns
Values returned by app_timer_start.
ret_code_t nrf_csense_init ( nrf_csense_event_handler_t  event_handler,
uint32_t  ticks 
)

Function for initializing the module. After initialization, no instances are enabled.

Parameters
[in]event_handlerEvent handler for the Capacitive Sensor module.
[in]ticksTime in app_timer ticks between next conversions.
Return values
NRF_ERROR_INVALID_PARAMIf invalid parameter was provided.
NRF_ERROR_INVALID_STATEIf one of the used modules is in invalid state.
NRF_ERROR_INTERNALIf an error occured while initializing one of the modules used by the capacitive sensor library.
NRF_SUCCESSIf the module was initialized successfully.
__STATIC_INLINE void nrf_csense_instance_context_set ( nrf_csense_instance_t *const  p_instance,
void *  p_context 
)

Function for setting a handler of the instance.

Parameters
[in]p_instancePointer to the instance whose steps are going to be changed.
[in]p_contextGeneral purpose pointer. Will be passed to the callback function.
ret_code_t nrf_csense_steps_set ( nrf_csense_instance_t *const  p_instance,
uint16_t  steps 
)

Function for setting steps of an instance.

Note that you have do disable the instance before you can change its number of steps.

Parameters
[in]p_instancePointer to the instance whose steps are going to be changed.
[in]stepsNew steps value.
Return values
NRF_ERROR_BUSYIf the capacitive sensor was busy.
NRF_SUCCESSIf steps were set successfully.
ret_code_t nrf_csense_ticks_set ( uint32_t  ticks)

Function for setting ticks between next measurements.

Parameters
[in]ticksNew time between conversions in app_timer ticks.
Return values
NRF_ERROR_BUSYIf the capacitive sensor was busy.
NRF_ERROR_INVALID_PARAMIf an invalid parameter was provided.
NRF_ERROR_INVALID_STATEIf app_timer was in invalid state.
NRF_SUCCESSIf ticks were set successfully.
ret_code_t nrf_csense_uninit ( void  )

Function for uninitializing the module.

Returns
Values returned by nrf_drv_csense_uninit and app_timer_stop.

Documentation feedback | Developer Zone | Subscribe | Updated