|
STM32L4xx_HAL_Driver
1.14.0
|
This file provides firmware functions to manage the following functionalities of the Touch Sensing Controller (TSC) peripheral: More...
Go to the source code of this file.
Functions | |
| static uint32_t | TSC_extract_groups (uint32_t iomask) |
| Utility function used to set the acquired groups mask. More... | |
| HAL_StatusTypeDef | HAL_TSC_Init (TSC_HandleTypeDef *htsc) |
| Initialize the TSC peripheral according to the specified parameters in the TSC_InitTypeDef structure and initialize the associated handle. More... | |
| HAL_StatusTypeDef | HAL_TSC_DeInit (TSC_HandleTypeDef *htsc) |
| Deinitialize the TSC peripheral registers to their default reset values. More... | |
| void | HAL_TSC_MspInit (TSC_HandleTypeDef *htsc) |
| Initialize the TSC MSP. More... | |
| void | HAL_TSC_MspDeInit (TSC_HandleTypeDef *htsc) |
| DeInitialize the TSC MSP. More... | |
| HAL_StatusTypeDef | HAL_TSC_RegisterCallback (TSC_HandleTypeDef *htsc, HAL_TSC_CallbackIDTypeDef CallbackID, pTSC_CallbackTypeDef pCallback) |
| Register a User TSC Callback To be used instead of the weak predefined callback. More... | |
| HAL_StatusTypeDef | HAL_TSC_UnRegisterCallback (TSC_HandleTypeDef *htsc, HAL_TSC_CallbackIDTypeDef CallbackID) |
| Unregister an TSC Callback TSC callback is redirected to the weak predefined callback. More... | |
| HAL_StatusTypeDef | HAL_TSC_Start (TSC_HandleTypeDef *htsc) |
| Start the acquisition. More... | |
| HAL_StatusTypeDef | HAL_TSC_Start_IT (TSC_HandleTypeDef *htsc) |
| Start the acquisition in interrupt mode. More... | |
| HAL_StatusTypeDef | HAL_TSC_Stop (TSC_HandleTypeDef *htsc) |
| Stop the acquisition previously launched in polling mode. More... | |
| HAL_StatusTypeDef | HAL_TSC_Stop_IT (TSC_HandleTypeDef *htsc) |
| Stop the acquisition previously launched in interrupt mode. More... | |
| HAL_StatusTypeDef | HAL_TSC_PollForAcquisition (TSC_HandleTypeDef *htsc) |
| Start acquisition and wait until completion. More... | |
| TSC_GroupStatusTypeDef | HAL_TSC_GroupGetStatus (TSC_HandleTypeDef *htsc, uint32_t gx_index) |
| Get the acquisition status for a group. More... | |
| uint32_t | HAL_TSC_GroupGetValue (TSC_HandleTypeDef *htsc, uint32_t gx_index) |
| Get the acquisition measure for a group. More... | |
| HAL_StatusTypeDef | HAL_TSC_IOConfig (TSC_HandleTypeDef *htsc, TSC_IOConfigTypeDef *config) |
| Configure TSC IOs. More... | |
| HAL_StatusTypeDef | HAL_TSC_IODischarge (TSC_HandleTypeDef *htsc, FunctionalState choice) |
| Discharge TSC IOs. More... | |
| HAL_TSC_StateTypeDef | HAL_TSC_GetState (TSC_HandleTypeDef *htsc) |
| Return the TSC handle state. More... | |
| void | HAL_TSC_IRQHandler (TSC_HandleTypeDef *htsc) |
| Handle TSC interrupt request. More... | |
| void | HAL_TSC_ConvCpltCallback (TSC_HandleTypeDef *htsc) |
| Acquisition completed callback in non-blocking mode. More... | |
| void | HAL_TSC_ErrorCallback (TSC_HandleTypeDef *htsc) |
| Error callback in non-blocking mode. More... | |
This file provides firmware functions to manage the following functionalities of the Touch Sensing Controller (TSC) peripheral:
================================================================================
##### TSC specific features #####
================================================================================
[..]
(#) Proven and robust surface charge transfer acquisition principle
(#) Supports up to 3 capacitive sensing channels per group
(#) Capacitive sensing channels can be acquired in parallel offering a very good
response time
(#) Spread spectrum feature to improve system robustness in noisy environments
(#) Full hardware management of the charge transfer acquisition sequence
(#) Programmable charge transfer frequency
(#) Programmable sampling capacitor I/O pin
(#) Programmable channel I/O pin
(#) Programmable max count value to avoid long acquisition when a channel is faulty
(#) Dedicated end of acquisition and max count error flags with interrupt capability
(#) One sampling capacitor for up to 3 capacitive sensing channels to reduce the system
components
(#) Compatible with proximity, touchkey, linear and rotary touch sensor implementation
##### How to use this driver #####
================================================================================
[..]
(#) Enable the TSC interface clock using __HAL_RCC_TSC_CLK_ENABLE() macro.
(#) GPIO pins configuration
(++) Enable the clock for the TSC GPIOs using __HAL_RCC_GPIOx_CLK_ENABLE() macro.
(++) Configure the TSC pins used as sampling IOs in alternate function output Open-Drain mode,
and TSC pins used as channel/shield IOs in alternate function output Push-Pull mode
using HAL_GPIO_Init() function.
(#) Interrupts configuration
(++) Configure the NVIC (if the interrupt model is used) using HAL_NVIC_SetPriority()
and HAL_NVIC_EnableIRQ() and function.
(#) TSC configuration
(++) Configure all TSC parameters and used TSC IOs using HAL_TSC_Init() function.
[..] TSC peripheral alternate functions are mapped on AF9.
*** Acquisition sequence ***
===================================
[..]
(+) Discharge all IOs using HAL_TSC_IODischarge() function.
(+) Wait a certain time allowing a good discharge of all capacitors. This delay depends
of the sampling capacitor and electrodes design.
(+) Select the channel IOs to be acquired using HAL_TSC_IOConfig() function.
(+) Launch the acquisition using either HAL_TSC_Start() or HAL_TSC_Start_IT() function.
If the synchronized mode is selected, the acquisition will start as soon as the signal
is received on the synchro pin.
(+) Wait the end of acquisition using either HAL_TSC_PollForAcquisition() or
HAL_TSC_GetState() function or using WFI instruction for example.
(+) Check the group acquisition status using HAL_TSC_GroupGetStatus() function.
(+) Read the acquisition value using HAL_TSC_GroupGetValue() function.
*** Callback registration ***
=============================================
[..]
The compilation flag USE_HAL_TSC_REGISTER_CALLBACKS when set to 1
allows the user to configure dynamically the driver callbacks.
Use Functions @ref HAL_TSC_RegisterCallback() to register an interrupt callback.
[..]
Function @ref HAL_TSC_RegisterCallback() allows to register following callbacks:
(+) ConvCpltCallback : callback for conversion complete process.
(+) ErrorCallback : callback for error detection.
(+) MspInitCallback : callback for Msp Init.
(+) MspDeInitCallback : callback for Msp DeInit.
[..]
This function takes as parameters the HAL peripheral handle, the Callback ID
and a pointer to the user callback function.
[..]
Use function @ref HAL_TSC_UnRegisterCallback to reset a callback to the default
weak function.
@ref HAL_TSC_UnRegisterCallback takes as parameters the HAL peripheral handle,
and the Callback ID.
[..]
This function allows to reset following callbacks:
(+) ConvCpltCallback : callback for conversion complete process.
(+) ErrorCallback : callback for error detection.
(+) MspInitCallback : callback for Msp Init.
(+) MspDeInitCallback : callback for Msp DeInit.
[..]
By default, after the @ref HAL_TSC_Init() and when the state is @ref HAL_TSC_STATE_RESET
all callbacks are set to the corresponding weak functions:
examples @ref HAL_TSC_ConvCpltCallback(), @ref HAL_TSC_ErrorCallback().
Exception done for MspInit and MspDeInit functions that are
reset to the legacy weak functions in the @ref HAL_TSC_Init()/ @ref HAL_TSC_DeInit() only when
these callbacks are null (not registered beforehand).
If MspInit or MspDeInit are not null, the @ref HAL_TSC_Init()/ @ref HAL_TSC_DeInit()
keep and use the user MspInit/MspDeInit callbacks (registered beforehand) whatever the state.
[..]
Callbacks can be registered/unregistered in @ref HAL_TSC_STATE_READY state only.
Exception done MspInit/MspDeInit functions that can be registered/unregistered
in @ref HAL_TSC_STATE_READY or @ref HAL_TSC_STATE_RESET state,
thus registered (user) MspInit/DeInit callbacks can be used during the Init/DeInit.
Then, the user first registers the MspInit/MspDeInit user callbacks
using @ref HAL_TSC_RegisterCallback() before calling @ref HAL_TSC_DeInit()
or @ref HAL_TSC_Init() function.
[..]
When the compilation flag USE_HAL_TSC_REGISTER_CALLBACKS is set to 0 or
not defined, the callback registration feature is not available and all callbacks
are set to the corresponding weak functions.Table 1. IOs for the STM32L4xx devices
+--------------------------------+
| IOs | TSC functions |
|--------------|-----------------|
| PB12 (AF) | TSC_G1_IO1 |
| PB13 (AF) | TSC_G1_IO2 |
| PB14 (AF) | TSC_G1_IO3 |
| PB15 (AF) | TSC_G1_IO4 |
|--------------|-----------------|
| PB4 (AF) | TSC_G2_IO1 |
| PB5 (AF) | TSC_G2_IO2 |
| PB6 (AF) | TSC_G2_IO3 |
| PB7 (AF) | TSC_G2_IO4 |
|--------------|-----------------|
| PA15 (AF) | TSC_G3_IO1 |
| PC10 (AF) | TSC_G3_IO2 |
| PC11 (AF) | TSC_G3_IO3 |
| PC12 (AF) | TSC_G3_IO4 |
|--------------|-----------------|
| PC6 (AF) | TSC_G4_IO1 |
| PC7 (AF) | TSC_G4_IO2 |
| PC8 (AF) | TSC_G4_IO3 |
| PC9 (AF) | TSC_G4_IO4 |
|--------------|-----------------|
| PE10 (AF) | TSC_G5_IO1 |
| PE11 (AF) | TSC_G5_IO2 |
| PE12 (AF) | TSC_G5_IO3 |
| PE13 (AF) | TSC_G5_IO4 |
|--------------|-----------------|
| PD10 (AF) | TSC_G6_IO1 |
| PD11 (AF) | TSC_G6_IO2 |
| PD12 (AF) | TSC_G6_IO3 |
| PD13 (AF) | TSC_G6_IO4 |
|--------------|-----------------|
| PE2 (AF) | TSC_G7_IO1 |
| PE3 (AF) | TSC_G7_IO2 |
| PE4 (AF) | TSC_G7_IO3 |
| PE5 (AF) | TSC_G7_IO4 |
|--------------|-----------------|
| PF14 (AF) | TSC_G8_IO1 |
| PF15 (AF) | TSC_G8_IO2 |
| PG0 (AF) | TSC_G8_IO3 |
| PG1 (AF) | TSC_G8_IO4 |
|--------------|-----------------|
| PB10 (AF) | TSC_SYNC |
| PD2 (AF) | |
+--------------------------------+
@attention
<h2><center>© Copyright (c) 2017 STMicroelectronics.
All rights reserved.</center></h2>
This software component is licensed by ST under BSD 3-Clause license,
the "License"; You may not use this file except in compliance with the
License. You may obtain a copy of the License at:
opensource.org/licenses/BSD-3-Clause
Definition in file stm32l4xx_hal_tsc.c.