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