my fork
Fork of mbed by
TARGET_NUCLEO_F072RB/stm32f0xx_hal_tsc.h@85:024bf7f99721, 2014-06-11 (annotated)
- Committer:
- bogdanm
- Date:
- Wed Jun 11 15:14:05 2014 +0100
- Revision:
- 85:024bf7f99721
- Child:
- 92:4fc01daae5a5
Release 85 of the mbed library
Main changes:
- K64F Ethernet fixes
- Updated tests
- Fixes for various mbed targets
- Code cleanup: fixed warnings, more consistent code style
- GCC support for K64F
There is a known issue with the I2C interface on some ST targets. If you
find the I2C interface problematic on your ST board, please log a bug
against this on mbed.org.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
bogdanm | 85:024bf7f99721 | 1 | /** |
bogdanm | 85:024bf7f99721 | 2 | ****************************************************************************** |
bogdanm | 85:024bf7f99721 | 3 | * @file stm32f0xx_hal_tsc.h |
bogdanm | 85:024bf7f99721 | 4 | * @author MCD Application Team |
bogdanm | 85:024bf7f99721 | 5 | * @version V1.0.0 |
bogdanm | 85:024bf7f99721 | 6 | * @date 28-May-2014 |
bogdanm | 85:024bf7f99721 | 7 | * @brief This file contains all the functions prototypes for the TSC firmware |
bogdanm | 85:024bf7f99721 | 8 | * library. |
bogdanm | 85:024bf7f99721 | 9 | ****************************************************************************** |
bogdanm | 85:024bf7f99721 | 10 | * @attention |
bogdanm | 85:024bf7f99721 | 11 | * |
bogdanm | 85:024bf7f99721 | 12 | * <h2><center>© COPYRIGHT(c) 2014 STMicroelectronics</center></h2> |
bogdanm | 85:024bf7f99721 | 13 | * |
bogdanm | 85:024bf7f99721 | 14 | * Redistribution and use in source and binary forms, with or without modification, |
bogdanm | 85:024bf7f99721 | 15 | * are permitted provided that the following conditions are met: |
bogdanm | 85:024bf7f99721 | 16 | * 1. Redistributions of source code must retain the above copyright notice, |
bogdanm | 85:024bf7f99721 | 17 | * this list of conditions and the following disclaimer. |
bogdanm | 85:024bf7f99721 | 18 | * 2. Redistributions in binary form must reproduce the above copyright notice, |
bogdanm | 85:024bf7f99721 | 19 | * this list of conditions and the following disclaimer in the documentation |
bogdanm | 85:024bf7f99721 | 20 | * and/or other materials provided with the distribution. |
bogdanm | 85:024bf7f99721 | 21 | * 3. Neither the name of STMicroelectronics nor the names of its contributors |
bogdanm | 85:024bf7f99721 | 22 | * may be used to endorse or promote products derived from this software |
bogdanm | 85:024bf7f99721 | 23 | * without specific prior written permission. |
bogdanm | 85:024bf7f99721 | 24 | * |
bogdanm | 85:024bf7f99721 | 25 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
bogdanm | 85:024bf7f99721 | 26 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
bogdanm | 85:024bf7f99721 | 27 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
bogdanm | 85:024bf7f99721 | 28 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE |
bogdanm | 85:024bf7f99721 | 29 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
bogdanm | 85:024bf7f99721 | 30 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
bogdanm | 85:024bf7f99721 | 31 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
bogdanm | 85:024bf7f99721 | 32 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
bogdanm | 85:024bf7f99721 | 33 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
bogdanm | 85:024bf7f99721 | 34 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
bogdanm | 85:024bf7f99721 | 35 | * |
bogdanm | 85:024bf7f99721 | 36 | ****************************************************************************** |
bogdanm | 85:024bf7f99721 | 37 | */ |
bogdanm | 85:024bf7f99721 | 38 | |
bogdanm | 85:024bf7f99721 | 39 | /* Define to prevent recursive inclusion -------------------------------------*/ |
bogdanm | 85:024bf7f99721 | 40 | #ifndef __STM32F0xx_TSC_H |
bogdanm | 85:024bf7f99721 | 41 | #define __STM32F0xx_TSC_H |
bogdanm | 85:024bf7f99721 | 42 | |
bogdanm | 85:024bf7f99721 | 43 | #ifdef __cplusplus |
bogdanm | 85:024bf7f99721 | 44 | extern "C" { |
bogdanm | 85:024bf7f99721 | 45 | #endif |
bogdanm | 85:024bf7f99721 | 46 | |
bogdanm | 85:024bf7f99721 | 47 | #if defined(STM32F051x8) || defined(STM32F071xB) || \ |
bogdanm | 85:024bf7f99721 | 48 | defined(STM32F042x6) || defined(STM32F048xx) || defined(STM32F072xB) || \ |
bogdanm | 85:024bf7f99721 | 49 | defined(STM32F058xx) || defined(STM32F078xx) |
bogdanm | 85:024bf7f99721 | 50 | |
bogdanm | 85:024bf7f99721 | 51 | /* Includes ------------------------------------------------------------------*/ |
bogdanm | 85:024bf7f99721 | 52 | #include "stm32f0xx_hal_def.h" |
bogdanm | 85:024bf7f99721 | 53 | |
bogdanm | 85:024bf7f99721 | 54 | /** @addtogroup STM32F0xx_HAL_Driver |
bogdanm | 85:024bf7f99721 | 55 | * @{ |
bogdanm | 85:024bf7f99721 | 56 | */ |
bogdanm | 85:024bf7f99721 | 57 | |
bogdanm | 85:024bf7f99721 | 58 | /** @addtogroup TSC |
bogdanm | 85:024bf7f99721 | 59 | * @{ |
bogdanm | 85:024bf7f99721 | 60 | */ |
bogdanm | 85:024bf7f99721 | 61 | |
bogdanm | 85:024bf7f99721 | 62 | /* Exported types ------------------------------------------------------------*/ |
bogdanm | 85:024bf7f99721 | 63 | |
bogdanm | 85:024bf7f99721 | 64 | /** |
bogdanm | 85:024bf7f99721 | 65 | * @brief TSC state structure definition |
bogdanm | 85:024bf7f99721 | 66 | */ |
bogdanm | 85:024bf7f99721 | 67 | typedef enum |
bogdanm | 85:024bf7f99721 | 68 | { |
bogdanm | 85:024bf7f99721 | 69 | HAL_TSC_STATE_RESET = 0x00, /*!< TSC registers have their reset value */ |
bogdanm | 85:024bf7f99721 | 70 | HAL_TSC_STATE_READY = 0x01, /*!< TSC registers are initialized or acquisition is completed with success */ |
bogdanm | 85:024bf7f99721 | 71 | HAL_TSC_STATE_BUSY = 0x02, /*!< TSC initialization or acquisition is on-going */ |
bogdanm | 85:024bf7f99721 | 72 | HAL_TSC_STATE_ERROR = 0x03 /*!< Acquisition is completed with max count error */ |
bogdanm | 85:024bf7f99721 | 73 | } HAL_TSC_StateTypeDef; |
bogdanm | 85:024bf7f99721 | 74 | |
bogdanm | 85:024bf7f99721 | 75 | /** |
bogdanm | 85:024bf7f99721 | 76 | * @brief TSC group status structure definition |
bogdanm | 85:024bf7f99721 | 77 | */ |
bogdanm | 85:024bf7f99721 | 78 | typedef enum |
bogdanm | 85:024bf7f99721 | 79 | { |
bogdanm | 85:024bf7f99721 | 80 | TSC_GROUP_ONGOING = 0x00, /*!< Acquisition on group is on-going or not started */ |
bogdanm | 85:024bf7f99721 | 81 | TSC_GROUP_COMPLETED = 0x01 /*!< Acquisition on group is completed with success (no max count error) */ |
bogdanm | 85:024bf7f99721 | 82 | } TSC_GroupStatusTypeDef; |
bogdanm | 85:024bf7f99721 | 83 | |
bogdanm | 85:024bf7f99721 | 84 | /** |
bogdanm | 85:024bf7f99721 | 85 | * @brief TSC init structure definition |
bogdanm | 85:024bf7f99721 | 86 | */ |
bogdanm | 85:024bf7f99721 | 87 | typedef struct |
bogdanm | 85:024bf7f99721 | 88 | { |
bogdanm | 85:024bf7f99721 | 89 | uint32_t CTPulseHighLength; /*!< Charge-transfer high pulse length */ |
bogdanm | 85:024bf7f99721 | 90 | uint32_t CTPulseLowLength; /*!< Charge-transfer low pulse length */ |
bogdanm | 85:024bf7f99721 | 91 | uint32_t SpreadSpectrum; /*!< Spread spectrum activation */ |
bogdanm | 85:024bf7f99721 | 92 | uint32_t SpreadSpectrumDeviation; /*!< Spread spectrum deviation */ |
bogdanm | 85:024bf7f99721 | 93 | uint32_t SpreadSpectrumPrescaler; /*!< Spread spectrum prescaler */ |
bogdanm | 85:024bf7f99721 | 94 | uint32_t PulseGeneratorPrescaler; /*!< Pulse generator prescaler */ |
bogdanm | 85:024bf7f99721 | 95 | uint32_t MaxCountValue; /*!< Max count value */ |
bogdanm | 85:024bf7f99721 | 96 | uint32_t IODefaultMode; /*!< IO default mode */ |
bogdanm | 85:024bf7f99721 | 97 | uint32_t SynchroPinPolarity; /*!< Synchro pin polarity */ |
bogdanm | 85:024bf7f99721 | 98 | uint32_t AcquisitionMode; /*!< Acquisition mode */ |
bogdanm | 85:024bf7f99721 | 99 | uint32_t MaxCountInterrupt; /*!< Max count interrupt activation */ |
bogdanm | 85:024bf7f99721 | 100 | uint32_t ChannelIOs; /*!< Channel IOs mask */ |
bogdanm | 85:024bf7f99721 | 101 | uint32_t ShieldIOs; /*!< Shield IOs mask */ |
bogdanm | 85:024bf7f99721 | 102 | uint32_t SamplingIOs; /*!< Sampling IOs mask */ |
bogdanm | 85:024bf7f99721 | 103 | } TSC_InitTypeDef; |
bogdanm | 85:024bf7f99721 | 104 | |
bogdanm | 85:024bf7f99721 | 105 | /** |
bogdanm | 85:024bf7f99721 | 106 | * @brief TSC IOs configuration structure definition |
bogdanm | 85:024bf7f99721 | 107 | */ |
bogdanm | 85:024bf7f99721 | 108 | typedef struct |
bogdanm | 85:024bf7f99721 | 109 | { |
bogdanm | 85:024bf7f99721 | 110 | uint32_t ChannelIOs; /*!< Channel IOs mask */ |
bogdanm | 85:024bf7f99721 | 111 | uint32_t ShieldIOs; /*!< Shield IOs mask */ |
bogdanm | 85:024bf7f99721 | 112 | uint32_t SamplingIOs; /*!< Sampling IOs mask */ |
bogdanm | 85:024bf7f99721 | 113 | } TSC_IOConfigTypeDef; |
bogdanm | 85:024bf7f99721 | 114 | |
bogdanm | 85:024bf7f99721 | 115 | /** |
bogdanm | 85:024bf7f99721 | 116 | * @brief TSC handle Structure definition |
bogdanm | 85:024bf7f99721 | 117 | */ |
bogdanm | 85:024bf7f99721 | 118 | typedef struct |
bogdanm | 85:024bf7f99721 | 119 | { |
bogdanm | 85:024bf7f99721 | 120 | TSC_TypeDef *Instance; /*!< Register base address */ |
bogdanm | 85:024bf7f99721 | 121 | TSC_InitTypeDef Init; /*!< Initialization parameters */ |
bogdanm | 85:024bf7f99721 | 122 | __IO HAL_TSC_StateTypeDef State; /*!< Peripheral state */ |
bogdanm | 85:024bf7f99721 | 123 | HAL_LockTypeDef Lock; /*!< Lock feature */ |
bogdanm | 85:024bf7f99721 | 124 | } TSC_HandleTypeDef; |
bogdanm | 85:024bf7f99721 | 125 | |
bogdanm | 85:024bf7f99721 | 126 | /* Exported constants --------------------------------------------------------*/ |
bogdanm | 85:024bf7f99721 | 127 | |
bogdanm | 85:024bf7f99721 | 128 | /** @defgroup TSC_Exported_Constants |
bogdanm | 85:024bf7f99721 | 129 | * @{ |
bogdanm | 85:024bf7f99721 | 130 | */ |
bogdanm | 85:024bf7f99721 | 131 | |
bogdanm | 85:024bf7f99721 | 132 | #define TSC_CTPH_1CYCLE ((uint32_t)((uint32_t) 0 << 28)) |
bogdanm | 85:024bf7f99721 | 133 | #define TSC_CTPH_2CYCLES ((uint32_t)((uint32_t) 1 << 28)) |
bogdanm | 85:024bf7f99721 | 134 | #define TSC_CTPH_3CYCLES ((uint32_t)((uint32_t) 2 << 28)) |
bogdanm | 85:024bf7f99721 | 135 | #define TSC_CTPH_4CYCLES ((uint32_t)((uint32_t) 3 << 28)) |
bogdanm | 85:024bf7f99721 | 136 | #define TSC_CTPH_5CYCLES ((uint32_t)((uint32_t) 4 << 28)) |
bogdanm | 85:024bf7f99721 | 137 | #define TSC_CTPH_6CYCLES ((uint32_t)((uint32_t) 5 << 28)) |
bogdanm | 85:024bf7f99721 | 138 | #define TSC_CTPH_7CYCLES ((uint32_t)((uint32_t) 6 << 28)) |
bogdanm | 85:024bf7f99721 | 139 | #define TSC_CTPH_8CYCLES ((uint32_t)((uint32_t) 7 << 28)) |
bogdanm | 85:024bf7f99721 | 140 | #define TSC_CTPH_9CYCLES ((uint32_t)((uint32_t) 8 << 28)) |
bogdanm | 85:024bf7f99721 | 141 | #define TSC_CTPH_10CYCLES ((uint32_t)((uint32_t) 9 << 28)) |
bogdanm | 85:024bf7f99721 | 142 | #define TSC_CTPH_11CYCLES ((uint32_t)((uint32_t)10 << 28)) |
bogdanm | 85:024bf7f99721 | 143 | #define TSC_CTPH_12CYCLES ((uint32_t)((uint32_t)11 << 28)) |
bogdanm | 85:024bf7f99721 | 144 | #define TSC_CTPH_13CYCLES ((uint32_t)((uint32_t)12 << 28)) |
bogdanm | 85:024bf7f99721 | 145 | #define TSC_CTPH_14CYCLES ((uint32_t)((uint32_t)13 << 28)) |
bogdanm | 85:024bf7f99721 | 146 | #define TSC_CTPH_15CYCLES ((uint32_t)((uint32_t)14 << 28)) |
bogdanm | 85:024bf7f99721 | 147 | #define TSC_CTPH_16CYCLES ((uint32_t)((uint32_t)15 << 28)) |
bogdanm | 85:024bf7f99721 | 148 | #define IS_TSC_CTPH(VAL) (((VAL) == TSC_CTPH_1CYCLE) || \ |
bogdanm | 85:024bf7f99721 | 149 | ((VAL) == TSC_CTPH_2CYCLES) || \ |
bogdanm | 85:024bf7f99721 | 150 | ((VAL) == TSC_CTPH_3CYCLES) || \ |
bogdanm | 85:024bf7f99721 | 151 | ((VAL) == TSC_CTPH_4CYCLES) || \ |
bogdanm | 85:024bf7f99721 | 152 | ((VAL) == TSC_CTPH_5CYCLES) || \ |
bogdanm | 85:024bf7f99721 | 153 | ((VAL) == TSC_CTPH_6CYCLES) || \ |
bogdanm | 85:024bf7f99721 | 154 | ((VAL) == TSC_CTPH_7CYCLES) || \ |
bogdanm | 85:024bf7f99721 | 155 | ((VAL) == TSC_CTPH_8CYCLES) || \ |
bogdanm | 85:024bf7f99721 | 156 | ((VAL) == TSC_CTPH_9CYCLES) || \ |
bogdanm | 85:024bf7f99721 | 157 | ((VAL) == TSC_CTPH_10CYCLES) || \ |
bogdanm | 85:024bf7f99721 | 158 | ((VAL) == TSC_CTPH_11CYCLES) || \ |
bogdanm | 85:024bf7f99721 | 159 | ((VAL) == TSC_CTPH_12CYCLES) || \ |
bogdanm | 85:024bf7f99721 | 160 | ((VAL) == TSC_CTPH_13CYCLES) || \ |
bogdanm | 85:024bf7f99721 | 161 | ((VAL) == TSC_CTPH_14CYCLES) || \ |
bogdanm | 85:024bf7f99721 | 162 | ((VAL) == TSC_CTPH_15CYCLES) || \ |
bogdanm | 85:024bf7f99721 | 163 | ((VAL) == TSC_CTPH_16CYCLES)) |
bogdanm | 85:024bf7f99721 | 164 | |
bogdanm | 85:024bf7f99721 | 165 | #define TSC_CTPL_1CYCLE ((uint32_t)((uint32_t) 0 << 24)) |
bogdanm | 85:024bf7f99721 | 166 | #define TSC_CTPL_2CYCLES ((uint32_t)((uint32_t) 1 << 24)) |
bogdanm | 85:024bf7f99721 | 167 | #define TSC_CTPL_3CYCLES ((uint32_t)((uint32_t) 2 << 24)) |
bogdanm | 85:024bf7f99721 | 168 | #define TSC_CTPL_4CYCLES ((uint32_t)((uint32_t) 3 << 24)) |
bogdanm | 85:024bf7f99721 | 169 | #define TSC_CTPL_5CYCLES ((uint32_t)((uint32_t) 4 << 24)) |
bogdanm | 85:024bf7f99721 | 170 | #define TSC_CTPL_6CYCLES ((uint32_t)((uint32_t) 5 << 24)) |
bogdanm | 85:024bf7f99721 | 171 | #define TSC_CTPL_7CYCLES ((uint32_t)((uint32_t) 6 << 24)) |
bogdanm | 85:024bf7f99721 | 172 | #define TSC_CTPL_8CYCLES ((uint32_t)((uint32_t) 7 << 24)) |
bogdanm | 85:024bf7f99721 | 173 | #define TSC_CTPL_9CYCLES ((uint32_t)((uint32_t) 8 << 24)) |
bogdanm | 85:024bf7f99721 | 174 | #define TSC_CTPL_10CYCLES ((uint32_t)((uint32_t) 9 << 24)) |
bogdanm | 85:024bf7f99721 | 175 | #define TSC_CTPL_11CYCLES ((uint32_t)((uint32_t)10 << 24)) |
bogdanm | 85:024bf7f99721 | 176 | #define TSC_CTPL_12CYCLES ((uint32_t)((uint32_t)11 << 24)) |
bogdanm | 85:024bf7f99721 | 177 | #define TSC_CTPL_13CYCLES ((uint32_t)((uint32_t)12 << 24)) |
bogdanm | 85:024bf7f99721 | 178 | #define TSC_CTPL_14CYCLES ((uint32_t)((uint32_t)13 << 24)) |
bogdanm | 85:024bf7f99721 | 179 | #define TSC_CTPL_15CYCLES ((uint32_t)((uint32_t)14 << 24)) |
bogdanm | 85:024bf7f99721 | 180 | #define TSC_CTPL_16CYCLES ((uint32_t)((uint32_t)15 << 24)) |
bogdanm | 85:024bf7f99721 | 181 | #define IS_TSC_CTPL(VAL) (((VAL) == TSC_CTPL_1CYCLE) || \ |
bogdanm | 85:024bf7f99721 | 182 | ((VAL) == TSC_CTPL_2CYCLES) || \ |
bogdanm | 85:024bf7f99721 | 183 | ((VAL) == TSC_CTPL_3CYCLES) || \ |
bogdanm | 85:024bf7f99721 | 184 | ((VAL) == TSC_CTPL_4CYCLES) || \ |
bogdanm | 85:024bf7f99721 | 185 | ((VAL) == TSC_CTPL_5CYCLES) || \ |
bogdanm | 85:024bf7f99721 | 186 | ((VAL) == TSC_CTPL_6CYCLES) || \ |
bogdanm | 85:024bf7f99721 | 187 | ((VAL) == TSC_CTPL_7CYCLES) || \ |
bogdanm | 85:024bf7f99721 | 188 | ((VAL) == TSC_CTPL_8CYCLES) || \ |
bogdanm | 85:024bf7f99721 | 189 | ((VAL) == TSC_CTPL_9CYCLES) || \ |
bogdanm | 85:024bf7f99721 | 190 | ((VAL) == TSC_CTPL_10CYCLES) || \ |
bogdanm | 85:024bf7f99721 | 191 | ((VAL) == TSC_CTPL_11CYCLES) || \ |
bogdanm | 85:024bf7f99721 | 192 | ((VAL) == TSC_CTPL_12CYCLES) || \ |
bogdanm | 85:024bf7f99721 | 193 | ((VAL) == TSC_CTPL_13CYCLES) || \ |
bogdanm | 85:024bf7f99721 | 194 | ((VAL) == TSC_CTPL_14CYCLES) || \ |
bogdanm | 85:024bf7f99721 | 195 | ((VAL) == TSC_CTPL_15CYCLES) || \ |
bogdanm | 85:024bf7f99721 | 196 | ((VAL) == TSC_CTPL_16CYCLES)) |
bogdanm | 85:024bf7f99721 | 197 | |
bogdanm | 85:024bf7f99721 | 198 | #define IS_TSC_SS(VAL) (((VAL) == DISABLE) || ((VAL) == ENABLE)) |
bogdanm | 85:024bf7f99721 | 199 | |
bogdanm | 85:024bf7f99721 | 200 | #define IS_TSC_SSD(VAL) (((VAL) == 0) || (((VAL) > 0) && ((VAL) < 128))) |
bogdanm | 85:024bf7f99721 | 201 | |
bogdanm | 85:024bf7f99721 | 202 | #define TSC_SS_PRESC_DIV1 ((uint32_t)0) |
bogdanm | 85:024bf7f99721 | 203 | #define TSC_SS_PRESC_DIV2 (TSC_CR_SSPSC) |
bogdanm | 85:024bf7f99721 | 204 | #define IS_TSC_SS_PRESC(VAL) (((VAL) == TSC_SS_PRESC_DIV1) || ((VAL) == TSC_SS_PRESC_DIV2)) |
bogdanm | 85:024bf7f99721 | 205 | |
bogdanm | 85:024bf7f99721 | 206 | #define TSC_PG_PRESC_DIV1 ((uint32_t)(0 << 12)) |
bogdanm | 85:024bf7f99721 | 207 | #define TSC_PG_PRESC_DIV2 ((uint32_t)(1 << 12)) |
bogdanm | 85:024bf7f99721 | 208 | #define TSC_PG_PRESC_DIV4 ((uint32_t)(2 << 12)) |
bogdanm | 85:024bf7f99721 | 209 | #define TSC_PG_PRESC_DIV8 ((uint32_t)(3 << 12)) |
bogdanm | 85:024bf7f99721 | 210 | #define TSC_PG_PRESC_DIV16 ((uint32_t)(4 << 12)) |
bogdanm | 85:024bf7f99721 | 211 | #define TSC_PG_PRESC_DIV32 ((uint32_t)(5 << 12)) |
bogdanm | 85:024bf7f99721 | 212 | #define TSC_PG_PRESC_DIV64 ((uint32_t)(6 << 12)) |
bogdanm | 85:024bf7f99721 | 213 | #define TSC_PG_PRESC_DIV128 ((uint32_t)(7 << 12)) |
bogdanm | 85:024bf7f99721 | 214 | #define IS_TSC_PG_PRESC(VAL) (((VAL) == TSC_PG_PRESC_DIV1) || \ |
bogdanm | 85:024bf7f99721 | 215 | ((VAL) == TSC_PG_PRESC_DIV2) || \ |
bogdanm | 85:024bf7f99721 | 216 | ((VAL) == TSC_PG_PRESC_DIV4) || \ |
bogdanm | 85:024bf7f99721 | 217 | ((VAL) == TSC_PG_PRESC_DIV8) || \ |
bogdanm | 85:024bf7f99721 | 218 | ((VAL) == TSC_PG_PRESC_DIV16) || \ |
bogdanm | 85:024bf7f99721 | 219 | ((VAL) == TSC_PG_PRESC_DIV32) || \ |
bogdanm | 85:024bf7f99721 | 220 | ((VAL) == TSC_PG_PRESC_DIV64) || \ |
bogdanm | 85:024bf7f99721 | 221 | ((VAL) == TSC_PG_PRESC_DIV128)) |
bogdanm | 85:024bf7f99721 | 222 | |
bogdanm | 85:024bf7f99721 | 223 | #define TSC_MCV_255 ((uint32_t)(0 << 5)) |
bogdanm | 85:024bf7f99721 | 224 | #define TSC_MCV_511 ((uint32_t)(1 << 5)) |
bogdanm | 85:024bf7f99721 | 225 | #define TSC_MCV_1023 ((uint32_t)(2 << 5)) |
bogdanm | 85:024bf7f99721 | 226 | #define TSC_MCV_2047 ((uint32_t)(3 << 5)) |
bogdanm | 85:024bf7f99721 | 227 | #define TSC_MCV_4095 ((uint32_t)(4 << 5)) |
bogdanm | 85:024bf7f99721 | 228 | #define TSC_MCV_8191 ((uint32_t)(5 << 5)) |
bogdanm | 85:024bf7f99721 | 229 | #define TSC_MCV_16383 ((uint32_t)(6 << 5)) |
bogdanm | 85:024bf7f99721 | 230 | #define IS_TSC_MCV(VAL) (((VAL) == TSC_MCV_255) || \ |
bogdanm | 85:024bf7f99721 | 231 | ((VAL) == TSC_MCV_511) || \ |
bogdanm | 85:024bf7f99721 | 232 | ((VAL) == TSC_MCV_1023) || \ |
bogdanm | 85:024bf7f99721 | 233 | ((VAL) == TSC_MCV_2047) || \ |
bogdanm | 85:024bf7f99721 | 234 | ((VAL) == TSC_MCV_4095) || \ |
bogdanm | 85:024bf7f99721 | 235 | ((VAL) == TSC_MCV_8191) || \ |
bogdanm | 85:024bf7f99721 | 236 | ((VAL) == TSC_MCV_16383)) |
bogdanm | 85:024bf7f99721 | 237 | |
bogdanm | 85:024bf7f99721 | 238 | #define TSC_IODEF_OUT_PP_LOW ((uint32_t)0) |
bogdanm | 85:024bf7f99721 | 239 | #define TSC_IODEF_IN_FLOAT (TSC_CR_IODEF) |
bogdanm | 85:024bf7f99721 | 240 | #define IS_TSC_IODEF(VAL) (((VAL) == TSC_IODEF_OUT_PP_LOW) || ((VAL) == TSC_IODEF_IN_FLOAT)) |
bogdanm | 85:024bf7f99721 | 241 | |
bogdanm | 85:024bf7f99721 | 242 | #define TSC_SYNC_POL_FALL ((uint32_t)0) |
bogdanm | 85:024bf7f99721 | 243 | #define TSC_SYNC_POL_RISE_HIGH (TSC_CR_SYNCPOL) |
bogdanm | 85:024bf7f99721 | 244 | #define IS_TSC_SYNC_POL(VAL) (((VAL) == TSC_SYNC_POL_FALL) || ((VAL) == TSC_SYNC_POL_RISE_HIGH)) |
bogdanm | 85:024bf7f99721 | 245 | |
bogdanm | 85:024bf7f99721 | 246 | #define TSC_ACQ_MODE_NORMAL ((uint32_t)0) |
bogdanm | 85:024bf7f99721 | 247 | #define TSC_ACQ_MODE_SYNCHRO (TSC_CR_SYNCPOL) |
bogdanm | 85:024bf7f99721 | 248 | #define IS_TSC_ACQ_MODE(VAL) (((VAL) == TSC_ACQ_MODE_NORMAL) || ((VAL) == TSC_ACQ_MODE_SYNCHRO)) |
bogdanm | 85:024bf7f99721 | 249 | |
bogdanm | 85:024bf7f99721 | 250 | #define TSC_IOMODE_UNUSED ((uint32_t)0) |
bogdanm | 85:024bf7f99721 | 251 | #define TSC_IOMODE_CHANNEL ((uint32_t)1) |
bogdanm | 85:024bf7f99721 | 252 | #define TSC_IOMODE_SHIELD ((uint32_t)2) |
bogdanm | 85:024bf7f99721 | 253 | #define TSC_IOMODE_SAMPLING ((uint32_t)3) |
bogdanm | 85:024bf7f99721 | 254 | #define IS_TSC_IOMODE(VAL) (((VAL) == TSC_IOMODE_UNUSED) || \ |
bogdanm | 85:024bf7f99721 | 255 | ((VAL) == TSC_IOMODE_CHANNEL) || \ |
bogdanm | 85:024bf7f99721 | 256 | ((VAL) == TSC_IOMODE_SHIELD) || \ |
bogdanm | 85:024bf7f99721 | 257 | ((VAL) == TSC_IOMODE_SAMPLING)) |
bogdanm | 85:024bf7f99721 | 258 | |
bogdanm | 85:024bf7f99721 | 259 | /** @defgroup TSC_interrupts_definition |
bogdanm | 85:024bf7f99721 | 260 | * @{ |
bogdanm | 85:024bf7f99721 | 261 | */ |
bogdanm | 85:024bf7f99721 | 262 | #define TSC_IT_EOA ((uint32_t)TSC_IER_EOAIE) |
bogdanm | 85:024bf7f99721 | 263 | #define TSC_IT_MCE ((uint32_t)TSC_IER_MCEIE) |
bogdanm | 85:024bf7f99721 | 264 | #define IS_TSC_MCE_IT(VAL) (((VAL) == DISABLE) || ((VAL) == ENABLE)) |
bogdanm | 85:024bf7f99721 | 265 | /** |
bogdanm | 85:024bf7f99721 | 266 | * @} |
bogdanm | 85:024bf7f99721 | 267 | */ |
bogdanm | 85:024bf7f99721 | 268 | |
bogdanm | 85:024bf7f99721 | 269 | /** @defgroup TSC_flags_definition |
bogdanm | 85:024bf7f99721 | 270 | * @{ |
bogdanm | 85:024bf7f99721 | 271 | */ |
bogdanm | 85:024bf7f99721 | 272 | #define TSC_FLAG_EOA ((uint32_t)TSC_ISR_EOAF) |
bogdanm | 85:024bf7f99721 | 273 | #define TSC_FLAG_MCE ((uint32_t)TSC_ISR_MCEF) |
bogdanm | 85:024bf7f99721 | 274 | /** |
bogdanm | 85:024bf7f99721 | 275 | * @} |
bogdanm | 85:024bf7f99721 | 276 | */ |
bogdanm | 85:024bf7f99721 | 277 | |
bogdanm | 85:024bf7f99721 | 278 | #define TSC_NB_OF_GROUPS (8) |
bogdanm | 85:024bf7f99721 | 279 | |
bogdanm | 85:024bf7f99721 | 280 | #define TSC_GROUP1 ((uint32_t)0x00000001) |
bogdanm | 85:024bf7f99721 | 281 | #define TSC_GROUP2 ((uint32_t)0x00000002) |
bogdanm | 85:024bf7f99721 | 282 | #define TSC_GROUP3 ((uint32_t)0x00000004) |
bogdanm | 85:024bf7f99721 | 283 | #define TSC_GROUP4 ((uint32_t)0x00000008) |
bogdanm | 85:024bf7f99721 | 284 | #define TSC_GROUP5 ((uint32_t)0x00000010) |
bogdanm | 85:024bf7f99721 | 285 | #define TSC_GROUP6 ((uint32_t)0x00000020) |
bogdanm | 85:024bf7f99721 | 286 | #define TSC_GROUP7 ((uint32_t)0x00000040) |
bogdanm | 85:024bf7f99721 | 287 | #define TSC_GROUP8 ((uint32_t)0x00000080) |
bogdanm | 85:024bf7f99721 | 288 | #define TSC_ALL_GROUPS ((uint32_t)0x000000FF) |
bogdanm | 85:024bf7f99721 | 289 | |
bogdanm | 85:024bf7f99721 | 290 | #define TSC_GROUP1_IDX ((uint32_t)0) |
bogdanm | 85:024bf7f99721 | 291 | #define TSC_GROUP2_IDX ((uint32_t)1) |
bogdanm | 85:024bf7f99721 | 292 | #define TSC_GROUP3_IDX ((uint32_t)2) |
bogdanm | 85:024bf7f99721 | 293 | #define TSC_GROUP4_IDX ((uint32_t)3) |
bogdanm | 85:024bf7f99721 | 294 | #define TSC_GROUP5_IDX ((uint32_t)4) |
bogdanm | 85:024bf7f99721 | 295 | #define TSC_GROUP6_IDX ((uint32_t)5) |
bogdanm | 85:024bf7f99721 | 296 | #define TSC_GROUP7_IDX ((uint32_t)6) |
bogdanm | 85:024bf7f99721 | 297 | #define TSC_GROUP8_IDX ((uint32_t)7) |
bogdanm | 85:024bf7f99721 | 298 | #define IS_GROUP_INDEX(VAL) (((VAL) == 0) || (((VAL) > 0) && ((VAL) < TSC_NB_OF_GROUPS))) |
bogdanm | 85:024bf7f99721 | 299 | |
bogdanm | 85:024bf7f99721 | 300 | #define TSC_GROUP1_IO1 ((uint32_t)0x00000001) |
bogdanm | 85:024bf7f99721 | 301 | #define TSC_GROUP1_IO2 ((uint32_t)0x00000002) |
bogdanm | 85:024bf7f99721 | 302 | #define TSC_GROUP1_IO3 ((uint32_t)0x00000004) |
bogdanm | 85:024bf7f99721 | 303 | #define TSC_GROUP1_IO4 ((uint32_t)0x00000008) |
bogdanm | 85:024bf7f99721 | 304 | #define TSC_GROUP1_ALL_IOS ((uint32_t)0x0000000F) |
bogdanm | 85:024bf7f99721 | 305 | |
bogdanm | 85:024bf7f99721 | 306 | #define TSC_GROUP2_IO1 ((uint32_t)0x00000010) |
bogdanm | 85:024bf7f99721 | 307 | #define TSC_GROUP2_IO2 ((uint32_t)0x00000020) |
bogdanm | 85:024bf7f99721 | 308 | #define TSC_GROUP2_IO3 ((uint32_t)0x00000040) |
bogdanm | 85:024bf7f99721 | 309 | #define TSC_GROUP2_IO4 ((uint32_t)0x00000080) |
bogdanm | 85:024bf7f99721 | 310 | #define TSC_GROUP2_ALL_IOS ((uint32_t)0x000000F0) |
bogdanm | 85:024bf7f99721 | 311 | |
bogdanm | 85:024bf7f99721 | 312 | #define TSC_GROUP3_IO1 ((uint32_t)0x00000100) |
bogdanm | 85:024bf7f99721 | 313 | #define TSC_GROUP3_IO2 ((uint32_t)0x00000200) |
bogdanm | 85:024bf7f99721 | 314 | #define TSC_GROUP3_IO3 ((uint32_t)0x00000400) |
bogdanm | 85:024bf7f99721 | 315 | #define TSC_GROUP3_IO4 ((uint32_t)0x00000800) |
bogdanm | 85:024bf7f99721 | 316 | #define TSC_GROUP3_ALL_IOS ((uint32_t)0x00000F00) |
bogdanm | 85:024bf7f99721 | 317 | |
bogdanm | 85:024bf7f99721 | 318 | #define TSC_GROUP4_IO1 ((uint32_t)0x00001000) |
bogdanm | 85:024bf7f99721 | 319 | #define TSC_GROUP4_IO2 ((uint32_t)0x00002000) |
bogdanm | 85:024bf7f99721 | 320 | #define TSC_GROUP4_IO3 ((uint32_t)0x00004000) |
bogdanm | 85:024bf7f99721 | 321 | #define TSC_GROUP4_IO4 ((uint32_t)0x00008000) |
bogdanm | 85:024bf7f99721 | 322 | #define TSC_GROUP4_ALL_IOS ((uint32_t)0x0000F000) |
bogdanm | 85:024bf7f99721 | 323 | |
bogdanm | 85:024bf7f99721 | 324 | #define TSC_GROUP5_IO1 ((uint32_t)0x00010000) |
bogdanm | 85:024bf7f99721 | 325 | #define TSC_GROUP5_IO2 ((uint32_t)0x00020000) |
bogdanm | 85:024bf7f99721 | 326 | #define TSC_GROUP5_IO3 ((uint32_t)0x00040000) |
bogdanm | 85:024bf7f99721 | 327 | #define TSC_GROUP5_IO4 ((uint32_t)0x00080000) |
bogdanm | 85:024bf7f99721 | 328 | #define TSC_GROUP5_ALL_IOS ((uint32_t)0x000F0000) |
bogdanm | 85:024bf7f99721 | 329 | |
bogdanm | 85:024bf7f99721 | 330 | #define TSC_GROUP6_IO1 ((uint32_t)0x00100000) |
bogdanm | 85:024bf7f99721 | 331 | #define TSC_GROUP6_IO2 ((uint32_t)0x00200000) |
bogdanm | 85:024bf7f99721 | 332 | #define TSC_GROUP6_IO3 ((uint32_t)0x00400000) |
bogdanm | 85:024bf7f99721 | 333 | #define TSC_GROUP6_IO4 ((uint32_t)0x00800000) |
bogdanm | 85:024bf7f99721 | 334 | #define TSC_GROUP6_ALL_IOS ((uint32_t)0x00F00000) |
bogdanm | 85:024bf7f99721 | 335 | |
bogdanm | 85:024bf7f99721 | 336 | #define TSC_GROUP7_IO1 ((uint32_t)0x01000000) |
bogdanm | 85:024bf7f99721 | 337 | #define TSC_GROUP7_IO2 ((uint32_t)0x02000000) |
bogdanm | 85:024bf7f99721 | 338 | #define TSC_GROUP7_IO3 ((uint32_t)0x04000000) |
bogdanm | 85:024bf7f99721 | 339 | #define TSC_GROUP7_IO4 ((uint32_t)0x08000000) |
bogdanm | 85:024bf7f99721 | 340 | #define TSC_GROUP7_ALL_IOS ((uint32_t)0x0F000000) |
bogdanm | 85:024bf7f99721 | 341 | |
bogdanm | 85:024bf7f99721 | 342 | #define TSC_GROUP8_IO1 ((uint32_t)0x10000000) |
bogdanm | 85:024bf7f99721 | 343 | #define TSC_GROUP8_IO2 ((uint32_t)0x20000000) |
bogdanm | 85:024bf7f99721 | 344 | #define TSC_GROUP8_IO3 ((uint32_t)0x40000000) |
bogdanm | 85:024bf7f99721 | 345 | #define TSC_GROUP8_IO4 ((uint32_t)0x80000000) |
bogdanm | 85:024bf7f99721 | 346 | #define TSC_GROUP8_ALL_IOS ((uint32_t)0xF0000000) |
bogdanm | 85:024bf7f99721 | 347 | |
bogdanm | 85:024bf7f99721 | 348 | #define TSC_ALL_GROUPS_ALL_IOS ((uint32_t)0xFFFFFFFF) |
bogdanm | 85:024bf7f99721 | 349 | |
bogdanm | 85:024bf7f99721 | 350 | /** |
bogdanm | 85:024bf7f99721 | 351 | * @} |
bogdanm | 85:024bf7f99721 | 352 | */ |
bogdanm | 85:024bf7f99721 | 353 | |
bogdanm | 85:024bf7f99721 | 354 | /* Exported macros -----------------------------------------------------------*/ |
bogdanm | 85:024bf7f99721 | 355 | |
bogdanm | 85:024bf7f99721 | 356 | /** @brief Reset TSC handle state |
bogdanm | 85:024bf7f99721 | 357 | * @param __HANDLE__: TSC handle. |
bogdanm | 85:024bf7f99721 | 358 | * @retval None |
bogdanm | 85:024bf7f99721 | 359 | */ |
bogdanm | 85:024bf7f99721 | 360 | #define __HAL_TSC_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_TSC_STATE_RESET) |
bogdanm | 85:024bf7f99721 | 361 | |
bogdanm | 85:024bf7f99721 | 362 | /** |
bogdanm | 85:024bf7f99721 | 363 | * @brief Enable the TSC peripheral. |
bogdanm | 85:024bf7f99721 | 364 | * @param __HANDLE__: TSC handle |
bogdanm | 85:024bf7f99721 | 365 | * @retval None |
bogdanm | 85:024bf7f99721 | 366 | */ |
bogdanm | 85:024bf7f99721 | 367 | #define __HAL_TSC_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR |= TSC_CR_TSCE) |
bogdanm | 85:024bf7f99721 | 368 | |
bogdanm | 85:024bf7f99721 | 369 | /** |
bogdanm | 85:024bf7f99721 | 370 | * @brief Disable the TSC peripheral. |
bogdanm | 85:024bf7f99721 | 371 | * @param __HANDLE__: TSC handle |
bogdanm | 85:024bf7f99721 | 372 | * @retval None |
bogdanm | 85:024bf7f99721 | 373 | */ |
bogdanm | 85:024bf7f99721 | 374 | #define __HAL_TSC_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR &= (uint32_t)(~TSC_CR_TSCE)) |
bogdanm | 85:024bf7f99721 | 375 | |
bogdanm | 85:024bf7f99721 | 376 | /** |
bogdanm | 85:024bf7f99721 | 377 | * @brief Start acquisition |
bogdanm | 85:024bf7f99721 | 378 | * @param __HANDLE__: TSC handle |
bogdanm | 85:024bf7f99721 | 379 | * @retval None |
bogdanm | 85:024bf7f99721 | 380 | */ |
bogdanm | 85:024bf7f99721 | 381 | #define __HAL_TSC_START_ACQ(__HANDLE__) ((__HANDLE__)->Instance->CR |= TSC_CR_START) |
bogdanm | 85:024bf7f99721 | 382 | |
bogdanm | 85:024bf7f99721 | 383 | /** |
bogdanm | 85:024bf7f99721 | 384 | * @brief Stop acquisition |
bogdanm | 85:024bf7f99721 | 385 | * @param __HANDLE__: TSC handle |
bogdanm | 85:024bf7f99721 | 386 | * @retval None |
bogdanm | 85:024bf7f99721 | 387 | */ |
bogdanm | 85:024bf7f99721 | 388 | #define __HAL_TSC_STOP_ACQ(__HANDLE__) ((__HANDLE__)->Instance->CR &= (uint32_t)(~TSC_CR_START)) |
bogdanm | 85:024bf7f99721 | 389 | |
bogdanm | 85:024bf7f99721 | 390 | /** |
bogdanm | 85:024bf7f99721 | 391 | * @brief Set IO default mode to output push-pull low |
bogdanm | 85:024bf7f99721 | 392 | * @param __HANDLE__: TSC handle |
bogdanm | 85:024bf7f99721 | 393 | * @retval None |
bogdanm | 85:024bf7f99721 | 394 | */ |
bogdanm | 85:024bf7f99721 | 395 | #define __HAL_TSC_SET_IODEF_OUTPPLOW(__HANDLE__) ((__HANDLE__)->Instance->CR &= (uint32_t)(~TSC_CR_IODEF)) |
bogdanm | 85:024bf7f99721 | 396 | |
bogdanm | 85:024bf7f99721 | 397 | /** |
bogdanm | 85:024bf7f99721 | 398 | * @brief Set IO default mode to input floating |
bogdanm | 85:024bf7f99721 | 399 | * @param __HANDLE__: TSC handle |
bogdanm | 85:024bf7f99721 | 400 | * @retval None |
bogdanm | 85:024bf7f99721 | 401 | */ |
bogdanm | 85:024bf7f99721 | 402 | #define __HAL_TSC_SET_IODEF_INFLOAT(__HANDLE__) ((__HANDLE__)->Instance->CR |= TSC_CR_IODEF) |
bogdanm | 85:024bf7f99721 | 403 | |
bogdanm | 85:024bf7f99721 | 404 | /** |
bogdanm | 85:024bf7f99721 | 405 | * @brief Set synchronization polarity to falling edge |
bogdanm | 85:024bf7f99721 | 406 | * @param __HANDLE__: TSC handle |
bogdanm | 85:024bf7f99721 | 407 | * @retval None |
bogdanm | 85:024bf7f99721 | 408 | */ |
bogdanm | 85:024bf7f99721 | 409 | #define __HAL_TSC_SET_SYNC_POL_FALL(__HANDLE__) ((__HANDLE__)->Instance->CR &= (uint32_t)(~TSC_CR_SYNCPOL)) |
bogdanm | 85:024bf7f99721 | 410 | |
bogdanm | 85:024bf7f99721 | 411 | /** |
bogdanm | 85:024bf7f99721 | 412 | * @brief Set synchronization polarity to rising edge and high level |
bogdanm | 85:024bf7f99721 | 413 | * @param __HANDLE__: TSC handle |
bogdanm | 85:024bf7f99721 | 414 | * @retval None |
bogdanm | 85:024bf7f99721 | 415 | */ |
bogdanm | 85:024bf7f99721 | 416 | #define __HAL_TSC_SET_SYNC_POL_RISE_HIGH(__HANDLE__) ((__HANDLE__)->Instance->CR |= TSC_CR_SYNCPOL) |
bogdanm | 85:024bf7f99721 | 417 | |
bogdanm | 85:024bf7f99721 | 418 | /** |
bogdanm | 85:024bf7f99721 | 419 | * @brief Enable TSC interrupt. |
bogdanm | 85:024bf7f99721 | 420 | * @param __HANDLE__: TSC handle |
bogdanm | 85:024bf7f99721 | 421 | * @param __INTERRUPT__: TSC interrupt |
bogdanm | 85:024bf7f99721 | 422 | * @retval None |
bogdanm | 85:024bf7f99721 | 423 | */ |
bogdanm | 85:024bf7f99721 | 424 | #define __HAL_TSC_ENABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->IER |= (__INTERRUPT__)) |
bogdanm | 85:024bf7f99721 | 425 | |
bogdanm | 85:024bf7f99721 | 426 | /** |
bogdanm | 85:024bf7f99721 | 427 | * @brief Disable TSC interrupt. |
bogdanm | 85:024bf7f99721 | 428 | * @param __HANDLE__: TSC handle |
bogdanm | 85:024bf7f99721 | 429 | * @param __INTERRUPT__: TSC interrupt |
bogdanm | 85:024bf7f99721 | 430 | * @retval None |
bogdanm | 85:024bf7f99721 | 431 | */ |
bogdanm | 85:024bf7f99721 | 432 | #define __HAL_TSC_DISABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->IER &= (uint32_t)(~(__INTERRUPT__))) |
bogdanm | 85:024bf7f99721 | 433 | |
bogdanm | 85:024bf7f99721 | 434 | /** @brief Check if the specified TSC interrupt source is enabled or disabled. |
bogdanm | 85:024bf7f99721 | 435 | * @param __HANDLE__: TSC Handle |
bogdanm | 85:024bf7f99721 | 436 | * @param __INTERRUPT__: TSC interrupt |
bogdanm | 85:024bf7f99721 | 437 | * @retval SET or RESET |
bogdanm | 85:024bf7f99721 | 438 | */ |
bogdanm | 85:024bf7f99721 | 439 | #define __HAL_TSC_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) ((((__HANDLE__)->Instance->IER & (__INTERRUPT__)) == (__INTERRUPT__)) ? SET : RESET) |
bogdanm | 85:024bf7f99721 | 440 | |
bogdanm | 85:024bf7f99721 | 441 | /** |
bogdanm | 85:024bf7f99721 | 442 | * @brief Get the selected TSC's flag status. |
bogdanm | 85:024bf7f99721 | 443 | * @param __HANDLE__: TSC handle |
bogdanm | 85:024bf7f99721 | 444 | * @param __FLAG__: TSC flag |
bogdanm | 85:024bf7f99721 | 445 | * @retval SET or RESET |
bogdanm | 85:024bf7f99721 | 446 | */ |
bogdanm | 85:024bf7f99721 | 447 | #define __HAL_TSC_GET_FLAG(__HANDLE__, __FLAG__) ((((__HANDLE__)->Instance->ISR & (__FLAG__)) == (__FLAG__)) ? SET : RESET) |
bogdanm | 85:024bf7f99721 | 448 | |
bogdanm | 85:024bf7f99721 | 449 | /** |
bogdanm | 85:024bf7f99721 | 450 | * @brief Clear the TSC's pending flag. |
bogdanm | 85:024bf7f99721 | 451 | * @param __HANDLE__: TSC handle |
bogdanm | 85:024bf7f99721 | 452 | * @param __FLAG__: TSC flag |
bogdanm | 85:024bf7f99721 | 453 | * @retval None |
bogdanm | 85:024bf7f99721 | 454 | */ |
bogdanm | 85:024bf7f99721 | 455 | #define __HAL_TSC_CLEAR_FLAG(__HANDLE__, __FLAG__) ((__HANDLE__)->Instance->ICR |= (__FLAG__)) |
bogdanm | 85:024bf7f99721 | 456 | |
bogdanm | 85:024bf7f99721 | 457 | /** |
bogdanm | 85:024bf7f99721 | 458 | * @brief Enable schmitt trigger hysteresis on a group of IOs |
bogdanm | 85:024bf7f99721 | 459 | * @param __HANDLE__: TSC handle |
bogdanm | 85:024bf7f99721 | 460 | * @param __GX_IOY_MASK__: IOs mask |
bogdanm | 85:024bf7f99721 | 461 | * @retval None |
bogdanm | 85:024bf7f99721 | 462 | */ |
bogdanm | 85:024bf7f99721 | 463 | #define __HAL_TSC_ENABLE_HYSTERESIS(__HANDLE__, __GX_IOY_MASK__) ((__HANDLE__)->Instance->IOHCR |= (__GX_IOY_MASK__)) |
bogdanm | 85:024bf7f99721 | 464 | |
bogdanm | 85:024bf7f99721 | 465 | /** |
bogdanm | 85:024bf7f99721 | 466 | * @brief Disable schmitt trigger hysteresis on a group of IOs |
bogdanm | 85:024bf7f99721 | 467 | * @param __HANDLE__: TSC handle |
bogdanm | 85:024bf7f99721 | 468 | * @param __GX_IOY_MASK__: IOs mask |
bogdanm | 85:024bf7f99721 | 469 | * @retval None |
bogdanm | 85:024bf7f99721 | 470 | */ |
bogdanm | 85:024bf7f99721 | 471 | #define __HAL_TSC_DISABLE_HYSTERESIS(__HANDLE__, __GX_IOY_MASK__) ((__HANDLE__)->Instance->IOHCR &= (uint32_t)(~(__GX_IOY_MASK__))) |
bogdanm | 85:024bf7f99721 | 472 | |
bogdanm | 85:024bf7f99721 | 473 | /** |
bogdanm | 85:024bf7f99721 | 474 | * @brief Open analog switch on a group of IOs |
bogdanm | 85:024bf7f99721 | 475 | * @param __HANDLE__: TSC handle |
bogdanm | 85:024bf7f99721 | 476 | * @param __GX_IOY_MASK__: IOs mask |
bogdanm | 85:024bf7f99721 | 477 | * @retval None |
bogdanm | 85:024bf7f99721 | 478 | */ |
bogdanm | 85:024bf7f99721 | 479 | #define __HAL_TSC_OPEN_ANALOG_SWITCH(__HANDLE__, __GX_IOY_MASK__) ((__HANDLE__)->Instance->IOASCR &= (uint32_t)(~(__GX_IOY_MASK__))) |
bogdanm | 85:024bf7f99721 | 480 | |
bogdanm | 85:024bf7f99721 | 481 | /** |
bogdanm | 85:024bf7f99721 | 482 | * @brief Close analog switch on a group of IOs |
bogdanm | 85:024bf7f99721 | 483 | * @param __HANDLE__: TSC handle |
bogdanm | 85:024bf7f99721 | 484 | * @param __GX_IOY_MASK__: IOs mask |
bogdanm | 85:024bf7f99721 | 485 | * @retval None |
bogdanm | 85:024bf7f99721 | 486 | */ |
bogdanm | 85:024bf7f99721 | 487 | #define __HAL_TSC_CLOSE_ANALOG_SWITCH(__HANDLE__, __GX_IOY_MASK__) ((__HANDLE__)->Instance->IOASCR |= (__GX_IOY_MASK__)) |
bogdanm | 85:024bf7f99721 | 488 | |
bogdanm | 85:024bf7f99721 | 489 | /** |
bogdanm | 85:024bf7f99721 | 490 | * @brief Enable a group of IOs in channel mode |
bogdanm | 85:024bf7f99721 | 491 | * @param __HANDLE__: TSC handle |
bogdanm | 85:024bf7f99721 | 492 | * @param __GX_IOY_MASK__: IOs mask |
bogdanm | 85:024bf7f99721 | 493 | * @retval None |
bogdanm | 85:024bf7f99721 | 494 | */ |
bogdanm | 85:024bf7f99721 | 495 | #define __HAL_TSC_ENABLE_CHANNEL(__HANDLE__, __GX_IOY_MASK__) ((__HANDLE__)->Instance->IOCCR |= (__GX_IOY_MASK__)) |
bogdanm | 85:024bf7f99721 | 496 | |
bogdanm | 85:024bf7f99721 | 497 | /** |
bogdanm | 85:024bf7f99721 | 498 | * @brief Disable a group of channel IOs |
bogdanm | 85:024bf7f99721 | 499 | * @param __HANDLE__: TSC handle |
bogdanm | 85:024bf7f99721 | 500 | * @param __GX_IOY_MASK__: IOs mask |
bogdanm | 85:024bf7f99721 | 501 | * @retval None |
bogdanm | 85:024bf7f99721 | 502 | */ |
bogdanm | 85:024bf7f99721 | 503 | #define __HAL_TSC_DISABLE_CHANNEL(__HANDLE__, __GX_IOY_MASK__) ((__HANDLE__)->Instance->IOCCR &= (uint32_t)(~(__GX_IOY_MASK__))) |
bogdanm | 85:024bf7f99721 | 504 | |
bogdanm | 85:024bf7f99721 | 505 | /** |
bogdanm | 85:024bf7f99721 | 506 | * @brief Enable a group of IOs in sampling mode |
bogdanm | 85:024bf7f99721 | 507 | * @param __HANDLE__: TSC handle |
bogdanm | 85:024bf7f99721 | 508 | * @param __GX_IOY_MASK__: IOs mask |
bogdanm | 85:024bf7f99721 | 509 | * @retval None |
bogdanm | 85:024bf7f99721 | 510 | */ |
bogdanm | 85:024bf7f99721 | 511 | #define __HAL_TSC_ENABLE_SAMPLING(__HANDLE__, __GX_IOY_MASK__) ((__HANDLE__)->Instance->IOSCR |= (__GX_IOY_MASK__)) |
bogdanm | 85:024bf7f99721 | 512 | |
bogdanm | 85:024bf7f99721 | 513 | /** |
bogdanm | 85:024bf7f99721 | 514 | * @brief Disable a group of sampling IOs |
bogdanm | 85:024bf7f99721 | 515 | * @param __HANDLE__: TSC handle |
bogdanm | 85:024bf7f99721 | 516 | * @param __GX_IOY_MASK__: IOs mask |
bogdanm | 85:024bf7f99721 | 517 | * @retval None |
bogdanm | 85:024bf7f99721 | 518 | */ |
bogdanm | 85:024bf7f99721 | 519 | #define __HAL_TSC_DISABLE_SAMPLING(__HANDLE__, __GX_IOY_MASK__) ((__HANDLE__)->Instance->IOSCR &= (uint32_t)(~(__GX_IOY_MASK__))) |
bogdanm | 85:024bf7f99721 | 520 | |
bogdanm | 85:024bf7f99721 | 521 | /** |
bogdanm | 85:024bf7f99721 | 522 | * @brief Enable acquisition groups |
bogdanm | 85:024bf7f99721 | 523 | * @param __HANDLE__: TSC handle |
bogdanm | 85:024bf7f99721 | 524 | * @param __GX_MASK__: Groups mask |
bogdanm | 85:024bf7f99721 | 525 | * @retval None |
bogdanm | 85:024bf7f99721 | 526 | */ |
bogdanm | 85:024bf7f99721 | 527 | #define __HAL_TSC_ENABLE_GROUP(__HANDLE__, __GX_MASK__) ((__HANDLE__)->Instance->IOGCSR |= (__GX_MASK__)) |
bogdanm | 85:024bf7f99721 | 528 | |
bogdanm | 85:024bf7f99721 | 529 | /** |
bogdanm | 85:024bf7f99721 | 530 | * @brief Disable acquisition groups |
bogdanm | 85:024bf7f99721 | 531 | * @param __HANDLE__: TSC handle |
bogdanm | 85:024bf7f99721 | 532 | * @param __GX_MASK__: Groups mask |
bogdanm | 85:024bf7f99721 | 533 | * @retval None |
bogdanm | 85:024bf7f99721 | 534 | */ |
bogdanm | 85:024bf7f99721 | 535 | #define __HAL_TSC_DISABLE_GROUP(__HANDLE__, __GX_MASK__) ((__HANDLE__)->Instance->IOGCSR &= (uint32_t)(~(__GX_MASK__))) |
bogdanm | 85:024bf7f99721 | 536 | |
bogdanm | 85:024bf7f99721 | 537 | /** @brief Gets acquisition group status |
bogdanm | 85:024bf7f99721 | 538 | * @param __HANDLE__: TSC Handle |
bogdanm | 85:024bf7f99721 | 539 | * @param __GX_INDEX__: Group index |
bogdanm | 85:024bf7f99721 | 540 | * @retval SET or RESET |
bogdanm | 85:024bf7f99721 | 541 | */ |
bogdanm | 85:024bf7f99721 | 542 | #define __HAL_TSC_GET_GROUP_STATUS(__HANDLE__, __GX_INDEX__) \ |
bogdanm | 85:024bf7f99721 | 543 | ((((__HANDLE__)->Instance->IOGCSR & (uint32_t)((uint32_t)1 << ((__GX_INDEX__) + (uint32_t)16))) == (uint32_t)((uint32_t)1 << ((__GX_INDEX__) + (uint32_t)16))) ? TSC_GROUP_COMPLETED : TSC_GROUP_ONGOING) |
bogdanm | 85:024bf7f99721 | 544 | |
bogdanm | 85:024bf7f99721 | 545 | /* Exported functions --------------------------------------------------------*/ |
bogdanm | 85:024bf7f99721 | 546 | |
bogdanm | 85:024bf7f99721 | 547 | /* Initialization and de-initialization functions *****************************/ |
bogdanm | 85:024bf7f99721 | 548 | HAL_StatusTypeDef HAL_TSC_Init(TSC_HandleTypeDef* htsc); |
bogdanm | 85:024bf7f99721 | 549 | HAL_StatusTypeDef HAL_TSC_DeInit(TSC_HandleTypeDef *htsc); |
bogdanm | 85:024bf7f99721 | 550 | void HAL_TSC_MspInit(TSC_HandleTypeDef* htsc); |
bogdanm | 85:024bf7f99721 | 551 | void HAL_TSC_MspDeInit(TSC_HandleTypeDef* htsc); |
bogdanm | 85:024bf7f99721 | 552 | |
bogdanm | 85:024bf7f99721 | 553 | /* IO operation functions *****************************************************/ |
bogdanm | 85:024bf7f99721 | 554 | HAL_StatusTypeDef HAL_TSC_Start(TSC_HandleTypeDef* htsc); |
bogdanm | 85:024bf7f99721 | 555 | HAL_StatusTypeDef HAL_TSC_Start_IT(TSC_HandleTypeDef* htsc); |
bogdanm | 85:024bf7f99721 | 556 | HAL_StatusTypeDef HAL_TSC_Stop(TSC_HandleTypeDef* htsc); |
bogdanm | 85:024bf7f99721 | 557 | HAL_StatusTypeDef HAL_TSC_Stop_IT(TSC_HandleTypeDef* htsc); |
bogdanm | 85:024bf7f99721 | 558 | TSC_GroupStatusTypeDef HAL_TSC_GroupGetStatus(TSC_HandleTypeDef* htsc, uint32_t gx_index); |
bogdanm | 85:024bf7f99721 | 559 | uint32_t HAL_TSC_GroupGetValue(TSC_HandleTypeDef* htsc, uint32_t gx_index); |
bogdanm | 85:024bf7f99721 | 560 | |
bogdanm | 85:024bf7f99721 | 561 | /* Peripheral Control functions ***********************************************/ |
bogdanm | 85:024bf7f99721 | 562 | HAL_StatusTypeDef HAL_TSC_IOConfig(TSC_HandleTypeDef* htsc, TSC_IOConfigTypeDef* config); |
bogdanm | 85:024bf7f99721 | 563 | HAL_StatusTypeDef HAL_TSC_IODischarge(TSC_HandleTypeDef* htsc, uint32_t choice); |
bogdanm | 85:024bf7f99721 | 564 | |
bogdanm | 85:024bf7f99721 | 565 | /* Peripheral State and Error functions ***************************************/ |
bogdanm | 85:024bf7f99721 | 566 | HAL_TSC_StateTypeDef HAL_TSC_GetState(TSC_HandleTypeDef* htsc); |
bogdanm | 85:024bf7f99721 | 567 | HAL_StatusTypeDef HAL_TSC_PollForAcquisition(TSC_HandleTypeDef* htsc); |
bogdanm | 85:024bf7f99721 | 568 | void HAL_TSC_IRQHandler(TSC_HandleTypeDef* htsc); |
bogdanm | 85:024bf7f99721 | 569 | |
bogdanm | 85:024bf7f99721 | 570 | /* Callback functions *********************************************************/ |
bogdanm | 85:024bf7f99721 | 571 | void HAL_TSC_ConvCpltCallback(TSC_HandleTypeDef* htsc); |
bogdanm | 85:024bf7f99721 | 572 | void HAL_TSC_ErrorCallback(TSC_HandleTypeDef* htsc); |
bogdanm | 85:024bf7f99721 | 573 | |
bogdanm | 85:024bf7f99721 | 574 | #endif /* defined(STM32F051x8) || defined(STM32F071xB) || */ |
bogdanm | 85:024bf7f99721 | 575 | /* defined(STM32F042x6) || defined(STM32F048xx) || defined(STM32F072xB) || */ |
bogdanm | 85:024bf7f99721 | 576 | /* defined(STM32F058xx) || defined(STM32F078xx) */ |
bogdanm | 85:024bf7f99721 | 577 | |
bogdanm | 85:024bf7f99721 | 578 | /** |
bogdanm | 85:024bf7f99721 | 579 | * @} |
bogdanm | 85:024bf7f99721 | 580 | */ |
bogdanm | 85:024bf7f99721 | 581 | |
bogdanm | 85:024bf7f99721 | 582 | /** |
bogdanm | 85:024bf7f99721 | 583 | * @} |
bogdanm | 85:024bf7f99721 | 584 | */ |
bogdanm | 85:024bf7f99721 | 585 | |
bogdanm | 85:024bf7f99721 | 586 | #ifdef __cplusplus |
bogdanm | 85:024bf7f99721 | 587 | } |
bogdanm | 85:024bf7f99721 | 588 | #endif |
bogdanm | 85:024bf7f99721 | 589 | |
bogdanm | 85:024bf7f99721 | 590 | #endif /*__STM32F0xx_TSC_H */ |
bogdanm | 85:024bf7f99721 | 591 | |
bogdanm | 85:024bf7f99721 | 592 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |