mbed library sources
Dependents: frdm_kl05z_gpio_test
Fork of mbed-src by
targets/cmsis/TARGET_STM/TARGET_NUCLEO_L053R8/stm32l0xx_hal_tsc.c@181:a4cbdfbbd2f4, 2014-05-07 (annotated)
- Committer:
- mbed_official
- Date:
- Wed May 07 13:15:08 2014 +0100
- Revision:
- 181:a4cbdfbbd2f4
Synchronized with git revision 7751e759576c6fd68deccb81ea82bac19ed41745
Full URL: https://github.com/mbedmicro/mbed/commit/7751e759576c6fd68deccb81ea82bac19ed41745/
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
mbed_official | 181:a4cbdfbbd2f4 | 1 | /** |
mbed_official | 181:a4cbdfbbd2f4 | 2 | ****************************************************************************** |
mbed_official | 181:a4cbdfbbd2f4 | 3 | * @file stm32l0xx_hal_tsc.c |
mbed_official | 181:a4cbdfbbd2f4 | 4 | * @author MCD Application Team |
mbed_official | 181:a4cbdfbbd2f4 | 5 | * @version V1.0.0 |
mbed_official | 181:a4cbdfbbd2f4 | 6 | * @date 22-April-2014 |
mbed_official | 181:a4cbdfbbd2f4 | 7 | * @brief This file provides firmware functions to manage the following |
mbed_official | 181:a4cbdfbbd2f4 | 8 | * functionalities of the Touch Sensing Controller (TSC) peripheral: |
mbed_official | 181:a4cbdfbbd2f4 | 9 | * + Initialization and DeInitialization |
mbed_official | 181:a4cbdfbbd2f4 | 10 | * + Channel IOs, Shield IOs and Sampling IOs configuration |
mbed_official | 181:a4cbdfbbd2f4 | 11 | * + Start and Stop an acquisition |
mbed_official | 181:a4cbdfbbd2f4 | 12 | * + Read acquisition result |
mbed_official | 181:a4cbdfbbd2f4 | 13 | * + Interrupts and flags management |
mbed_official | 181:a4cbdfbbd2f4 | 14 | * |
mbed_official | 181:a4cbdfbbd2f4 | 15 | @verbatim |
mbed_official | 181:a4cbdfbbd2f4 | 16 | ================================================================================ |
mbed_official | 181:a4cbdfbbd2f4 | 17 | ##### TSC specific features ##### |
mbed_official | 181:a4cbdfbbd2f4 | 18 | ================================================================================ |
mbed_official | 181:a4cbdfbbd2f4 | 19 | [..] |
mbed_official | 181:a4cbdfbbd2f4 | 20 | (#) Proven and robust surface charge transfer acquisition principle |
mbed_official | 181:a4cbdfbbd2f4 | 21 | |
mbed_official | 181:a4cbdfbbd2f4 | 22 | (#) Supports up to 3 capacitive sensing channels per group |
mbed_official | 181:a4cbdfbbd2f4 | 23 | |
mbed_official | 181:a4cbdfbbd2f4 | 24 | (#) Capacitive sensing channels can be acquired in parallel offering a very good |
mbed_official | 181:a4cbdfbbd2f4 | 25 | response time |
mbed_official | 181:a4cbdfbbd2f4 | 26 | |
mbed_official | 181:a4cbdfbbd2f4 | 27 | (#) Spread spectrum feature to improve system robustness in noisy environments |
mbed_official | 181:a4cbdfbbd2f4 | 28 | |
mbed_official | 181:a4cbdfbbd2f4 | 29 | (#) Full hardware management of the charge transfer acquisition sequence |
mbed_official | 181:a4cbdfbbd2f4 | 30 | |
mbed_official | 181:a4cbdfbbd2f4 | 31 | (#) Programmable charge transfer frequency |
mbed_official | 181:a4cbdfbbd2f4 | 32 | |
mbed_official | 181:a4cbdfbbd2f4 | 33 | (#) Programmable sampling capacitor I/O pin |
mbed_official | 181:a4cbdfbbd2f4 | 34 | |
mbed_official | 181:a4cbdfbbd2f4 | 35 | (#) Programmable channel I/O pin |
mbed_official | 181:a4cbdfbbd2f4 | 36 | |
mbed_official | 181:a4cbdfbbd2f4 | 37 | (#) Programmable max count value to avoid long acquisition when a channel is faulty |
mbed_official | 181:a4cbdfbbd2f4 | 38 | |
mbed_official | 181:a4cbdfbbd2f4 | 39 | (#) Dedicated end of acquisition and max count error flags with interrupt capability |
mbed_official | 181:a4cbdfbbd2f4 | 40 | |
mbed_official | 181:a4cbdfbbd2f4 | 41 | (#) One sampling capacitor for up to 3 capacitive sensing channels to reduce the system |
mbed_official | 181:a4cbdfbbd2f4 | 42 | components |
mbed_official | 181:a4cbdfbbd2f4 | 43 | |
mbed_official | 181:a4cbdfbbd2f4 | 44 | (#) Compatible with proximity, touchkey, linear and rotary touch sensor implementation |
mbed_official | 181:a4cbdfbbd2f4 | 45 | |
mbed_official | 181:a4cbdfbbd2f4 | 46 | |
mbed_official | 181:a4cbdfbbd2f4 | 47 | ##### How to use this driver ##### |
mbed_official | 181:a4cbdfbbd2f4 | 48 | ================================================================================ |
mbed_official | 181:a4cbdfbbd2f4 | 49 | [..] |
mbed_official | 181:a4cbdfbbd2f4 | 50 | (#) Enable the TSC interface clock using __TSC_CLK_ENABLE() macro. |
mbed_official | 181:a4cbdfbbd2f4 | 51 | |
mbed_official | 181:a4cbdfbbd2f4 | 52 | (#) GPIO pins configuration |
mbed_official | 181:a4cbdfbbd2f4 | 53 | (++) Enable the clock for the TSC GPIOs using __GPIOx_CLK_ENABLE() macro. |
mbed_official | 181:a4cbdfbbd2f4 | 54 | (++) Configure the TSC pins used as sampling IOs in alternate function output Open-Drain mode, |
mbed_official | 181:a4cbdfbbd2f4 | 55 | and TSC pins used as channel/shield IOs in alternate function output Push-Pull mode |
mbed_official | 181:a4cbdfbbd2f4 | 56 | using HAL_GPIO_Init() function. |
mbed_official | 181:a4cbdfbbd2f4 | 57 | (++) Configure the alternate function on all the TSC pins using HAL_xxxx() function. |
mbed_official | 181:a4cbdfbbd2f4 | 58 | |
mbed_official | 181:a4cbdfbbd2f4 | 59 | (#) Interrupts configuration |
mbed_official | 181:a4cbdfbbd2f4 | 60 | (++) Configure the NVIC (if the interrupt model is used) using HAL_xxx() function. |
mbed_official | 181:a4cbdfbbd2f4 | 61 | |
mbed_official | 181:a4cbdfbbd2f4 | 62 | (#) TSC configuration |
mbed_official | 181:a4cbdfbbd2f4 | 63 | (++) Configure all TSC parameters and used TSC IOs using HAL_TSC_Init() function. |
mbed_official | 181:a4cbdfbbd2f4 | 64 | |
mbed_official | 181:a4cbdfbbd2f4 | 65 | *** Acquisition sequence *** |
mbed_official | 181:a4cbdfbbd2f4 | 66 | =================================== |
mbed_official | 181:a4cbdfbbd2f4 | 67 | [..] |
mbed_official | 181:a4cbdfbbd2f4 | 68 | (+) Discharge all IOs using HAL_TSC_IODischarge() function. |
mbed_official | 181:a4cbdfbbd2f4 | 69 | (+) Wait a certain time allowing a good discharge of all capacitors. This delay depends |
mbed_official | 181:a4cbdfbbd2f4 | 70 | of the sampling capacitor and electrodes design. |
mbed_official | 181:a4cbdfbbd2f4 | 71 | (+) Select the channel IOs to be acquired using HAL_TSC_IOConfig() function. |
mbed_official | 181:a4cbdfbbd2f4 | 72 | (+) Launch the acquisition using either HAL_TSC_Start() or HAL_TSC_Start_IT() function. |
mbed_official | 181:a4cbdfbbd2f4 | 73 | If the synchronized mode is selected, the acquisition will start as soon as the signal |
mbed_official | 181:a4cbdfbbd2f4 | 74 | is received on the synchro pin. |
mbed_official | 181:a4cbdfbbd2f4 | 75 | (+) Wait the end of acquisition using either HAL_TSC_PollForAcquisition() or |
mbed_official | 181:a4cbdfbbd2f4 | 76 | HAL_TSC_GetState() function or using WFI instruction for example. |
mbed_official | 181:a4cbdfbbd2f4 | 77 | (+) Check the group acquisition status using HAL_TSC_GroupGetStatus() function. |
mbed_official | 181:a4cbdfbbd2f4 | 78 | (+) Read the acquisition value using HAL_TSC_GroupGetValue() function. |
mbed_official | 181:a4cbdfbbd2f4 | 79 | |
mbed_official | 181:a4cbdfbbd2f4 | 80 | @endverbatim |
mbed_official | 181:a4cbdfbbd2f4 | 81 | ****************************************************************************** |
mbed_official | 181:a4cbdfbbd2f4 | 82 | * @attention |
mbed_official | 181:a4cbdfbbd2f4 | 83 | * |
mbed_official | 181:a4cbdfbbd2f4 | 84 | * <h2><center>© COPYRIGHT(c) 2014 STMicroelectronics</center></h2> |
mbed_official | 181:a4cbdfbbd2f4 | 85 | * |
mbed_official | 181:a4cbdfbbd2f4 | 86 | * Redistribution and use in source and binary forms, with or without modification, |
mbed_official | 181:a4cbdfbbd2f4 | 87 | * are permitted provided that the following conditions are met: |
mbed_official | 181:a4cbdfbbd2f4 | 88 | * 1. Redistributions of source code must retain the above copyright notice, |
mbed_official | 181:a4cbdfbbd2f4 | 89 | * this list of conditions and the following disclaimer. |
mbed_official | 181:a4cbdfbbd2f4 | 90 | * 2. Redistributions in binary form must reproduce the above copyright notice, |
mbed_official | 181:a4cbdfbbd2f4 | 91 | * this list of conditions and the following disclaimer in the documentation |
mbed_official | 181:a4cbdfbbd2f4 | 92 | * and/or other materials provided with the distribution. |
mbed_official | 181:a4cbdfbbd2f4 | 93 | * 3. Neither the name of STMicroelectronics nor the names of its contributors |
mbed_official | 181:a4cbdfbbd2f4 | 94 | * may be used to endorse or promote products derived from this software |
mbed_official | 181:a4cbdfbbd2f4 | 95 | * without specific prior written permission. |
mbed_official | 181:a4cbdfbbd2f4 | 96 | * |
mbed_official | 181:a4cbdfbbd2f4 | 97 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
mbed_official | 181:a4cbdfbbd2f4 | 98 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
mbed_official | 181:a4cbdfbbd2f4 | 99 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
mbed_official | 181:a4cbdfbbd2f4 | 100 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE |
mbed_official | 181:a4cbdfbbd2f4 | 101 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
mbed_official | 181:a4cbdfbbd2f4 | 102 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
mbed_official | 181:a4cbdfbbd2f4 | 103 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
mbed_official | 181:a4cbdfbbd2f4 | 104 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
mbed_official | 181:a4cbdfbbd2f4 | 105 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
mbed_official | 181:a4cbdfbbd2f4 | 106 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
mbed_official | 181:a4cbdfbbd2f4 | 107 | * |
mbed_official | 181:a4cbdfbbd2f4 | 108 | ****************************************************************************** |
mbed_official | 181:a4cbdfbbd2f4 | 109 | */ |
mbed_official | 181:a4cbdfbbd2f4 | 110 | |
mbed_official | 181:a4cbdfbbd2f4 | 111 | /* Includes ------------------------------------------------------------------*/ |
mbed_official | 181:a4cbdfbbd2f4 | 112 | #include "stm32l0xx_hal.h" |
mbed_official | 181:a4cbdfbbd2f4 | 113 | |
mbed_official | 181:a4cbdfbbd2f4 | 114 | /** @addtogroup STM32L0xx_HAL_Driver |
mbed_official | 181:a4cbdfbbd2f4 | 115 | * @{ |
mbed_official | 181:a4cbdfbbd2f4 | 116 | */ |
mbed_official | 181:a4cbdfbbd2f4 | 117 | |
mbed_official | 181:a4cbdfbbd2f4 | 118 | /** @defgroup TSC |
mbed_official | 181:a4cbdfbbd2f4 | 119 | * @brief HAL TSC module driver |
mbed_official | 181:a4cbdfbbd2f4 | 120 | * @{ |
mbed_official | 181:a4cbdfbbd2f4 | 121 | */ |
mbed_official | 181:a4cbdfbbd2f4 | 122 | |
mbed_official | 181:a4cbdfbbd2f4 | 123 | #ifdef HAL_TSC_MODULE_ENABLED |
mbed_official | 181:a4cbdfbbd2f4 | 124 | |
mbed_official | 181:a4cbdfbbd2f4 | 125 | /* Private typedef -----------------------------------------------------------*/ |
mbed_official | 181:a4cbdfbbd2f4 | 126 | /* Private define ------------------------------------------------------------*/ |
mbed_official | 181:a4cbdfbbd2f4 | 127 | /* Private macro -------------------------------------------------------------*/ |
mbed_official | 181:a4cbdfbbd2f4 | 128 | /* Private variables ---------------------------------------------------------*/ |
mbed_official | 181:a4cbdfbbd2f4 | 129 | /* Private function prototypes -----------------------------------------------*/ |
mbed_official | 181:a4cbdfbbd2f4 | 130 | static uint32_t TSC_extract_groups(uint32_t iomask); |
mbed_official | 181:a4cbdfbbd2f4 | 131 | /* Private functions ---------------------------------------------------------*/ |
mbed_official | 181:a4cbdfbbd2f4 | 132 | |
mbed_official | 181:a4cbdfbbd2f4 | 133 | /** @defgroup TSC_Private_Functions |
mbed_official | 181:a4cbdfbbd2f4 | 134 | * @{ |
mbed_official | 181:a4cbdfbbd2f4 | 135 | */ |
mbed_official | 181:a4cbdfbbd2f4 | 136 | |
mbed_official | 181:a4cbdfbbd2f4 | 137 | /** @defgroup TSC_Group1 Initialization/de-initialization functions |
mbed_official | 181:a4cbdfbbd2f4 | 138 | * @brief Initialization and Configuration functions |
mbed_official | 181:a4cbdfbbd2f4 | 139 | * |
mbed_official | 181:a4cbdfbbd2f4 | 140 | @verbatim |
mbed_official | 181:a4cbdfbbd2f4 | 141 | =============================================================================== |
mbed_official | 181:a4cbdfbbd2f4 | 142 | ##### Initialization and de-initialization functions ##### |
mbed_official | 181:a4cbdfbbd2f4 | 143 | =============================================================================== |
mbed_official | 181:a4cbdfbbd2f4 | 144 | [..] This section provides functions allowing to: |
mbed_official | 181:a4cbdfbbd2f4 | 145 | (+) Initialize and configure the TSC. |
mbed_official | 181:a4cbdfbbd2f4 | 146 | (+) De-initialize the TSC. |
mbed_official | 181:a4cbdfbbd2f4 | 147 | @endverbatim |
mbed_official | 181:a4cbdfbbd2f4 | 148 | * @{ |
mbed_official | 181:a4cbdfbbd2f4 | 149 | */ |
mbed_official | 181:a4cbdfbbd2f4 | 150 | |
mbed_official | 181:a4cbdfbbd2f4 | 151 | /** |
mbed_official | 181:a4cbdfbbd2f4 | 152 | * @brief Initializes the TSC peripheral according to the specified parameters |
mbed_official | 181:a4cbdfbbd2f4 | 153 | * in the TSC_InitTypeDef structure. |
mbed_official | 181:a4cbdfbbd2f4 | 154 | * @param htsc: TSC handle |
mbed_official | 181:a4cbdfbbd2f4 | 155 | * @retval HAL status |
mbed_official | 181:a4cbdfbbd2f4 | 156 | */ |
mbed_official | 181:a4cbdfbbd2f4 | 157 | HAL_StatusTypeDef HAL_TSC_Init(TSC_HandleTypeDef* htsc) |
mbed_official | 181:a4cbdfbbd2f4 | 158 | { |
mbed_official | 181:a4cbdfbbd2f4 | 159 | /* Check TSC handle allocation */ |
mbed_official | 181:a4cbdfbbd2f4 | 160 | if (htsc == NULL) |
mbed_official | 181:a4cbdfbbd2f4 | 161 | { |
mbed_official | 181:a4cbdfbbd2f4 | 162 | return HAL_ERROR; |
mbed_official | 181:a4cbdfbbd2f4 | 163 | } |
mbed_official | 181:a4cbdfbbd2f4 | 164 | |
mbed_official | 181:a4cbdfbbd2f4 | 165 | /* Check the parameters */ |
mbed_official | 181:a4cbdfbbd2f4 | 166 | assert_param(IS_TSC_ALL_INSTANCE(htsc->Instance)); |
mbed_official | 181:a4cbdfbbd2f4 | 167 | assert_param(IS_TSC_CTPH(htsc->Init.CTPulseHighLength)); |
mbed_official | 181:a4cbdfbbd2f4 | 168 | assert_param(IS_TSC_CTPL(htsc->Init.CTPulseLowLength)); |
mbed_official | 181:a4cbdfbbd2f4 | 169 | assert_param(IS_TSC_SS(htsc->Init.SpreadSpectrum)); |
mbed_official | 181:a4cbdfbbd2f4 | 170 | assert_param(IS_TSC_SSD(htsc->Init.SpreadSpectrumDeviation)); |
mbed_official | 181:a4cbdfbbd2f4 | 171 | assert_param(IS_TSC_SS_PRESC(htsc->Init.SpreadSpectrumPrescaler)); |
mbed_official | 181:a4cbdfbbd2f4 | 172 | assert_param(IS_TSC_PG_PRESC(htsc->Init.PulseGeneratorPrescaler)); |
mbed_official | 181:a4cbdfbbd2f4 | 173 | assert_param(IS_TSC_MCV(htsc->Init.MaxCountValue)); |
mbed_official | 181:a4cbdfbbd2f4 | 174 | assert_param(IS_TSC_IODEF(htsc->Init.IODefaultMode)); |
mbed_official | 181:a4cbdfbbd2f4 | 175 | assert_param(IS_TSC_SYNC_POL(htsc->Init.SynchroPinPolarity)); |
mbed_official | 181:a4cbdfbbd2f4 | 176 | assert_param(IS_TSC_ACQ_MODE(htsc->Init.AcquisitionMode)); |
mbed_official | 181:a4cbdfbbd2f4 | 177 | assert_param(IS_TSC_MCE_IT(htsc->Init.MaxCountInterrupt)); |
mbed_official | 181:a4cbdfbbd2f4 | 178 | |
mbed_official | 181:a4cbdfbbd2f4 | 179 | /* Initialize the TSC state */ |
mbed_official | 181:a4cbdfbbd2f4 | 180 | htsc->State = HAL_TSC_STATE_BUSY; |
mbed_official | 181:a4cbdfbbd2f4 | 181 | |
mbed_official | 181:a4cbdfbbd2f4 | 182 | /* Init the low level hardware : GPIO, CLOCK, CORTEX */ |
mbed_official | 181:a4cbdfbbd2f4 | 183 | HAL_TSC_MspInit(htsc); |
mbed_official | 181:a4cbdfbbd2f4 | 184 | |
mbed_official | 181:a4cbdfbbd2f4 | 185 | /*--------------------------------------------------------------------------*/ |
mbed_official | 181:a4cbdfbbd2f4 | 186 | /* Set TSC parameters */ |
mbed_official | 181:a4cbdfbbd2f4 | 187 | |
mbed_official | 181:a4cbdfbbd2f4 | 188 | /* Enable TSC */ |
mbed_official | 181:a4cbdfbbd2f4 | 189 | htsc->Instance->CR = TSC_CR_TSCE; |
mbed_official | 181:a4cbdfbbd2f4 | 190 | |
mbed_official | 181:a4cbdfbbd2f4 | 191 | /* Set all functions */ |
mbed_official | 181:a4cbdfbbd2f4 | 192 | htsc->Instance->CR |= (htsc->Init.CTPulseHighLength | |
mbed_official | 181:a4cbdfbbd2f4 | 193 | htsc->Init.CTPulseLowLength | |
mbed_official | 181:a4cbdfbbd2f4 | 194 | (uint32_t)(htsc->Init.SpreadSpectrumDeviation << 17) | |
mbed_official | 181:a4cbdfbbd2f4 | 195 | htsc->Init.SpreadSpectrumPrescaler | |
mbed_official | 181:a4cbdfbbd2f4 | 196 | htsc->Init.PulseGeneratorPrescaler | |
mbed_official | 181:a4cbdfbbd2f4 | 197 | htsc->Init.MaxCountValue | |
mbed_official | 181:a4cbdfbbd2f4 | 198 | htsc->Init.IODefaultMode | |
mbed_official | 181:a4cbdfbbd2f4 | 199 | htsc->Init.SynchroPinPolarity | |
mbed_official | 181:a4cbdfbbd2f4 | 200 | htsc->Init.AcquisitionMode); |
mbed_official | 181:a4cbdfbbd2f4 | 201 | |
mbed_official | 181:a4cbdfbbd2f4 | 202 | /* Spread spectrum */ |
mbed_official | 181:a4cbdfbbd2f4 | 203 | if (htsc->Init.SpreadSpectrum == ENABLE) |
mbed_official | 181:a4cbdfbbd2f4 | 204 | { |
mbed_official | 181:a4cbdfbbd2f4 | 205 | htsc->Instance->CR |= TSC_CR_SSE; |
mbed_official | 181:a4cbdfbbd2f4 | 206 | } |
mbed_official | 181:a4cbdfbbd2f4 | 207 | |
mbed_official | 181:a4cbdfbbd2f4 | 208 | /* Disable Schmitt trigger hysteresis on all used TSC IOs */ |
mbed_official | 181:a4cbdfbbd2f4 | 209 | htsc->Instance->IOHCR = (uint32_t)(~(htsc->Init.ChannelIOs | htsc->Init.ShieldIOs | htsc->Init.SamplingIOs)); |
mbed_official | 181:a4cbdfbbd2f4 | 210 | |
mbed_official | 181:a4cbdfbbd2f4 | 211 | /* Set channel and shield IOs */ |
mbed_official | 181:a4cbdfbbd2f4 | 212 | htsc->Instance->IOCCR = (htsc->Init.ChannelIOs | htsc->Init.ShieldIOs); |
mbed_official | 181:a4cbdfbbd2f4 | 213 | |
mbed_official | 181:a4cbdfbbd2f4 | 214 | /* Set sampling IOs */ |
mbed_official | 181:a4cbdfbbd2f4 | 215 | htsc->Instance->IOSCR = htsc->Init.SamplingIOs; |
mbed_official | 181:a4cbdfbbd2f4 | 216 | |
mbed_official | 181:a4cbdfbbd2f4 | 217 | /* Set the groups to be acquired */ |
mbed_official | 181:a4cbdfbbd2f4 | 218 | htsc->Instance->IOGCSR = TSC_extract_groups(htsc->Init.ChannelIOs); |
mbed_official | 181:a4cbdfbbd2f4 | 219 | |
mbed_official | 181:a4cbdfbbd2f4 | 220 | /* Clear interrupts */ |
mbed_official | 181:a4cbdfbbd2f4 | 221 | htsc->Instance->IER &= (uint32_t)(~(TSC_IT_EOA | TSC_IT_MCE)); |
mbed_official | 181:a4cbdfbbd2f4 | 222 | |
mbed_official | 181:a4cbdfbbd2f4 | 223 | /* Clear flags */ |
mbed_official | 181:a4cbdfbbd2f4 | 224 | htsc->Instance->ICR |= (TSC_FLAG_EOA | TSC_FLAG_MCE); |
mbed_official | 181:a4cbdfbbd2f4 | 225 | |
mbed_official | 181:a4cbdfbbd2f4 | 226 | /*--------------------------------------------------------------------------*/ |
mbed_official | 181:a4cbdfbbd2f4 | 227 | |
mbed_official | 181:a4cbdfbbd2f4 | 228 | /* Initialize the TSC state */ |
mbed_official | 181:a4cbdfbbd2f4 | 229 | htsc->State = HAL_TSC_STATE_READY; |
mbed_official | 181:a4cbdfbbd2f4 | 230 | |
mbed_official | 181:a4cbdfbbd2f4 | 231 | /* Return function status */ |
mbed_official | 181:a4cbdfbbd2f4 | 232 | return HAL_OK; |
mbed_official | 181:a4cbdfbbd2f4 | 233 | } |
mbed_official | 181:a4cbdfbbd2f4 | 234 | |
mbed_official | 181:a4cbdfbbd2f4 | 235 | /** |
mbed_official | 181:a4cbdfbbd2f4 | 236 | * @brief Deinitializes the TSC peripheral registers to their default reset values. |
mbed_official | 181:a4cbdfbbd2f4 | 237 | * @param htsc: TSC handle |
mbed_official | 181:a4cbdfbbd2f4 | 238 | * @retval HAL status |
mbed_official | 181:a4cbdfbbd2f4 | 239 | */ |
mbed_official | 181:a4cbdfbbd2f4 | 240 | HAL_StatusTypeDef HAL_TSC_DeInit(TSC_HandleTypeDef* htsc) |
mbed_official | 181:a4cbdfbbd2f4 | 241 | { |
mbed_official | 181:a4cbdfbbd2f4 | 242 | /* Check TSC handle allocation */ |
mbed_official | 181:a4cbdfbbd2f4 | 243 | if (htsc == NULL) |
mbed_official | 181:a4cbdfbbd2f4 | 244 | { |
mbed_official | 181:a4cbdfbbd2f4 | 245 | return HAL_ERROR; |
mbed_official | 181:a4cbdfbbd2f4 | 246 | } |
mbed_official | 181:a4cbdfbbd2f4 | 247 | |
mbed_official | 181:a4cbdfbbd2f4 | 248 | /* Check the parameters */ |
mbed_official | 181:a4cbdfbbd2f4 | 249 | assert_param(IS_TSC_ALL_INSTANCE(htsc->Instance)); |
mbed_official | 181:a4cbdfbbd2f4 | 250 | |
mbed_official | 181:a4cbdfbbd2f4 | 251 | /* Change TSC state */ |
mbed_official | 181:a4cbdfbbd2f4 | 252 | htsc->State = HAL_TSC_STATE_BUSY; |
mbed_official | 181:a4cbdfbbd2f4 | 253 | |
mbed_official | 181:a4cbdfbbd2f4 | 254 | /* DeInit the low level hardware */ |
mbed_official | 181:a4cbdfbbd2f4 | 255 | HAL_TSC_MspDeInit(htsc); |
mbed_official | 181:a4cbdfbbd2f4 | 256 | |
mbed_official | 181:a4cbdfbbd2f4 | 257 | /* Change TSC state */ |
mbed_official | 181:a4cbdfbbd2f4 | 258 | htsc->State = HAL_TSC_STATE_RESET; |
mbed_official | 181:a4cbdfbbd2f4 | 259 | |
mbed_official | 181:a4cbdfbbd2f4 | 260 | /* Process unlocked */ |
mbed_official | 181:a4cbdfbbd2f4 | 261 | __HAL_UNLOCK(htsc); |
mbed_official | 181:a4cbdfbbd2f4 | 262 | |
mbed_official | 181:a4cbdfbbd2f4 | 263 | /* Return function status */ |
mbed_official | 181:a4cbdfbbd2f4 | 264 | return HAL_OK; |
mbed_official | 181:a4cbdfbbd2f4 | 265 | } |
mbed_official | 181:a4cbdfbbd2f4 | 266 | |
mbed_official | 181:a4cbdfbbd2f4 | 267 | /** |
mbed_official | 181:a4cbdfbbd2f4 | 268 | * @brief Initializes the TSC MSP. |
mbed_official | 181:a4cbdfbbd2f4 | 269 | * @param htsc: pointer to a TSC_HandleTypeDef structure that contains |
mbed_official | 181:a4cbdfbbd2f4 | 270 | * the configuration information for the specified TSC. |
mbed_official | 181:a4cbdfbbd2f4 | 271 | * @retval None |
mbed_official | 181:a4cbdfbbd2f4 | 272 | */ |
mbed_official | 181:a4cbdfbbd2f4 | 273 | __weak void HAL_TSC_MspInit(TSC_HandleTypeDef* htsc) |
mbed_official | 181:a4cbdfbbd2f4 | 274 | { |
mbed_official | 181:a4cbdfbbd2f4 | 275 | /* NOTE : This function should not be modified, when the callback is needed, |
mbed_official | 181:a4cbdfbbd2f4 | 276 | the HAL_TSC_MspInit could be implemented in the user file. |
mbed_official | 181:a4cbdfbbd2f4 | 277 | */ |
mbed_official | 181:a4cbdfbbd2f4 | 278 | } |
mbed_official | 181:a4cbdfbbd2f4 | 279 | |
mbed_official | 181:a4cbdfbbd2f4 | 280 | /** |
mbed_official | 181:a4cbdfbbd2f4 | 281 | * @brief DeInitializes the TSC MSP. |
mbed_official | 181:a4cbdfbbd2f4 | 282 | * @param htsc: pointer to a TSC_HandleTypeDef structure that contains |
mbed_official | 181:a4cbdfbbd2f4 | 283 | * the configuration information for the specified TSC. |
mbed_official | 181:a4cbdfbbd2f4 | 284 | * @retval None |
mbed_official | 181:a4cbdfbbd2f4 | 285 | */ |
mbed_official | 181:a4cbdfbbd2f4 | 286 | __weak void HAL_TSC_MspDeInit(TSC_HandleTypeDef* htsc) |
mbed_official | 181:a4cbdfbbd2f4 | 287 | { |
mbed_official | 181:a4cbdfbbd2f4 | 288 | /* NOTE : This function should not be modified, when the callback is needed, |
mbed_official | 181:a4cbdfbbd2f4 | 289 | the HAL_TSC_MspDeInit could be implemented in the user file. |
mbed_official | 181:a4cbdfbbd2f4 | 290 | */ |
mbed_official | 181:a4cbdfbbd2f4 | 291 | } |
mbed_official | 181:a4cbdfbbd2f4 | 292 | |
mbed_official | 181:a4cbdfbbd2f4 | 293 | /** |
mbed_official | 181:a4cbdfbbd2f4 | 294 | * @} |
mbed_official | 181:a4cbdfbbd2f4 | 295 | */ |
mbed_official | 181:a4cbdfbbd2f4 | 296 | |
mbed_official | 181:a4cbdfbbd2f4 | 297 | /** @defgroup HAL_TSC_Group2 IO operation functions |
mbed_official | 181:a4cbdfbbd2f4 | 298 | * @brief IO operation functions |
mbed_official | 181:a4cbdfbbd2f4 | 299 | * |
mbed_official | 181:a4cbdfbbd2f4 | 300 | @verbatim |
mbed_official | 181:a4cbdfbbd2f4 | 301 | =============================================================================== |
mbed_official | 181:a4cbdfbbd2f4 | 302 | ##### I/O Operation functions ##### |
mbed_official | 181:a4cbdfbbd2f4 | 303 | =============================================================================== |
mbed_official | 181:a4cbdfbbd2f4 | 304 | [..] This section provides functions allowing to: |
mbed_official | 181:a4cbdfbbd2f4 | 305 | (+) Start acquisition in polling mode. |
mbed_official | 181:a4cbdfbbd2f4 | 306 | (+) Start acquisition in interrupt mode. |
mbed_official | 181:a4cbdfbbd2f4 | 307 | (+) Stop conversion in polling mode. |
mbed_official | 181:a4cbdfbbd2f4 | 308 | (+) Stop conversion in interrupt mode. |
mbed_official | 181:a4cbdfbbd2f4 | 309 | (+) Get group acquisition status. |
mbed_official | 181:a4cbdfbbd2f4 | 310 | (+) Get group acquisition value. |
mbed_official | 181:a4cbdfbbd2f4 | 311 | @endverbatim |
mbed_official | 181:a4cbdfbbd2f4 | 312 | * @{ |
mbed_official | 181:a4cbdfbbd2f4 | 313 | */ |
mbed_official | 181:a4cbdfbbd2f4 | 314 | |
mbed_official | 181:a4cbdfbbd2f4 | 315 | /** |
mbed_official | 181:a4cbdfbbd2f4 | 316 | * @brief Starts the acquisition. |
mbed_official | 181:a4cbdfbbd2f4 | 317 | * @param htsc: pointer to a TSC_HandleTypeDef structure that contains |
mbed_official | 181:a4cbdfbbd2f4 | 318 | * the configuration information for the specified TSC. |
mbed_official | 181:a4cbdfbbd2f4 | 319 | * @retval HAL status |
mbed_official | 181:a4cbdfbbd2f4 | 320 | */ |
mbed_official | 181:a4cbdfbbd2f4 | 321 | HAL_StatusTypeDef HAL_TSC_Start(TSC_HandleTypeDef* htsc) |
mbed_official | 181:a4cbdfbbd2f4 | 322 | { |
mbed_official | 181:a4cbdfbbd2f4 | 323 | /* Check the parameters */ |
mbed_official | 181:a4cbdfbbd2f4 | 324 | assert_param(IS_TSC_ALL_INSTANCE(htsc->Instance)); |
mbed_official | 181:a4cbdfbbd2f4 | 325 | |
mbed_official | 181:a4cbdfbbd2f4 | 326 | /* Process locked */ |
mbed_official | 181:a4cbdfbbd2f4 | 327 | __HAL_LOCK(htsc); |
mbed_official | 181:a4cbdfbbd2f4 | 328 | |
mbed_official | 181:a4cbdfbbd2f4 | 329 | /* Change TSC state */ |
mbed_official | 181:a4cbdfbbd2f4 | 330 | htsc->State = HAL_TSC_STATE_BUSY; |
mbed_official | 181:a4cbdfbbd2f4 | 331 | |
mbed_official | 181:a4cbdfbbd2f4 | 332 | /* Clear interrupts */ |
mbed_official | 181:a4cbdfbbd2f4 | 333 | __HAL_TSC_DISABLE_IT(htsc, (TSC_IT_EOA | TSC_IT_MCE)); |
mbed_official | 181:a4cbdfbbd2f4 | 334 | |
mbed_official | 181:a4cbdfbbd2f4 | 335 | /* Clear flags */ |
mbed_official | 181:a4cbdfbbd2f4 | 336 | __HAL_TSC_CLEAR_FLAG(htsc, (TSC_FLAG_EOA | TSC_FLAG_MCE)); |
mbed_official | 181:a4cbdfbbd2f4 | 337 | |
mbed_official | 181:a4cbdfbbd2f4 | 338 | /* Stop discharging the IOs */ |
mbed_official | 181:a4cbdfbbd2f4 | 339 | __HAL_TSC_SET_IODEF_INFLOAT(htsc); |
mbed_official | 181:a4cbdfbbd2f4 | 340 | |
mbed_official | 181:a4cbdfbbd2f4 | 341 | /* Launch the acquisition */ |
mbed_official | 181:a4cbdfbbd2f4 | 342 | __HAL_TSC_START_ACQ(htsc); |
mbed_official | 181:a4cbdfbbd2f4 | 343 | |
mbed_official | 181:a4cbdfbbd2f4 | 344 | /* Process unlocked */ |
mbed_official | 181:a4cbdfbbd2f4 | 345 | __HAL_UNLOCK(htsc); |
mbed_official | 181:a4cbdfbbd2f4 | 346 | |
mbed_official | 181:a4cbdfbbd2f4 | 347 | /* Return function status */ |
mbed_official | 181:a4cbdfbbd2f4 | 348 | return HAL_OK; |
mbed_official | 181:a4cbdfbbd2f4 | 349 | } |
mbed_official | 181:a4cbdfbbd2f4 | 350 | |
mbed_official | 181:a4cbdfbbd2f4 | 351 | /** |
mbed_official | 181:a4cbdfbbd2f4 | 352 | * @brief Enables the interrupt and starts the acquisition |
mbed_official | 181:a4cbdfbbd2f4 | 353 | * @param htsc: pointer to a TSC_HandleTypeDef structure that contains |
mbed_official | 181:a4cbdfbbd2f4 | 354 | * the configuration information for the specified TSC. |
mbed_official | 181:a4cbdfbbd2f4 | 355 | * @retval HAL status. |
mbed_official | 181:a4cbdfbbd2f4 | 356 | */ |
mbed_official | 181:a4cbdfbbd2f4 | 357 | HAL_StatusTypeDef HAL_TSC_Start_IT(TSC_HandleTypeDef* htsc) |
mbed_official | 181:a4cbdfbbd2f4 | 358 | { |
mbed_official | 181:a4cbdfbbd2f4 | 359 | /* Check the parameters */ |
mbed_official | 181:a4cbdfbbd2f4 | 360 | assert_param(IS_TSC_ALL_INSTANCE(htsc->Instance)); |
mbed_official | 181:a4cbdfbbd2f4 | 361 | assert_param(IS_TSC_MCE_IT(htsc->Init.MaxCountInterrupt)); |
mbed_official | 181:a4cbdfbbd2f4 | 362 | |
mbed_official | 181:a4cbdfbbd2f4 | 363 | /* Process locked */ |
mbed_official | 181:a4cbdfbbd2f4 | 364 | __HAL_LOCK(htsc); |
mbed_official | 181:a4cbdfbbd2f4 | 365 | |
mbed_official | 181:a4cbdfbbd2f4 | 366 | /* Change TSC state */ |
mbed_official | 181:a4cbdfbbd2f4 | 367 | htsc->State = HAL_TSC_STATE_BUSY; |
mbed_official | 181:a4cbdfbbd2f4 | 368 | |
mbed_official | 181:a4cbdfbbd2f4 | 369 | /* Enable end of acquisition interrupt */ |
mbed_official | 181:a4cbdfbbd2f4 | 370 | __HAL_TSC_ENABLE_IT(htsc, TSC_IT_EOA); |
mbed_official | 181:a4cbdfbbd2f4 | 371 | |
mbed_official | 181:a4cbdfbbd2f4 | 372 | /* Enable max count error interrupt (optional) */ |
mbed_official | 181:a4cbdfbbd2f4 | 373 | if (htsc->Init.MaxCountInterrupt == ENABLE) |
mbed_official | 181:a4cbdfbbd2f4 | 374 | { |
mbed_official | 181:a4cbdfbbd2f4 | 375 | __HAL_TSC_ENABLE_IT(htsc, TSC_IT_MCE); |
mbed_official | 181:a4cbdfbbd2f4 | 376 | } |
mbed_official | 181:a4cbdfbbd2f4 | 377 | else |
mbed_official | 181:a4cbdfbbd2f4 | 378 | { |
mbed_official | 181:a4cbdfbbd2f4 | 379 | __HAL_TSC_DISABLE_IT(htsc, TSC_IT_MCE); |
mbed_official | 181:a4cbdfbbd2f4 | 380 | } |
mbed_official | 181:a4cbdfbbd2f4 | 381 | |
mbed_official | 181:a4cbdfbbd2f4 | 382 | /* Clear flags */ |
mbed_official | 181:a4cbdfbbd2f4 | 383 | __HAL_TSC_CLEAR_FLAG(htsc, (TSC_FLAG_EOA | TSC_FLAG_MCE)); |
mbed_official | 181:a4cbdfbbd2f4 | 384 | |
mbed_official | 181:a4cbdfbbd2f4 | 385 | /* Stop discharging the IOs */ |
mbed_official | 181:a4cbdfbbd2f4 | 386 | __HAL_TSC_SET_IODEF_INFLOAT(htsc); |
mbed_official | 181:a4cbdfbbd2f4 | 387 | |
mbed_official | 181:a4cbdfbbd2f4 | 388 | /* Launch the acquisition */ |
mbed_official | 181:a4cbdfbbd2f4 | 389 | __HAL_TSC_START_ACQ(htsc); |
mbed_official | 181:a4cbdfbbd2f4 | 390 | |
mbed_official | 181:a4cbdfbbd2f4 | 391 | /* Process unlocked */ |
mbed_official | 181:a4cbdfbbd2f4 | 392 | __HAL_UNLOCK(htsc); |
mbed_official | 181:a4cbdfbbd2f4 | 393 | |
mbed_official | 181:a4cbdfbbd2f4 | 394 | /* Return function status */ |
mbed_official | 181:a4cbdfbbd2f4 | 395 | return HAL_OK; |
mbed_official | 181:a4cbdfbbd2f4 | 396 | } |
mbed_official | 181:a4cbdfbbd2f4 | 397 | |
mbed_official | 181:a4cbdfbbd2f4 | 398 | /** |
mbed_official | 181:a4cbdfbbd2f4 | 399 | * @brief Stops the acquisition previously launched in polling mode |
mbed_official | 181:a4cbdfbbd2f4 | 400 | * @param htsc: pointer to a TSC_HandleTypeDef structure that contains |
mbed_official | 181:a4cbdfbbd2f4 | 401 | * the configuration information for the specified TSC. |
mbed_official | 181:a4cbdfbbd2f4 | 402 | * @retval HAL status |
mbed_official | 181:a4cbdfbbd2f4 | 403 | */ |
mbed_official | 181:a4cbdfbbd2f4 | 404 | HAL_StatusTypeDef HAL_TSC_Stop(TSC_HandleTypeDef* htsc) |
mbed_official | 181:a4cbdfbbd2f4 | 405 | { |
mbed_official | 181:a4cbdfbbd2f4 | 406 | /* Check the parameters */ |
mbed_official | 181:a4cbdfbbd2f4 | 407 | assert_param(IS_TSC_ALL_INSTANCE(htsc->Instance)); |
mbed_official | 181:a4cbdfbbd2f4 | 408 | |
mbed_official | 181:a4cbdfbbd2f4 | 409 | /* Process locked */ |
mbed_official | 181:a4cbdfbbd2f4 | 410 | __HAL_LOCK(htsc); |
mbed_official | 181:a4cbdfbbd2f4 | 411 | |
mbed_official | 181:a4cbdfbbd2f4 | 412 | /* Stop the acquisition */ |
mbed_official | 181:a4cbdfbbd2f4 | 413 | __HAL_TSC_STOP_ACQ(htsc); |
mbed_official | 181:a4cbdfbbd2f4 | 414 | |
mbed_official | 181:a4cbdfbbd2f4 | 415 | /* Clear flags */ |
mbed_official | 181:a4cbdfbbd2f4 | 416 | __HAL_TSC_CLEAR_FLAG(htsc, (TSC_FLAG_EOA | TSC_FLAG_MCE)); |
mbed_official | 181:a4cbdfbbd2f4 | 417 | |
mbed_official | 181:a4cbdfbbd2f4 | 418 | /* Change TSC state */ |
mbed_official | 181:a4cbdfbbd2f4 | 419 | htsc->State = HAL_TSC_STATE_READY; |
mbed_official | 181:a4cbdfbbd2f4 | 420 | |
mbed_official | 181:a4cbdfbbd2f4 | 421 | /* Process unlocked */ |
mbed_official | 181:a4cbdfbbd2f4 | 422 | __HAL_UNLOCK(htsc); |
mbed_official | 181:a4cbdfbbd2f4 | 423 | |
mbed_official | 181:a4cbdfbbd2f4 | 424 | /* Return function status */ |
mbed_official | 181:a4cbdfbbd2f4 | 425 | return HAL_OK; |
mbed_official | 181:a4cbdfbbd2f4 | 426 | } |
mbed_official | 181:a4cbdfbbd2f4 | 427 | |
mbed_official | 181:a4cbdfbbd2f4 | 428 | /** |
mbed_official | 181:a4cbdfbbd2f4 | 429 | * @brief Stops the acquisition previously launched in interrupt mode |
mbed_official | 181:a4cbdfbbd2f4 | 430 | * @param htsc: pointer to a TSC_HandleTypeDef structure that contains |
mbed_official | 181:a4cbdfbbd2f4 | 431 | * the configuration information for the specified TSC. |
mbed_official | 181:a4cbdfbbd2f4 | 432 | * @retval HAL status |
mbed_official | 181:a4cbdfbbd2f4 | 433 | */ |
mbed_official | 181:a4cbdfbbd2f4 | 434 | HAL_StatusTypeDef HAL_TSC_Stop_IT(TSC_HandleTypeDef* htsc) |
mbed_official | 181:a4cbdfbbd2f4 | 435 | { |
mbed_official | 181:a4cbdfbbd2f4 | 436 | /* Check the parameters */ |
mbed_official | 181:a4cbdfbbd2f4 | 437 | assert_param(IS_TSC_ALL_INSTANCE(htsc->Instance)); |
mbed_official | 181:a4cbdfbbd2f4 | 438 | |
mbed_official | 181:a4cbdfbbd2f4 | 439 | /* Process locked */ |
mbed_official | 181:a4cbdfbbd2f4 | 440 | __HAL_LOCK(htsc); |
mbed_official | 181:a4cbdfbbd2f4 | 441 | |
mbed_official | 181:a4cbdfbbd2f4 | 442 | /* Stop the acquisition */ |
mbed_official | 181:a4cbdfbbd2f4 | 443 | __HAL_TSC_STOP_ACQ(htsc); |
mbed_official | 181:a4cbdfbbd2f4 | 444 | |
mbed_official | 181:a4cbdfbbd2f4 | 445 | /* Disable interrupts */ |
mbed_official | 181:a4cbdfbbd2f4 | 446 | __HAL_TSC_DISABLE_IT(htsc, (TSC_IT_EOA | TSC_IT_MCE)); |
mbed_official | 181:a4cbdfbbd2f4 | 447 | |
mbed_official | 181:a4cbdfbbd2f4 | 448 | /* Clear flags */ |
mbed_official | 181:a4cbdfbbd2f4 | 449 | __HAL_TSC_CLEAR_FLAG(htsc, (TSC_FLAG_EOA | TSC_FLAG_MCE)); |
mbed_official | 181:a4cbdfbbd2f4 | 450 | |
mbed_official | 181:a4cbdfbbd2f4 | 451 | /* Change TSC state */ |
mbed_official | 181:a4cbdfbbd2f4 | 452 | htsc->State = HAL_TSC_STATE_READY; |
mbed_official | 181:a4cbdfbbd2f4 | 453 | |
mbed_official | 181:a4cbdfbbd2f4 | 454 | /* Process unlocked */ |
mbed_official | 181:a4cbdfbbd2f4 | 455 | __HAL_UNLOCK(htsc); |
mbed_official | 181:a4cbdfbbd2f4 | 456 | |
mbed_official | 181:a4cbdfbbd2f4 | 457 | /* Return function status */ |
mbed_official | 181:a4cbdfbbd2f4 | 458 | return HAL_OK; |
mbed_official | 181:a4cbdfbbd2f4 | 459 | } |
mbed_official | 181:a4cbdfbbd2f4 | 460 | |
mbed_official | 181:a4cbdfbbd2f4 | 461 | /** |
mbed_official | 181:a4cbdfbbd2f4 | 462 | * @brief Gets the acquisition status for a group |
mbed_official | 181:a4cbdfbbd2f4 | 463 | * @param htsc: pointer to a TSC_HandleTypeDef structure that contains |
mbed_official | 181:a4cbdfbbd2f4 | 464 | * the configuration information for the specified TSC. |
mbed_official | 181:a4cbdfbbd2f4 | 465 | * @param gx_index: Index of the group |
mbed_official | 181:a4cbdfbbd2f4 | 466 | * @retval Group status |
mbed_official | 181:a4cbdfbbd2f4 | 467 | */ |
mbed_official | 181:a4cbdfbbd2f4 | 468 | TSC_GroupStatusTypeDef HAL_TSC_GroupGetStatus(TSC_HandleTypeDef* htsc, uint32_t gx_index) |
mbed_official | 181:a4cbdfbbd2f4 | 469 | { |
mbed_official | 181:a4cbdfbbd2f4 | 470 | /* Check the parameters */ |
mbed_official | 181:a4cbdfbbd2f4 | 471 | assert_param(IS_TSC_ALL_INSTANCE(htsc->Instance)); |
mbed_official | 181:a4cbdfbbd2f4 | 472 | assert_param(IS_GROUP_INDEX(gx_index)); |
mbed_official | 181:a4cbdfbbd2f4 | 473 | |
mbed_official | 181:a4cbdfbbd2f4 | 474 | /* Return the group status */ |
mbed_official | 181:a4cbdfbbd2f4 | 475 | return(__HAL_TSC_GET_GROUP_STATUS(htsc, gx_index)); |
mbed_official | 181:a4cbdfbbd2f4 | 476 | } |
mbed_official | 181:a4cbdfbbd2f4 | 477 | |
mbed_official | 181:a4cbdfbbd2f4 | 478 | /** |
mbed_official | 181:a4cbdfbbd2f4 | 479 | * @brief Gets the acquisition measure for a group |
mbed_official | 181:a4cbdfbbd2f4 | 480 | * @param htsc: pointer to a TSC_HandleTypeDef structure that contains |
mbed_official | 181:a4cbdfbbd2f4 | 481 | * the configuration information for the specified TSC. |
mbed_official | 181:a4cbdfbbd2f4 | 482 | * @param gx_index: Index of the group |
mbed_official | 181:a4cbdfbbd2f4 | 483 | * @retval Acquisition measure |
mbed_official | 181:a4cbdfbbd2f4 | 484 | */ |
mbed_official | 181:a4cbdfbbd2f4 | 485 | uint32_t HAL_TSC_GroupGetValue(TSC_HandleTypeDef* htsc, uint32_t gx_index) |
mbed_official | 181:a4cbdfbbd2f4 | 486 | { |
mbed_official | 181:a4cbdfbbd2f4 | 487 | /* Check the parameters */ |
mbed_official | 181:a4cbdfbbd2f4 | 488 | assert_param(IS_TSC_ALL_INSTANCE(htsc->Instance)); |
mbed_official | 181:a4cbdfbbd2f4 | 489 | assert_param(IS_GROUP_INDEX(gx_index)); |
mbed_official | 181:a4cbdfbbd2f4 | 490 | |
mbed_official | 181:a4cbdfbbd2f4 | 491 | /* Return the group acquisition counter */ |
mbed_official | 181:a4cbdfbbd2f4 | 492 | return htsc->Instance->IOGXCR[gx_index]; |
mbed_official | 181:a4cbdfbbd2f4 | 493 | } |
mbed_official | 181:a4cbdfbbd2f4 | 494 | |
mbed_official | 181:a4cbdfbbd2f4 | 495 | /** |
mbed_official | 181:a4cbdfbbd2f4 | 496 | * @} |
mbed_official | 181:a4cbdfbbd2f4 | 497 | */ |
mbed_official | 181:a4cbdfbbd2f4 | 498 | |
mbed_official | 181:a4cbdfbbd2f4 | 499 | /** @defgroup HAL_TSC_Group3 Peripheral Control functions |
mbed_official | 181:a4cbdfbbd2f4 | 500 | * @brief Peripheral Control functions |
mbed_official | 181:a4cbdfbbd2f4 | 501 | * |
mbed_official | 181:a4cbdfbbd2f4 | 502 | @verbatim |
mbed_official | 181:a4cbdfbbd2f4 | 503 | =============================================================================== |
mbed_official | 181:a4cbdfbbd2f4 | 504 | ##### Peripheral Control functions ##### |
mbed_official | 181:a4cbdfbbd2f4 | 505 | =============================================================================== |
mbed_official | 181:a4cbdfbbd2f4 | 506 | [..] This section provides functions allowing to: |
mbed_official | 181:a4cbdfbbd2f4 | 507 | (+) Configure TSC IOs |
mbed_official | 181:a4cbdfbbd2f4 | 508 | (+) Discharge TSC IOs |
mbed_official | 181:a4cbdfbbd2f4 | 509 | @endverbatim |
mbed_official | 181:a4cbdfbbd2f4 | 510 | * @{ |
mbed_official | 181:a4cbdfbbd2f4 | 511 | */ |
mbed_official | 181:a4cbdfbbd2f4 | 512 | |
mbed_official | 181:a4cbdfbbd2f4 | 513 | /** |
mbed_official | 181:a4cbdfbbd2f4 | 514 | * @brief Configures TSC IOs |
mbed_official | 181:a4cbdfbbd2f4 | 515 | * @param htsc: pointer to a TSC_HandleTypeDef structure that contains |
mbed_official | 181:a4cbdfbbd2f4 | 516 | * the configuration information for the specified TSC. |
mbed_official | 181:a4cbdfbbd2f4 | 517 | * @param config: pointer to the configuration structure. |
mbed_official | 181:a4cbdfbbd2f4 | 518 | * @retval HAL status |
mbed_official | 181:a4cbdfbbd2f4 | 519 | */ |
mbed_official | 181:a4cbdfbbd2f4 | 520 | HAL_StatusTypeDef HAL_TSC_IOConfig(TSC_HandleTypeDef* htsc, TSC_IOConfigTypeDef* config) |
mbed_official | 181:a4cbdfbbd2f4 | 521 | { |
mbed_official | 181:a4cbdfbbd2f4 | 522 | /* Check the parameters */ |
mbed_official | 181:a4cbdfbbd2f4 | 523 | assert_param(IS_TSC_ALL_INSTANCE(htsc->Instance)); |
mbed_official | 181:a4cbdfbbd2f4 | 524 | |
mbed_official | 181:a4cbdfbbd2f4 | 525 | /* Process locked */ |
mbed_official | 181:a4cbdfbbd2f4 | 526 | __HAL_LOCK(htsc); |
mbed_official | 181:a4cbdfbbd2f4 | 527 | |
mbed_official | 181:a4cbdfbbd2f4 | 528 | /* Stop acquisition */ |
mbed_official | 181:a4cbdfbbd2f4 | 529 | __HAL_TSC_STOP_ACQ(htsc); |
mbed_official | 181:a4cbdfbbd2f4 | 530 | |
mbed_official | 181:a4cbdfbbd2f4 | 531 | /* Disable Schmitt trigger hysteresis on all used TSC IOs */ |
mbed_official | 181:a4cbdfbbd2f4 | 532 | htsc->Instance->IOHCR = (uint32_t)(~(config->ChannelIOs | config->ShieldIOs | config->SamplingIOs)); |
mbed_official | 181:a4cbdfbbd2f4 | 533 | |
mbed_official | 181:a4cbdfbbd2f4 | 534 | /* Set channel and shield IOs */ |
mbed_official | 181:a4cbdfbbd2f4 | 535 | htsc->Instance->IOCCR = (config->ChannelIOs | config->ShieldIOs); |
mbed_official | 181:a4cbdfbbd2f4 | 536 | |
mbed_official | 181:a4cbdfbbd2f4 | 537 | /* Set sampling IOs */ |
mbed_official | 181:a4cbdfbbd2f4 | 538 | htsc->Instance->IOSCR = config->SamplingIOs; |
mbed_official | 181:a4cbdfbbd2f4 | 539 | |
mbed_official | 181:a4cbdfbbd2f4 | 540 | /* Set groups to be acquired */ |
mbed_official | 181:a4cbdfbbd2f4 | 541 | htsc->Instance->IOGCSR = TSC_extract_groups(config->ChannelIOs); |
mbed_official | 181:a4cbdfbbd2f4 | 542 | |
mbed_official | 181:a4cbdfbbd2f4 | 543 | /* Process unlocked */ |
mbed_official | 181:a4cbdfbbd2f4 | 544 | __HAL_UNLOCK(htsc); |
mbed_official | 181:a4cbdfbbd2f4 | 545 | |
mbed_official | 181:a4cbdfbbd2f4 | 546 | /* Return function status */ |
mbed_official | 181:a4cbdfbbd2f4 | 547 | return HAL_OK; |
mbed_official | 181:a4cbdfbbd2f4 | 548 | } |
mbed_official | 181:a4cbdfbbd2f4 | 549 | |
mbed_official | 181:a4cbdfbbd2f4 | 550 | /** |
mbed_official | 181:a4cbdfbbd2f4 | 551 | * @brief Discharge TSC IOs |
mbed_official | 181:a4cbdfbbd2f4 | 552 | * @param htsc: pointer to a TSC_HandleTypeDef structure that contains |
mbed_official | 181:a4cbdfbbd2f4 | 553 | * the configuration information for the specified TSC. |
mbed_official | 181:a4cbdfbbd2f4 | 554 | * @param choice: enable or disable |
mbed_official | 181:a4cbdfbbd2f4 | 555 | * @retval HAL status |
mbed_official | 181:a4cbdfbbd2f4 | 556 | */ |
mbed_official | 181:a4cbdfbbd2f4 | 557 | HAL_StatusTypeDef HAL_TSC_IODischarge(TSC_HandleTypeDef* htsc, uint32_t choice) |
mbed_official | 181:a4cbdfbbd2f4 | 558 | { |
mbed_official | 181:a4cbdfbbd2f4 | 559 | /* Check the parameters */ |
mbed_official | 181:a4cbdfbbd2f4 | 560 | assert_param(IS_TSC_ALL_INSTANCE(htsc->Instance)); |
mbed_official | 181:a4cbdfbbd2f4 | 561 | |
mbed_official | 181:a4cbdfbbd2f4 | 562 | /* Process locked */ |
mbed_official | 181:a4cbdfbbd2f4 | 563 | __HAL_LOCK(htsc); |
mbed_official | 181:a4cbdfbbd2f4 | 564 | |
mbed_official | 181:a4cbdfbbd2f4 | 565 | if (choice == ENABLE) |
mbed_official | 181:a4cbdfbbd2f4 | 566 | { |
mbed_official | 181:a4cbdfbbd2f4 | 567 | __HAL_TSC_SET_IODEF_OUTPPLOW(htsc); |
mbed_official | 181:a4cbdfbbd2f4 | 568 | } |
mbed_official | 181:a4cbdfbbd2f4 | 569 | else |
mbed_official | 181:a4cbdfbbd2f4 | 570 | { |
mbed_official | 181:a4cbdfbbd2f4 | 571 | __HAL_TSC_SET_IODEF_INFLOAT(htsc); |
mbed_official | 181:a4cbdfbbd2f4 | 572 | } |
mbed_official | 181:a4cbdfbbd2f4 | 573 | |
mbed_official | 181:a4cbdfbbd2f4 | 574 | /* Process unlocked */ |
mbed_official | 181:a4cbdfbbd2f4 | 575 | __HAL_UNLOCK(htsc); |
mbed_official | 181:a4cbdfbbd2f4 | 576 | |
mbed_official | 181:a4cbdfbbd2f4 | 577 | /* Return the group acquisition counter */ |
mbed_official | 181:a4cbdfbbd2f4 | 578 | return HAL_OK; |
mbed_official | 181:a4cbdfbbd2f4 | 579 | } |
mbed_official | 181:a4cbdfbbd2f4 | 580 | |
mbed_official | 181:a4cbdfbbd2f4 | 581 | /** |
mbed_official | 181:a4cbdfbbd2f4 | 582 | * @} |
mbed_official | 181:a4cbdfbbd2f4 | 583 | */ |
mbed_official | 181:a4cbdfbbd2f4 | 584 | |
mbed_official | 181:a4cbdfbbd2f4 | 585 | /** @defgroup HAL_TSC_Group4 State functions |
mbed_official | 181:a4cbdfbbd2f4 | 586 | * @brief State functions |
mbed_official | 181:a4cbdfbbd2f4 | 587 | * |
mbed_official | 181:a4cbdfbbd2f4 | 588 | @verbatim |
mbed_official | 181:a4cbdfbbd2f4 | 589 | =============================================================================== |
mbed_official | 181:a4cbdfbbd2f4 | 590 | ##### State functions ##### |
mbed_official | 181:a4cbdfbbd2f4 | 591 | =============================================================================== |
mbed_official | 181:a4cbdfbbd2f4 | 592 | [..] |
mbed_official | 181:a4cbdfbbd2f4 | 593 | This subsection provides functions allowing to |
mbed_official | 181:a4cbdfbbd2f4 | 594 | (+) Get TSC state. |
mbed_official | 181:a4cbdfbbd2f4 | 595 | (+) Poll for acquisition completed. |
mbed_official | 181:a4cbdfbbd2f4 | 596 | (+) Handles TSC interrupt request. |
mbed_official | 181:a4cbdfbbd2f4 | 597 | |
mbed_official | 181:a4cbdfbbd2f4 | 598 | @endverbatim |
mbed_official | 181:a4cbdfbbd2f4 | 599 | * @{ |
mbed_official | 181:a4cbdfbbd2f4 | 600 | */ |
mbed_official | 181:a4cbdfbbd2f4 | 601 | |
mbed_official | 181:a4cbdfbbd2f4 | 602 | /** |
mbed_official | 181:a4cbdfbbd2f4 | 603 | * @brief Return the TSC state |
mbed_official | 181:a4cbdfbbd2f4 | 604 | * @param htsc: pointer to a TSC_HandleTypeDef structure that contains |
mbed_official | 181:a4cbdfbbd2f4 | 605 | * the configuration information for the specified TSC. |
mbed_official | 181:a4cbdfbbd2f4 | 606 | * @retval HAL state |
mbed_official | 181:a4cbdfbbd2f4 | 607 | */ |
mbed_official | 181:a4cbdfbbd2f4 | 608 | HAL_TSC_StateTypeDef HAL_TSC_GetState(TSC_HandleTypeDef* htsc) |
mbed_official | 181:a4cbdfbbd2f4 | 609 | { |
mbed_official | 181:a4cbdfbbd2f4 | 610 | /* Check the parameters */ |
mbed_official | 181:a4cbdfbbd2f4 | 611 | assert_param(IS_TSC_ALL_INSTANCE(htsc->Instance)); |
mbed_official | 181:a4cbdfbbd2f4 | 612 | |
mbed_official | 181:a4cbdfbbd2f4 | 613 | if (htsc->State == HAL_TSC_STATE_BUSY) |
mbed_official | 181:a4cbdfbbd2f4 | 614 | { |
mbed_official | 181:a4cbdfbbd2f4 | 615 | /* Check end of acquisition flag */ |
mbed_official | 181:a4cbdfbbd2f4 | 616 | if (__HAL_TSC_GET_FLAG(htsc, TSC_FLAG_EOA) != RESET) |
mbed_official | 181:a4cbdfbbd2f4 | 617 | { |
mbed_official | 181:a4cbdfbbd2f4 | 618 | /* Check max count error flag */ |
mbed_official | 181:a4cbdfbbd2f4 | 619 | if (__HAL_TSC_GET_FLAG(htsc, TSC_FLAG_MCE) != RESET) |
mbed_official | 181:a4cbdfbbd2f4 | 620 | { |
mbed_official | 181:a4cbdfbbd2f4 | 621 | /* Change TSC state */ |
mbed_official | 181:a4cbdfbbd2f4 | 622 | htsc->State = HAL_TSC_STATE_ERROR; |
mbed_official | 181:a4cbdfbbd2f4 | 623 | } |
mbed_official | 181:a4cbdfbbd2f4 | 624 | else |
mbed_official | 181:a4cbdfbbd2f4 | 625 | { |
mbed_official | 181:a4cbdfbbd2f4 | 626 | /* Change TSC state */ |
mbed_official | 181:a4cbdfbbd2f4 | 627 | htsc->State = HAL_TSC_STATE_READY; |
mbed_official | 181:a4cbdfbbd2f4 | 628 | } |
mbed_official | 181:a4cbdfbbd2f4 | 629 | } |
mbed_official | 181:a4cbdfbbd2f4 | 630 | } |
mbed_official | 181:a4cbdfbbd2f4 | 631 | |
mbed_official | 181:a4cbdfbbd2f4 | 632 | /* Return TSC state */ |
mbed_official | 181:a4cbdfbbd2f4 | 633 | return htsc->State; |
mbed_official | 181:a4cbdfbbd2f4 | 634 | } |
mbed_official | 181:a4cbdfbbd2f4 | 635 | |
mbed_official | 181:a4cbdfbbd2f4 | 636 | /** |
mbed_official | 181:a4cbdfbbd2f4 | 637 | * @brief Start acquisition and wait until completion |
mbed_official | 181:a4cbdfbbd2f4 | 638 | * @note There is no need of a timeout parameter as the max count error is already |
mbed_official | 181:a4cbdfbbd2f4 | 639 | * managed by the TSC peripheral. |
mbed_official | 181:a4cbdfbbd2f4 | 640 | * @param htsc: pointer to a TSC_HandleTypeDef structure that contains |
mbed_official | 181:a4cbdfbbd2f4 | 641 | * the configuration information for the specified TSC. |
mbed_official | 181:a4cbdfbbd2f4 | 642 | * @retval HAL state |
mbed_official | 181:a4cbdfbbd2f4 | 643 | */ |
mbed_official | 181:a4cbdfbbd2f4 | 644 | HAL_StatusTypeDef HAL_TSC_PollForAcquisition(TSC_HandleTypeDef* htsc) |
mbed_official | 181:a4cbdfbbd2f4 | 645 | { |
mbed_official | 181:a4cbdfbbd2f4 | 646 | /* Check the parameters */ |
mbed_official | 181:a4cbdfbbd2f4 | 647 | assert_param(IS_TSC_ALL_INSTANCE(htsc->Instance)); |
mbed_official | 181:a4cbdfbbd2f4 | 648 | |
mbed_official | 181:a4cbdfbbd2f4 | 649 | /* Process locked */ |
mbed_official | 181:a4cbdfbbd2f4 | 650 | __HAL_LOCK(htsc); |
mbed_official | 181:a4cbdfbbd2f4 | 651 | |
mbed_official | 181:a4cbdfbbd2f4 | 652 | /* Check end of acquisition */ |
mbed_official | 181:a4cbdfbbd2f4 | 653 | while (HAL_TSC_GetState(htsc) == HAL_TSC_STATE_BUSY) |
mbed_official | 181:a4cbdfbbd2f4 | 654 | { |
mbed_official | 181:a4cbdfbbd2f4 | 655 | /* The timeout (max count error) is managed by the TSC peripheral itself. */ |
mbed_official | 181:a4cbdfbbd2f4 | 656 | } |
mbed_official | 181:a4cbdfbbd2f4 | 657 | |
mbed_official | 181:a4cbdfbbd2f4 | 658 | /* Process unlocked */ |
mbed_official | 181:a4cbdfbbd2f4 | 659 | __HAL_UNLOCK(htsc); |
mbed_official | 181:a4cbdfbbd2f4 | 660 | |
mbed_official | 181:a4cbdfbbd2f4 | 661 | return HAL_OK; |
mbed_official | 181:a4cbdfbbd2f4 | 662 | } |
mbed_official | 181:a4cbdfbbd2f4 | 663 | |
mbed_official | 181:a4cbdfbbd2f4 | 664 | /** |
mbed_official | 181:a4cbdfbbd2f4 | 665 | * @brief Handles TSC interrupt request |
mbed_official | 181:a4cbdfbbd2f4 | 666 | * @param htsc: pointer to a TSC_HandleTypeDef structure that contains |
mbed_official | 181:a4cbdfbbd2f4 | 667 | * the configuration information for the specified TSC. |
mbed_official | 181:a4cbdfbbd2f4 | 668 | * @retval None |
mbed_official | 181:a4cbdfbbd2f4 | 669 | */ |
mbed_official | 181:a4cbdfbbd2f4 | 670 | void HAL_TSC_IRQHandler(TSC_HandleTypeDef* htsc) |
mbed_official | 181:a4cbdfbbd2f4 | 671 | { |
mbed_official | 181:a4cbdfbbd2f4 | 672 | /* Check the parameters */ |
mbed_official | 181:a4cbdfbbd2f4 | 673 | assert_param(IS_TSC_ALL_INSTANCE(htsc->Instance)); |
mbed_official | 181:a4cbdfbbd2f4 | 674 | |
mbed_official | 181:a4cbdfbbd2f4 | 675 | /* Check if the end of acquisition occured */ |
mbed_official | 181:a4cbdfbbd2f4 | 676 | if (__HAL_TSC_GET_FLAG(htsc, TSC_FLAG_EOA) != RESET) |
mbed_official | 181:a4cbdfbbd2f4 | 677 | { |
mbed_official | 181:a4cbdfbbd2f4 | 678 | /* Clear EOA flag */ |
mbed_official | 181:a4cbdfbbd2f4 | 679 | __HAL_TSC_CLEAR_FLAG(htsc, TSC_FLAG_EOA); |
mbed_official | 181:a4cbdfbbd2f4 | 680 | } |
mbed_official | 181:a4cbdfbbd2f4 | 681 | |
mbed_official | 181:a4cbdfbbd2f4 | 682 | /* Check if max count error occured */ |
mbed_official | 181:a4cbdfbbd2f4 | 683 | if (__HAL_TSC_GET_FLAG(htsc, TSC_FLAG_MCE) != RESET) |
mbed_official | 181:a4cbdfbbd2f4 | 684 | { |
mbed_official | 181:a4cbdfbbd2f4 | 685 | /* Clear MCE flag */ |
mbed_official | 181:a4cbdfbbd2f4 | 686 | __HAL_TSC_CLEAR_FLAG(htsc, TSC_FLAG_MCE); |
mbed_official | 181:a4cbdfbbd2f4 | 687 | /* Change TSC state */ |
mbed_official | 181:a4cbdfbbd2f4 | 688 | htsc->State = HAL_TSC_STATE_ERROR; |
mbed_official | 181:a4cbdfbbd2f4 | 689 | /* Conversion completed callback */ |
mbed_official | 181:a4cbdfbbd2f4 | 690 | HAL_TSC_ErrorCallback(htsc); |
mbed_official | 181:a4cbdfbbd2f4 | 691 | } |
mbed_official | 181:a4cbdfbbd2f4 | 692 | else |
mbed_official | 181:a4cbdfbbd2f4 | 693 | { |
mbed_official | 181:a4cbdfbbd2f4 | 694 | /* Change TSC state */ |
mbed_official | 181:a4cbdfbbd2f4 | 695 | htsc->State = HAL_TSC_STATE_READY; |
mbed_official | 181:a4cbdfbbd2f4 | 696 | /* Conversion completed callback */ |
mbed_official | 181:a4cbdfbbd2f4 | 697 | HAL_TSC_ConvCpltCallback(htsc); |
mbed_official | 181:a4cbdfbbd2f4 | 698 | } |
mbed_official | 181:a4cbdfbbd2f4 | 699 | } |
mbed_official | 181:a4cbdfbbd2f4 | 700 | |
mbed_official | 181:a4cbdfbbd2f4 | 701 | /** |
mbed_official | 181:a4cbdfbbd2f4 | 702 | * @} |
mbed_official | 181:a4cbdfbbd2f4 | 703 | */ |
mbed_official | 181:a4cbdfbbd2f4 | 704 | |
mbed_official | 181:a4cbdfbbd2f4 | 705 | /** |
mbed_official | 181:a4cbdfbbd2f4 | 706 | * @brief Acquisition completed callback in non blocking mode |
mbed_official | 181:a4cbdfbbd2f4 | 707 | * @param htsc: pointer to a TSC_HandleTypeDef structure that contains |
mbed_official | 181:a4cbdfbbd2f4 | 708 | * the configuration information for the specified TSC. |
mbed_official | 181:a4cbdfbbd2f4 | 709 | * @retval None |
mbed_official | 181:a4cbdfbbd2f4 | 710 | */ |
mbed_official | 181:a4cbdfbbd2f4 | 711 | __weak void HAL_TSC_ConvCpltCallback(TSC_HandleTypeDef* htsc) |
mbed_official | 181:a4cbdfbbd2f4 | 712 | { |
mbed_official | 181:a4cbdfbbd2f4 | 713 | /* NOTE : This function should not be modified, when the callback is needed, |
mbed_official | 181:a4cbdfbbd2f4 | 714 | the HAL_TSC_ConvCpltCallback could be implemented in the user file. |
mbed_official | 181:a4cbdfbbd2f4 | 715 | */ |
mbed_official | 181:a4cbdfbbd2f4 | 716 | } |
mbed_official | 181:a4cbdfbbd2f4 | 717 | |
mbed_official | 181:a4cbdfbbd2f4 | 718 | /** |
mbed_official | 181:a4cbdfbbd2f4 | 719 | * @brief Error callback in non blocking mode |
mbed_official | 181:a4cbdfbbd2f4 | 720 | * @param htsc: pointer to a TSC_HandleTypeDef structure that contains |
mbed_official | 181:a4cbdfbbd2f4 | 721 | * the configuration information for the specified TSC. |
mbed_official | 181:a4cbdfbbd2f4 | 722 | * @retval None |
mbed_official | 181:a4cbdfbbd2f4 | 723 | */ |
mbed_official | 181:a4cbdfbbd2f4 | 724 | __weak void HAL_TSC_ErrorCallback(TSC_HandleTypeDef* htsc) |
mbed_official | 181:a4cbdfbbd2f4 | 725 | { |
mbed_official | 181:a4cbdfbbd2f4 | 726 | /* NOTE : This function should not be modified, when the callback is needed, |
mbed_official | 181:a4cbdfbbd2f4 | 727 | the HAL_TSC_ErrorCallback could be implemented in the user file. |
mbed_official | 181:a4cbdfbbd2f4 | 728 | */ |
mbed_official | 181:a4cbdfbbd2f4 | 729 | } |
mbed_official | 181:a4cbdfbbd2f4 | 730 | |
mbed_official | 181:a4cbdfbbd2f4 | 731 | /** |
mbed_official | 181:a4cbdfbbd2f4 | 732 | * @brief Utility function used to set the acquired groups mask |
mbed_official | 181:a4cbdfbbd2f4 | 733 | * @param iomask: Channels IOs mask |
mbed_official | 181:a4cbdfbbd2f4 | 734 | * @retval Acquired groups mask |
mbed_official | 181:a4cbdfbbd2f4 | 735 | */ |
mbed_official | 181:a4cbdfbbd2f4 | 736 | static uint32_t TSC_extract_groups(uint32_t iomask) |
mbed_official | 181:a4cbdfbbd2f4 | 737 | { |
mbed_official | 181:a4cbdfbbd2f4 | 738 | uint32_t groups = 0; |
mbed_official | 181:a4cbdfbbd2f4 | 739 | uint32_t idx; |
mbed_official | 181:a4cbdfbbd2f4 | 740 | |
mbed_official | 181:a4cbdfbbd2f4 | 741 | for (idx = 0; idx < TSC_NB_OF_GROUPS; idx++) |
mbed_official | 181:a4cbdfbbd2f4 | 742 | { |
mbed_official | 181:a4cbdfbbd2f4 | 743 | if ((iomask & ((uint32_t)0x0F << (idx * 4))) != RESET) |
mbed_official | 181:a4cbdfbbd2f4 | 744 | { |
mbed_official | 181:a4cbdfbbd2f4 | 745 | groups |= ((uint32_t)1 << idx); |
mbed_official | 181:a4cbdfbbd2f4 | 746 | } |
mbed_official | 181:a4cbdfbbd2f4 | 747 | } |
mbed_official | 181:a4cbdfbbd2f4 | 748 | |
mbed_official | 181:a4cbdfbbd2f4 | 749 | return groups; |
mbed_official | 181:a4cbdfbbd2f4 | 750 | } |
mbed_official | 181:a4cbdfbbd2f4 | 751 | |
mbed_official | 181:a4cbdfbbd2f4 | 752 | /** |
mbed_official | 181:a4cbdfbbd2f4 | 753 | * @} |
mbed_official | 181:a4cbdfbbd2f4 | 754 | */ |
mbed_official | 181:a4cbdfbbd2f4 | 755 | |
mbed_official | 181:a4cbdfbbd2f4 | 756 | #endif /* HAL_TSC_MODULE_ENABLED */ |
mbed_official | 181:a4cbdfbbd2f4 | 757 | |
mbed_official | 181:a4cbdfbbd2f4 | 758 | /** |
mbed_official | 181:a4cbdfbbd2f4 | 759 | * @} |
mbed_official | 181:a4cbdfbbd2f4 | 760 | */ |
mbed_official | 181:a4cbdfbbd2f4 | 761 | |
mbed_official | 181:a4cbdfbbd2f4 | 762 | /** |
mbed_official | 181:a4cbdfbbd2f4 | 763 | * @} |
mbed_official | 181:a4cbdfbbd2f4 | 764 | */ |
mbed_official | 181:a4cbdfbbd2f4 | 765 | |
mbed_official | 181:a4cbdfbbd2f4 | 766 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |