Callbacks¶
-
group
group_capsense_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
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 fifth-generation CapSense in CS-DMA mode this callback is called only once in Cy_CapSense_ScanSlots() function. 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
This is called after sensor scan completion and there is no other sensor in the queue to be scanned.
3
Tuner Send Callback
ptrTunerSendCallback
This is called by the Cy_CapSense_RunTuner() function to establish synchronous communication with the Tuner tool.
4
Tuner Receive Callback
ptrTunerReceiveCallback
This is called by the Cy_CapSense_RunTuner() function to establish synchronous communication with the Tuner tool.
5
CapSense Data Structure Initialization Callback
ptrEODsInitCallback
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.
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: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.
context->ptrInternalContext-><Associated Register> = &CallbackFunction;
Callbacks 1 and 2 can be registered / unregistered using the Cy_CapSense_RegisterCallback() and Cy_CapSense_UnRegisterCallback() functions.