October 2019 UM1913 Rev 8 1/149
1
UM1913
User manual
Developing applications on STM32Cube
with STMTouch touch sensing library
Introduction
STM32Cube is an STMicroelectronics original initiative to improve developer productivity by
reducing development effort, time and cost. STM32Cube covers the STM32 portfolio.
STM32Cube includes STM32CubeMX, configuration tool that allows the generation of C
initialization code and an embedded software platform, delivered per STM32xx Series:
the STM32Cube HAL, STM32 abstraction layer embedded software ensuring maximized
portability across the STM32 portfolio
a consistent set of middleware components such as RTOS, USB, TCP/IP, Graphics and
STMTouch
all embedded software utilities coming with a full set of examples
This user manual describes the STMTouch touch sensing library that is part of the
STM32Cube firmware package, available from the STMicroelectronics website
(http://www.st.com/stm32cube). It is intended for developers who use STM32Cube firmware
on STM32 Arm
®
-based microcontrollers listed in the table below.
The STMTouch touch sensing library (TSL) includes:
a complete register address mapping with all bits, bitfields and registers declared in C
a collection of routines and data structures covering all functions to manage the touch
sensing technology
The source code is developed using the ANSI-C standard. It is fully documented and is
MISRA C
®
2004 compliant. Writing the whole library in 'Strict ANSI-C' makes it independent
from the development tools. Only the start-up files depend on the development tools. Since
this library is generic and covers many functionalities and microcontrollers, the size and/or
execution speed of the application code may not be optimized. For many applications, this
library may be used as is. However, for applications having tough constraints in terms of
code size and/or execution speed, this library may need to be fine tuned.
Table 1. Applicable products
Type Software package (associated STM32 Series)
STM32Cube
package
STM32CubeF0, STM32CubeF3 (STM32F0/F3)
STM32CubeL0, STM32CubeL1, STM32CubeL4 (STM32L0/L1/L4/L4+)
STM32CubeWB (STM32WB)
www.st.com
Contents UM1913
2/149 UM1913 Rev 8
Contents
1 Coding rules and conventions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
1.1 Acronyms and abbreviations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
1.2 Naming conventions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .11
1.3 Coding rules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .11
1.3.1 General . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
1.3.2 Variable types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
1.3.3 Peripheral registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
1.4 MISRA C 2004 compliance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
1.4.1 Generalities . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
1.4.2 Compliance matrix . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
2 STMTouch touch sensing library . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
2.1 Supported microcontrollers and development tools . . . . . . . . . . . . . . . . . 14
2.1.1 Supported microcontrollers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
2.1.2 Development tools . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
2.2 Package description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
2.3 Main features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
2.4 Architecture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
2.4.1 Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
2.4.2 STMTouch touch sensing library layers . . . . . . . . . . . . . . . . . . . . . . . . . 17
2.4.3 Acquisition and processing layers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
2.4.4 Header files inclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
2.5 Channel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
2.5.1 Principle . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
2.5.2 Resources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
2.5.3 Parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
2.5.4 Usage example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
2.6 Bank . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
2.6.1 Principle . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
2.6.2 Resources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
2.6.3 Parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
2.6.4 Usage example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
2.7 Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22