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.
|
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.
|
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).
|
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:
context->ptrInternalContext-><Associated Register> = &CallbackFunction;
Callbacks 1 and 2 can be registered / unregistered using the Cy_CapSense_RegisterCallback() and Cy_CapSense_UnRegisterCallback() functions.