CAPSENSE™ Middleware Library 3.0
Callbacks

Callbacks allow the user to execute Custom code called from the CAPSENSE™ middleware when an event occurs.

CAPSENSE™ supports several callbacks.

# Callback Name Associated Register Callback Function Prototype Description
1 Start Sample ptrSSCallback cy_capsense_callback_t This is called before each sensor scan triggering. Such a callback can be used to implement user-specific use cases like changing scan parameters depending on whether a sensor is going to be scanned. For the fifth-generation CAPSENSE™ in CS-DMA mode this callback is called only once in Cy_CapSense_ScanSlots() function with NULL passed as a parameter. In INT driven mode it is called in Cy_CapSense_ScanSlots() and in Cy_CapSense_ScanISR() function before HW starting the scan.
2 End Of Scan ptrEOSCallback cy_capsense_callback_t This is called after sensor scan completion and there is no other sensor in the queue to be scanned. For the fifth-generation CAPSENSE™ in CS-DMA mode this callback is called with NULL passed as a parameter.
3 Tuner Send Callback ptrTunerSendCallback cy_capsense_tuner_send_callback_t This is called by the Cy_CapSense_RunTuner() function to establish synchronous communication with the Tuner tool.
4 Tuner Receive Callback ptrTunerReceiveCallback cy_capsense_tuner_receive_callback_t This is called by the Cy_CapSense_RunTuner() function to establish synchronous communication with the Tuner tool.
5 CAPSENSE™ Data Structure Initialization Callback ptrEODsInitCallback cy_capsense_ds_init_callback_t This is called by the Cy_CapSense_Enable() function after CAPSENSE™ Data Structure initialization complete and before launching the first initialization scan. Using this callback is not recommended. It is used only to implement only user's specific use cases (while changing the CAPSENSE™ default configuration). The callback is available for Fifth Generation CAPSENSE™ devices.
Note
Callbacks 1 and 2 are called by the Cy_CapSense_InterruptHandler() function and lengthen this function execution. Usually, Cy_CapSense_InterruptHandler() is called inside the ISR. Then these callbacks also lengthen the ISR execution.

All callbacks can be registered by direct assignment of the function pointers to the corresponding CAPSENSE™ Data Structure field after call of the Cy_CapSense_Init() function as follows:

Callbacks 1 and 2 can be registered / unregistered using the Cy_CapSense_RegisterCallback() and Cy_CapSense_UnRegisterCallback() functions.