High-level functions represent the highest abstraction layer of the CapSense middleware.
These functions perform tasks such as scanning, data processing, data reporting and tuning interfaces. When performing a task, different initialization is required based on a sensing method or type of widgets is automatically handled by these functions. Therefore, these functions are sensing methods, features, and widget type agnostics.
All the tasks required to implement a sensing system can be fulfilled by the high-level functions. But, there is a set of Low-level Functions that provides access to lower level and specific tasks. If a design requires access to low-level tasks, these functions can be used. The functions related to a given sensing methods are not available if the corresponding method is disabled.
Functions | |
cy_status | Cy_CapSense_Init (cy_stc_capsense_context_t *context) |
Captures the CSD HW block and configures it to the default state. More... | |
cy_status | Cy_CapSense_DeInit (cy_stc_capsense_context_t *context) |
Stops the middleware operation and releases the CSD HW block. More... | |
cy_status | Cy_CapSense_Enable (cy_stc_capsense_context_t *context) |
Initializes the CapSense firmware modules. More... | |
cy_status | Cy_CapSense_Save (cy_stc_capsense_context_t *context) |
Saves the state of CapSense so the functionality can be restored using the Cy_CapSense_Restore() function. More... | |
cy_status | Cy_CapSense_Restore (cy_stc_capsense_context_t *context) |
Resumes the middleware operation if the Cy_CapSense_Save() function was called previously. More... | |
cy_status | Cy_CapSense_ProcessAllWidgets (cy_stc_capsense_context_t *context) |
Performs full data processing of all enabled widgets. More... | |
cy_status | Cy_CapSense_ProcessWidget (uint32_t widgetId, cy_stc_capsense_context_t *context) |
Performs full data processing of the specified widget if it is enabled. More... | |
void | Cy_CapSense_IncrementGestureTimestamp (cy_stc_capsense_context_t *context) |
Increments the timestamp register for the predefined timestamp interval. More... | |
void | Cy_CapSense_SetGestureTimestamp (uint32_t value, cy_stc_capsense_context_t *context) |
Rewrites the timestamp register by the specified value. More... | |
void | Cy_CapSense_Wakeup (const cy_stc_capsense_context_t *context) |
Resumes the middleware after Deep Sleep. More... | |
cy_en_syspm_status_t | Cy_CapSense_DeepSleepCallback (cy_stc_syspm_callback_params_t *callbackParams, cy_en_syspm_callback_mode_t mode) |
Handles Active to Deep Sleep power mode transition for the CapSense middleware. More... | |
cy_status | Cy_CapSense_RegisterCallback (cy_en_capsense_callback_event_t callbackType, cy_capsense_callback_t callbackFunction, cy_stc_capsense_context_t *context) |
Registers a callback function. More... | |
cy_status | Cy_CapSense_UnRegisterCallback (cy_en_capsense_callback_event_t callbackType, cy_stc_capsense_context_t *context) |
This function unregisters a previously registered callback function in the CapSense middleware. More... | |
uint32_t | Cy_CapSense_DecodeWidgetGestures (uint32_t widgetId, const cy_stc_capsense_context_t *context) |
Performs processing of all gestures for the specified widget. More... | |
cy_status | Cy_CapSense_SetupWidget (uint32_t widgetId, cy_stc_capsense_context_t *context) |
Performs the initialization required to scan the specified widget. More... | |
cy_status | Cy_CapSense_Scan (cy_stc_capsense_context_t *context) |
Initiates scanning of all the sensors in the widget initialized by Cy_CapSense_SetupWidget(), if no scan is in progress. More... | |
cy_status | Cy_CapSense_ScanAllWidgets (cy_stc_capsense_context_t *context) |
Initiates scanning of all enabled widgets (and sensors) in the project. More... | |
uint32_t | Cy_CapSense_IsBusy (const cy_stc_capsense_context_t *context) |
This function returns a status of the CapSense middleware whether a scan is currently in progress or not. More... | |
void | Cy_CapSense_InterruptHandler (const CSD_Type *base, cy_stc_capsense_context_t *context) |
Implements interrupt service routine for CapSense Middleware. More... | |
uint32_t | Cy_CapSense_IsAnyWidgetActive (const cy_stc_capsense_context_t *context) |
Reports whether any widget has detected touch. More... | |
uint32_t | Cy_CapSense_IsWidgetActive (uint32_t widgetId, const cy_stc_capsense_context_t *context) |
Reports whether the specified widget detected touch on any of its sensors. More... | |
uint32_t | Cy_CapSense_IsSensorActive (uint32_t widgetId, uint32_t sensorId, const cy_stc_capsense_context_t *context) |
Reports whether the specified sensor in the widget detected touch. More... | |
uint32_t | Cy_CapSense_IsProximitySensorActive (uint32_t widgetId, uint32_t sensorId, const cy_stc_capsense_context_t *context) |
Reports the status of the specified proximity widget/sensor. More... | |
cy_stc_capsense_touch_t * | Cy_CapSense_GetTouchInfo (uint32_t widgetId, const cy_stc_capsense_context_t *context) |
Reports the details of touch position detected on the specified touchpad, matrix buttons or slider widgets. More... | |
uint32_t | Cy_CapSense_RunTuner (cy_stc_capsense_context_t *context) |
Establishes synchronized operation between the CapSense middleware and the CapSense Tuner tool. More... | |
uint32_t | Cy_CapSense_CheckCommandIntegrity (const uint8_t *commandPacket) |
Checks command format, header, tail, CRC, etc. More... | |
cy_status Cy_CapSense_Init | ( | cy_stc_capsense_context_t * | context | ) |
Captures the CSD HW block and configures it to the default state.
This function is called by the application program prior to calling any other function of the middleware.
The following tasks are executed:
After the middleware is configured using Cy_CapSense_Init() function, application program should configure and enable the CSD block interrupt, and then call of the Cy_CapSense_Enable() function to complete the middleware initialization process. See the function usage example below for more details.
When the middleware operation is stopped by the Cy_CapSense_DeInit() function, subsequent call of the Cy_CapSense_Init() function repeats initialization process and it is not needed to call the Cy_CapSense_Enable() function second time. However, to implement time-multiplexed mode (sharing the CSD HW Block between multiple middleware) the Cy_CapSense_Save() and Cy_CapSense_Restore() functions should be used instead of the Cy_CapSense_DeInit() and Cy_CapSense_Init() functions for further compatibility.
context | The pointer to the CapSense context structure cy_stc_capsense_context_t generated by the CapSense Configurator tool. The structure contains both, CapSense configuration and internal data and it is used during whole CapSense operation. |
The 'cy_capsense_context' variable that is used as the parameter of the Cy_CapSense_Init() and Cy_CapSense_Enable() functions is declared in the cycfg_capsense.h file.
The CapSense_ISR_cfg variable should be declared by the application program according to the examples below:
For CM0+ core:
For CM4 core:
The CapSense interrupt handler should be declared by the application program according to the example below:
The CapSense_HW is the pointer to the base register address of the CSD HW block. A macro for the pointer can be found in cycfg_peripherals.h file defined as <Csd_Personality_Name>_HW. If no name specified then the default name is used csd_<Block_Number>_csd_<Block_Number>_HW.
cy_status Cy_CapSense_DeInit | ( | cy_stc_capsense_context_t * | context | ) |
Stops the middleware operation and releases the CSD HW block.
No sensor scanning can be executed when the middleware is stopped. This function should be called only when no scanning is in progress. I.e. Cy_CapSense_IsBusy() returns a non-busy status.
After it is stopped, the CSD HW block may be reconfigured by the application program or other middleware for any other usage.
When the middleware operation is stopped by the Cy_CapSense_DeInit() function, subsequent call of the Cy_CapSense_Init() function repeats initialization process and it is not needed to call the Cy_CapSense_Enable() function second time. However, to implement time-multiplexed mode (sharing the CSD HW Block between multiple middleware) the Cy_CapSense_Save() and Cy_CapSense_Restore() functions should be used instead of the Cy_CapSense_DeInit() and Cy_CapSense_Init() functions for further compatibility.
context | The pointer to the CapSense context structure cy_stc_capsense_context_t. |
cy_status Cy_CapSense_Enable | ( | cy_stc_capsense_context_t * | context | ) |
Initializes the CapSense firmware modules.
This function requires the Cy_CapSense_Init() function is called and the CSD HW block interrupt to be configured prior to calling this function. See the function usage example below for details on usage.
The following are executed as part of the function:
Any subsequent call of this function repeats initialization process. Therefore, it is possible to change the middleware configuration from the application program by writing registers to the data structure and calling this function again.
The repeated call of this function is also done inside the Cy_CapSense_RunTuner() function when a restart command is received.
context | The pointer to the CapSense context structure cy_stc_capsense_context_t. |
The 'cy_capsense_context' variable that is used as the parameter of the Cy_CapSense_Init() and Cy_CapSense_Enable() functions is declared in the cycfg_capsense.h file.
The CapSense_ISR_cfg variable should be declared by the application program according to the examples below:
For CM0+ core:
For CM4 core:
The CapSense interrupt handler should be declared by the application program according to the example below:
The CapSense_HW is the pointer to the base register address of the CSD HW block. A macro for the pointer can be found in cycfg_peripherals.h file defined as <Csd_Personality_Name>_HW. If no name is specified then the default name is used csd_<Block_Number>_csd_<Block_Number>_HW.
cy_status Cy_CapSense_Save | ( | cy_stc_capsense_context_t * | context | ) |
Saves the state of CapSense so the functionality can be restored using the Cy_CapSense_Restore() function.
This function, along with the Cy_CapSense_Restore() function, is specifically designed for ease of use and supports time multiplexing of the CSD HW block among multiple middlewares. When the CSD HW block is shared by two or more middlewares, this function can be used to save the current state of the CSD HW block and CapSense middleware prior to releasing the CSD HW block for use by other middleware. See the function usage example below for details on usage.
This function performs the same tasks as the Cy_CapSense_DeInit() function and is kept for API consistency among middlewares. It is recommended to use Cy_CapSense_Save() and Cy_CapSense_Restore() functions to implement Time-multiplexed mode instead of Cy_CapSense_DeInit() and Cy_CapSense_Init() functions for further compatibility.
This function performs the following operations:
context | The pointer to the CapSense context structure cy_stc_capsense_context_t. |
An example of sharing the CSD HW block by the CapSense and CSDADC middleware.
Declares the CapSense_ISR_cfg variable:
Declares the CSDADC_ISR_cfg variable:
Defines the CapSense interrupt handler:
Defines the CSDADC interrupt handler:
The part of the main.c FW flow:
cy_status Cy_CapSense_Restore | ( | cy_stc_capsense_context_t * | context | ) |
Resumes the middleware operation if the Cy_CapSense_Save() function was called previously.
This function, along with the Cy_CapSense_Save() function is specifically designed for ease of use and supports time multiplexing of the CSD HW block among multiple middlewares. When the CSD HW block is shared by two or more middlewares, this function can be used to restore the previous state of the CSD HW block and CapSense middleware saved using the Cy_CapSense_Save() function. See the function usage example below for details on usage.
This function performs the same tasks as Cy_CapSense_Init() function and is kept for API consistency among middlewares. It is recommended to use Cy_CapSense_Save() and Cy_CapSense_Restore() functions to implement time-multiplexed mode instead of Cy_CapSense_DeInit() and Cy_CapSense_Init() functions for further compatibility.
context | The pointer to the CapSense context structure cy_stc_capsense_context_t. |
An example of sharing the CSD HW block by CapSense and CSDADC middleware:
cy_status Cy_CapSense_ProcessAllWidgets | ( | cy_stc_capsense_context_t * | context | ) |
Performs full data processing of all enabled widgets.
This function performs all data processes for all enabled widgets and sensors in the middleware to produce meaningful status output from widgets and sensors. The following tasks are executed as part of processing all the widgets:
This function is called by the application program only after all the enabled widgets (and sensors) in the middleware are scanned. Calling this function multiple times without sensor scanning causes unexpected behavior.
The disabled widgets are not processed by this function.
context | The pointer to the CapSense context structure cy_stc_capsense_context_t. |
cy_status Cy_CapSense_ProcessWidget | ( | uint32_t | widgetId, |
cy_stc_capsense_context_t * | context | ||
) |
Performs full data processing of the specified widget if it is enabled.
This function performs exactly the same tasks as Cy_CapSense_ProcessAllWidgets(), but only for a specified widget. This function can be used along with the Cy_CapSense_SetupWidget() and Cy_CapSense_Scan() functions to scan and process data for a specific widget. This function is called only after all the sensors in the widgets are scanned. A disabled widget is not processed by this function.
A pipeline scan method (i.e. during scanning of a widget performing processing of the previously scanned widget) can be implemented using this function and it may reduce the total execution time, increase the refresh rate and decrease the average power consumption.
A pipeline scan method (i.e. during scanning of a current widget (N), perform processing of the previously scanned widget (N-1)) can be implemented using this function and it may reduce the total execution time, increase the refresh rate, and decrease the average power consumption. See the function usage example below for details on usage.
widgetId | Specifies the ID number of the widget. A macro for the widget ID can be found in the cycfg_capsense.h file defined as CY_CAPSENSE_<WIDGET_NAME>_WDGT_ID. |
context | The pointer to the CapSense context structure cy_stc_capsense_context_t. |
An example of pipeline implementation:
void Cy_CapSense_IncrementGestureTimestamp | ( | cy_stc_capsense_context_t * | context | ) |
Increments the timestamp register for the predefined timestamp interval.
A timestamp is required for operation of the Gesture and Ballistic multiplier feature. Hence this function and timestamp is required only if the Gesture detection or Ballistic multiplier feature is enabled.
This function increments the timestamp by the interval specified in the context->ptrCommonContext->timestampInterval register. The unit for the timestamp and timestamp interval is milliseconds and the default value of the interval is 1.
The application program must periodically call this function or register a periodic callback to this function to keep the timestamp updated and operational for the operation of the Gesture and Ballistic multiplier feature.
The timestamp can be updated in one of the three methods:
See the function usage example below for more details.
The interval at which this function is called should match with interval defined in context->ptrCommonContext->timestampInterval register. Either the register value can be updated to match the callback interval or the callback can be made at interval set in the register.
If a timestamp is available from another source, the application program may choose to periodically update the timestamp by using the Cy_CapSense_SetGestureTimestamp() function instead of registering a callback.
context | The pointer to the CapSense context structure cy_stc_capsense_context_t. |
An example of timestamp updating:
void Cy_CapSense_SetGestureTimestamp | ( | uint32_t | value, |
cy_stc_capsense_context_t * | context | ||
) |
Rewrites the timestamp register by the specified value.
This function writes the specified value into the middleware timestamp context->ptrCommonContext->timestamp register.
If a timestamp is available from another source, the application program may choose to periodically update the timestamp by using this function instead of registering a callback.
Do not modify the timestamp arbitrarily or simultaneously use with the Cy_CapSense_IncrementGestureTimestamp() function, which may result in unexpected result.
value | Specifies the timestamp value (in ms). |
context | The pointer to the CapSense context structure cy_stc_capsense_context_t. |
void Cy_CapSense_Wakeup | ( | const cy_stc_capsense_context_t * | context | ) |
Resumes the middleware after Deep Sleep.
This function is used to resume the middleware operation after exiting Deep Sleep. In Deep Sleep power mode, the CSD HW block is powered off and an extra delay is required to establish correct operation of the CSD HW block.
context | The pointer to the CapSense context structure cy_stc_capsense_context_t. |
cy_en_syspm_status_t Cy_CapSense_DeepSleepCallback | ( | cy_stc_syspm_callback_params_t * | callbackParams, |
cy_en_syspm_callback_mode_t | mode | ||
) |
Handles Active to Deep Sleep power mode transition for the CapSense middleware.
Calling this function directly from the application program is not recommended. Instead, Cy_SysPm_DeepSleep() should be used for the Active to Deep Sleep power mode transition of the device.
For proper operation of the CapSense middleware during the Active to Deep Sleep mode transition, a callback to this function should be registered using the Cy_SysPm_RegisterCallback() function with CY_SYSPM_DEEPSLEEP type. After the callback is registered, this function is called by the Cy_SysPm_DeepSleep() function to prepare the middleware to the device power mode transition.
When this function is called with CY_SYSPM_CHECK_READY as input, this function returns CY_SYSPM_SUCCESS if no scanning is in progress. Otherwise CY_SYSPM_FAIL is returned. If CY_SYSPM_FAIL status is returned, a device cannot change the power mode without completing the current scan as a transition to Deep Sleep during the scan can disrupt the middleware operation.
callbackParams | Refer to the description of the cy_stc_syspm_callback_params_t type in the Peripheral Driver Library documentation. |
mode | Specifies mode cy_en_syspm_callback_mode_t. |
cy_status Cy_CapSense_RegisterCallback | ( | cy_en_capsense_callback_event_t | callbackType, |
cy_capsense_callback_t | callbackFunction, | ||
cy_stc_capsense_context_t * | context | ||
) |
Registers a callback function.
The registered function will be called by the CapSense middleware when the specified event cy_en_capsense_callback_event_t has occurred in the CapSense middleware.
callbackType | The event on which the registered function is called by the CapSense middleware. Refer to cy_en_capsense_callback_event_t for the list of supported events. |
callbackFunction | The pointer to the callback function to be called by the middleware. |
context | The pointer to the CapSense context structure cy_stc_capsense_context_t. |
cy_status Cy_CapSense_UnRegisterCallback | ( | cy_en_capsense_callback_event_t | callbackType, |
cy_stc_capsense_context_t * | context | ||
) |
This function unregisters a previously registered callback function in the CapSense middleware.
callbackType | The event on which the function should be unregistered. Refer to cy_en_capsense_callback_event_t for the list of supported events. |
context | The pointer to the CapSense context structure cy_stc_capsense_context_t. |
uint32_t Cy_CapSense_DecodeWidgetGestures | ( | uint32_t | widgetId, |
const cy_stc_capsense_context_t * | context | ||
) |
Performs processing of all gestures for the specified widget.
This function should be called by application program only after all sensors are scanned and all data processing is executed using Cy_CapSense_ProcessAllWidgets() or Cy_CapSense_ProcessWidget() functions for the widget. Calling this function multiple times without a new sensor scan and process causes unexpected behavior.
widgetId | Specifies the ID number of the widget. A macro for the widget ID can be found in the cycfg_capsense.h file defined as CY_CAPSENSE_<WIDGET_NAME>_WDGT_ID. |
context | The pointer to the CapSense context structure cy_stc_capsense_context_t. |
An example of gesture decoding:
An example of gesture status parsing:
cy_status Cy_CapSense_SetupWidget | ( | uint32_t | widgetId, |
cy_stc_capsense_context_t * | context | ||
) |
Performs the initialization required to scan the specified widget.
This function prepares the middleware to scan all the sensors in the specified widget by executing the following tasks:
This function does not start sensor scanning. The Cy_CapSense_Scan() function must be called to start the scan sensors in the widget. If this function is called more than once, it does not break the middleware operation, but only the last initialized widget is in effect.
The status of a sensor scan must be checked using the Cy_CapSense_IsBusy() function prior to starting a next scan or setting up another widget.
widgetId | Specifies the ID number of the widget. A macro for the widget ID can be found in the cycfg_capsense.h file defined as CY_CAPSENSE_<WIDGET_NAME>_WDGT_ID. |
context | The pointer to the CapSense context structure cy_stc_capsense_context_t. |
cy_status Cy_CapSense_Scan | ( | cy_stc_capsense_context_t * | context | ) |
Initiates scanning of all the sensors in the widget initialized by Cy_CapSense_SetupWidget(), if no scan is in progress.
Prior to calling this function to scan sensors, the widget required to be scanned must be initialized using Cy_CapSense_SetupWidget() function.
This function initiates scan only for the first sensor in the widget and then exits the function. The scan for the remaining sensors in the widget is initiated in the interrupt service routine (part of middleware) trigged at the end of each scan completion. Hence, status of the current scan should be checked using the Cy_CapSense_IsBusy() and wait until all scans in the current widget are finished prior to starting the next scan or initializing another widget.
context | The pointer to the CapSense context structure cy_stc_capsense_context_t. |
cy_status Cy_CapSense_ScanAllWidgets | ( | cy_stc_capsense_context_t * | context | ) |
Initiates scanning of all enabled widgets (and sensors) in the project.
The tasks of both Cy_CapSense_SetupWidget() and Cy_CapSense_Scan() functions are executed by this function. The status of a sensor scan must be checked using the Cy_CapSense_IsBusy() prior to starting the next scan or setting up another widget.
This function initiates a scan only for the first sensor in the first widget and then exits the function. The scan for the remaining sensors are initiated in the interrupt service routine (part of middleware) trigged at the end of each scan completion. Hence, the status of the current scan should be checked using the Cy_CapSense_IsBusy() and wait until all scans is finished prior to starting a next scan or initializing another widget.
context | The pointer to the CapSense context structure cy_stc_capsense_context_t. |
uint32_t Cy_CapSense_IsBusy | ( | const cy_stc_capsense_context_t * | context | ) |
This function returns a status of the CapSense middleware whether a scan is currently in progress or not.
If the middleware is busy, a new scan or setup widgets should not be initiated.
context | The pointer to the CapSense context structure cy_stc_capsense_context_t. |
void Cy_CapSense_InterruptHandler | ( | const CSD_Type * | base, |
cy_stc_capsense_context_t * | context | ||
) |
Implements interrupt service routine for CapSense Middleware.
The CSD HW block generates an interrupt at end of every sensor scan. The CapSense middleware uses this interrupt to implement a non-blocking sensor scan method, in which only the first sensor scan is initiated by the application program and subsequent sensor scans are initiated in the interrupt service routine as soon as the current scan is completed. The above stated interrupt service routine is implemented as a part of the CapSense middleware.
The CapSense middleware does not initialize or modify the priority of interrupts. For the operation of middleware, the application program must configure CSD interrupt and assign interrupt vector to the Cy_CapSense_InterruptHandler() function. Refer to function usage example for details.
base | The pointer to the base register address of the CSD HW block. A macro for the pointer can be found in cycfg_peripherals.h file defined as <Csd_Personality_Name>_HW. If no name is specified then the default name is used csd_<Block_Number>_csd_<Block_Number>_HW. |
context | The pointer to the CapSense context structure cy_stc_capsense_context_t. |
An example of the ISR initialization:
The CapSense_ISR_cfg variable should be declared by the application program according to the examples below:
For Core CM0+:
For Core CM4:
The CapSense interrupt handler should be defined by the application program according to the example below:
Then, the application program should configure and enable the CSD block interrupt between calls of the Cy_CapSense_Init() and Cy_CapSense_Enable() functions:
CapSense_HW is the pointer to the base register address of the CSD HW block. A macro for the pointer can be found in the cycfg_peripherals.h file defined as <Csd_Personality_Name>_HW. If no name specified, the default name is used csd_<Block_Number>_csd_<Block_Number>_HW.
An example of sharing the CSD HW block by the CapSense and CSDADC middleware.
Declares the CapSense_ISR_cfg variable:
Declares the CSDADC_ISR_cfg variable:
Defines the CapSense interrupt handler:
Defines the CSDADC interrupt handler:
The part of the main.c FW flow:
uint32_t Cy_CapSense_IsAnyWidgetActive | ( | const cy_stc_capsense_context_t * | context | ) |
Reports whether any widget has detected touch.
This function reports whether any widget has detected a touch by extracting information from the widget status registers. This function does not process widget data but extracts previously processed results from the CapSense Structures.
context | The pointer to the CapSense context structure cy_stc_capsense_context_t. |
uint32_t Cy_CapSense_IsWidgetActive | ( | uint32_t | widgetId, |
const cy_stc_capsense_context_t * | context | ||
) |
Reports whether the specified widget detected touch on any of its sensors.
This function reports whether the specified widget has detected a touch by extracting information from the widget status register. This function does not process widget data but extracts previously processed results from the CapSense Structures.
widgetId | Specifies the ID number of the widget. A macro for the widget ID can be found in the cycfg_capsense.h file defined as CY_CAPSENSE_<WIDGET_NAME>_WDGT_ID. |
context | The pointer to the CapSense context structure cy_stc_capsense_context_t. |
uint32_t Cy_CapSense_IsSensorActive | ( | uint32_t | widgetId, |
uint32_t | sensorId, | ||
const cy_stc_capsense_context_t * | context | ||
) |
Reports whether the specified sensor in the widget detected touch.
This function reports whether the specified sensor in the widget has detected a touch by extracting information from the widget status register. This function does not process widget or sensor data but extracts previously processed results from the CapSense Structures.
For proximity sensors, this function returns the proximity detection status. To get the touch status of proximity sensors, use the Cy_CapSense_IsProximitySensorActive() function.
widgetId | Specifies the ID number of the widget. A macro for the widget ID can be found in the cycfg_capsense.h file defined as CY_CAPSENSE_<WIDGET_NAME>_WDGT_ID. |
sensorId | Specifies the ID number of the sensor within the widget. A macro for the sensor ID within a specified widget can be found in the cycfg_capsense.h file defined as CY_CAPSENSE_<WIDGET_NAME>_SNS<SENSOR_NUMBER>_ID. |
context | The pointer to the CapSense context structure cy_stc_capsense_context_t. |
uint32_t Cy_CapSense_IsProximitySensorActive | ( | uint32_t | widgetId, |
uint32_t | sensorId, | ||
const cy_stc_capsense_context_t * | context | ||
) |
Reports the status of the specified proximity widget/sensor.
This function reports whether the specified proximity sensor has detected a touch or proximity event by extracting information from the widget status register. This function is used only with proximity widgets. This function does not process widget data but extracts previously processed results from the CapSense Structures.
widgetId | Specifies the ID number of the widget. A macro for the widget ID can be found in the cycfg_capsense.h file defined as CY_CAPSENSE_<WIDGET_NAME>_WDGT_ID. |
sensorId | Specifies the ID number of the sensor within the widget. A macro for the sensor ID within a specified widget can be found in the cycfg_capsense.h file defined as CY_CAPSENSE_<WIDGET_NAME>_SNS<SENSOR_NUMBER>_ID. |
context | The pointer to the CapSense context structure cy_stc_capsense_context_t. |
cy_stc_capsense_touch_t* Cy_CapSense_GetTouchInfo | ( | uint32_t | widgetId, |
const cy_stc_capsense_context_t * | context | ||
) |
Reports the details of touch position detected on the specified touchpad, matrix buttons or slider widgets.
This function does not process widget data but extracts previously processed results from the CapSense Structures.
widgetId | Specifies the ID number of the widget. A macro for the widget ID can be found in the cycfg_capsense.h file defined as CY_CAPSENSE_<WIDGET_NAME>_WDGT_ID. |
context | The pointer to the CapSense context structure cy_stc_capsense_context_t. |
uint32_t Cy_CapSense_RunTuner | ( | cy_stc_capsense_context_t * | context | ) |
Establishes synchronized operation between the CapSense middleware and the CapSense Tuner tool.
This function should be called periodically in the application program to serve the CapSense Tuner tool requests and commands to synchronize the operation, however there is no specific timing requirement for this function. In most cases, the best place to call this function is after processing and before next scanning.
If a user changes some parameters in the Tuner tool, a re-initialization of the middleware is required. In such cases, the tuner issues a re-initialize command and which is executed by this function.
If this function is not called by the application program, the middleware operation is asynchronous to the Tuner tool and the following disadvantages are applicable:
context | The pointer to the CapSense context structure cy_stc_capsense_context_t. |
An example of synchronization with the Tuner tool using EzI2C:
An example of synchronization with the Tuner tool using UART.
Tuner Send callback implementation: Transmitting data through UART interface:
Tuner Receive callback implementation: Receiving data from UART interface:
A part of the main.c FW flow with registering callbacks:
Refer to the Callbacks section for details.
uint32_t Cy_CapSense_CheckCommandIntegrity | ( | const uint8_t * | commandPacket | ) |
Checks command format, header, tail, CRC, etc.
This function checks whether the specified packet with the size CY_CAPSENSE_COMMAND_PACKET_SIZE could be represented as a command received from the CapSense Tuner tool. The verification includes the following items:
Command format is the following:
commandPacket | The pointer to the data packet that should be verified. |