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