CapSense is a Cypress capacitive sensing solution. Capacitive sensing can be used in a variety of applications and products where conventional mechanical buttons can be replaced with sleek human interfaces to transform the way users interact with electronic systems. These include home appliances, and automotive, IoT, and industrial applications. CapSense supports multiple interfaces (widgets) using both CSX and CSD sensing methods with robust performance.
CapSense has become a popular technology to replace conventional mechanical- and optical-based user interfaces. There are fewer parts involved, which saves cost and increases reliability with no wear-and-tear. The main advantages of CapSense compared with other solutions are: robust performance in harsh environmental conditions and rejection of a wide range of external noise sources.
Use CapSense for:
The CSD HW block enables multiple sensing capabilities on PSoC devices including self-cap and mutual-cap capacitive touch sensing solution, a 10-bit ADC, IDAC, and Comparator. The CSD driver is a low-level peripheral driver, a wrapper to manage access to the CSD HW block. Each middleware access to the CSD HW block is through the CSD Driver.
The CSD HW block can support only one function at a time. However, all supported functionality (like CapSense, ADC, etc.) can be time-multiplexed in a design. I.e. you can save the existing state of the CapSense middleware, restore the state of the ADC middleware, perform ADC measurements, and then switch back to the CapSense functionality. For more details and code examples refer to the description of the Cy_CapSense_Save() and Cy_CapSense_Restore() functions.
This section describes only CapSense middleware. Refer to the corresponding sections for documentation of other middleware supported by the CSD HW block.
A CapSense solution includes:
Include cy_capsense.h to get access to all functions and other declarations in this library. If you are using the ModusToolbox CapSense Configurator tool, you can include cycfg_capsense.h only.
Cypress CapSense middleware can be used in various Development Environments such as ModusToolbox, MBED, etc. Refer to the Supported Software and Tools. The quickest way to get started is using the Code Examples. Cypress Semiconductor continuously extends its portfolio of the code examples at the Cypress Semiconductor website and at the Cypress Semiconductor GitHub.
This quick start guide assumes that the environment is configured to use the PSoC 6 Peripheral Driver Library(psoc6pdl) for development and the PSoC 6 Peripheral Driver Library(psoc6pdl) is included in the project. It also assumes the ModusToolbox Device Configurator Tool, ModusToolbox CapSense Configurator Tool, and ModusToolbox CapSense Tuner Tool are installed on your machine.
You can immediately start with the following MBED OS code example available at the Cypress Semiconductor GitHub:
If you are doing your own project, remember to include cycfg.h file:
and call the resource initialization functions in main() at the beginning:
The CapSense operates on the top of the CapSense Sigma Delta (CSD) driver. Refer to the PDL API Reference Manual.
This document provides descriptions of the functions in the CapSense middleware library, and descriptions of the data structures (register map) used by the middleware library.
The Application Programming Interface (API) routines allow controlling and executing specific tasks using the CapSense middleware. The CapSense API is described in the following sections:
This version of the CapSense Middleware was validated for compatibility with the following Software and Tools:
| Software and Tools | Version |
|---|---|
| ModusToolbox Software Environment | 2.0 |
| - ModusToolbox Device Configurator | 2.0 |
| - ModusToolbox CSD Personality in Device Configurator | 2.0 |
| - ModusToolbox CapSense Configurator tool | 2.0 |
| - ModusToolbox CapSense Tuner tool | 2.0 |
| PSoC6 Peripheral Driver Library (PDL) | 1.2.0 |
| GCC Compiler | 7.2.1 |
| IAR Compiler | 8.32 |
| Arm Compiler 6 (Note 1) | 6.11 |
| MBED OS | 5.13.1 |
| FreeRTOS | 10.0.1 |
Note 1 The CapSense middleware includes the pre-compiled libraries for Arm Compiler 6. They are built with the following options to be compatible with ModusToolbox and MBED:
To operate in custom environments with Arm Compiler 6, apply the above mentioned build options.
Refer to the Changelog to learn about the design impact of the newer version. Set up your environment in accordance with Supported Software and Tools.
Ensure:
You might need to re-generate the configuration structures for either the device initialization code or the middleware initialization code.
The CapSense middleware Flash and RAM memory consumption varies:
The table below provides the middleware total memory consumption for specific CapSense configurations. Memory consumption for any custom design/configuration can be determined by analyzing a *.map file generated by the compiler.
The measurements were done with GCC compiler configured in the Release mode with optimization set for Size.
| Configuration: | Configuration 1 | Configuration 2 | Configuration 3 | Configuration 4 | Configuration 5 |
|---|---|---|---|---|---|
Flash: | < 12000 | < 14050 | < 17400 | < 18600 | < 27000 |
SRAM: | < 370 | < 700 | < 2180 | < 1050 | < 4250 |
| Widgets | |||||
| CSD Button | 1 (6 sensors) | 1 (6 sensors) | 1 (2 sensors) | 1 (6 sensors) | |
| CSD Matrix Buttons | |||||
| CSD Slider | 1 (9 segments) | 1 (9 segments) | |||
| CSD Touchpad | 1 (9 Cols and 8 Rows) | 1 (9 Cols and 8 Rows) | |||
| CSD Proximity | 1 (1 sensor) | 1 (1 sensor) | 1 (1 sensor) | ||
| CSX Button | |||||
| CSX Matrix Buttons | 1 (3 Rx and 3 Tx) | ||||
| CSX Touchpad | 1 (9 Rx and 8 Tx) | 1 (9 Rx and 8 Tx) | |||
| Features | |||||
| Gesture | enabled | enabled | enabled | ||
| Ballistic Multiplier | enabled | enabled | |||
| Centroid Type | 3x3 | 3x3 | 5x5 CSD, 3x3 CSX | ||
| Supported fingers on touchpad | 2 | 1 | 2 | ||
| Shield | enabled | enabled | enabled | ||
| SmartSense | enabled | ||||
| CSD auto-calibration | enabled | enabled | enabled | enabled | |
| CSX auto-calibration | enabled | enabled | |||
| Raw Count Filters | |||||
| IIR | enabled | enabled | enabled | ||
| Median | enabled | enabled | enabled | ||
| Average | |||||
| Position Filters | |||||
| IIR | |||||
| Median | enabled | enabled | enabled | ||
| Average | |||||
| Adaptive IIR | enabled | enabled | enabled | ||
| Jitter | enabled | enabled | enabled | ||
| MISRA Rule | Rule Class (Required/Advisory) | Rule Description | Description of Deviation(s) |
|---|---|---|---|
| 11.4 | A | A conversion should not be performed between a pointer to object and an integer type. | Such conversion is performed with CapSense context in two cases: interrupt handler and DeepSleepCallback function. Both cases are verified on correct operation. |
| 12.13 | A | The increment (++) and decrement (–) operators should not be mixed with other operators in an expression. | These violations are reported for the GCC ARM optimized form of the "for" loop that have the following syntax: for(index = COUNT; index –> 0u;) It is used to improve performance. |
| 1.2 | R | Constant: Dereference of NULL pointer. | These violations are reported as a result of using of offset macros of CSD Driver with corresponding documented violation 20.6. Refer to CSD Driver API Ref Guide. |
| 20.3 |
This section lists the known problems with the CapSense middleware.
| Cypress ID | Known Issue | Workaround |
|---|---|---|
| 319100 | GPIO simultaneous operation with unrestricted strength and frequency creates noise that can affect CapSense operation. | Refer to the errata section of the device datasheet for details. PSoC 63 with BLE Datasheet Programmable System-on-Chip |
| Version | Changes | Reason for Change |
|---|---|---|
| 2.0 | Added memory usage section to the CapSense API Ref Guide | User experience improvement |
| Updated documentation | User experience improvement | |
| Added the errata section to the CapSense API Ref Guide | User experience improvement | |
| CapSense MW sources are enclosed with the conditional compilation to ensure a successful compilation for non-CapSense-capable devices | Fixing a compilation error for non CapSense-capable devices | |
| Optimized flash memory consumption based on user's configuration | Flash foot-print optimization | |
| Renamed function Cy_CapSense_CheckCommandIntegrity() to Cy_CapSense_CheckTunerCmdIntegrity() | User experience improvement | |
| 1.20 | Added Arm Compiler 6 support | Feature enhancement |
| Changed the hierarchy of the binary files folders | MBED OS compatibility | |
| 1.1 | The following functions made obsolete:
Two simple functions introduced to replace the listed above functions: | User experience improvement |
| Fixed the shield operation when Csh is disabled | Defect fixing | |
| Fixed the implementation of the position filtering for the Radial Slider widget | Defect fixing | |
| Added restoring hardware to its default state in the Cy_CapSense_DeInit() implementation | Defect fixing | |
| Added the capability to enable the shield electrode without dedicated electrodes | Feature enhancement | |
| Added support of a protocol-agnostic tuner interface (UART, SPI, etc.) | Feature enhancement | |
| 1.0 | The initial version |
Important information about the CapSense-technology overview, appropriate Cypress device for the design, CapSense system and sensor design guidelines, different interfaces and tuning guidelines necessary for a successful design of a CapSense system is available in the Getting Started with CapSense document and the product-specific CapSense design guide. Cypress highly recommends starting with these documents. They can be found on the Cypress web site at www.cypress.com. For details about application notes, code examples, and kits, see the References section in this datasheet.
For more information, refer to the following documents: