1 /** 2 ****************************************************************************** 3 * @file stm32f2xx_hal_gpio_ex.h 4 * @author MCD Application Team 5 * @brief Header file of GPIO HAL Extension module. 6 ****************************************************************************** 7 * @attention 8 * 9 * Copyright (c) 2017 STMicroelectronics. 10 * All rights reserved. 11 * 12 * This software is licensed under terms that can be found in the LICENSE file 13 * in the root directory of this software component. 14 * If no LICENSE file comes with this software, it is provided AS-IS. 15 * 16 ****************************************************************************** 17 */ 18 19 /* Define to prevent recursive inclusion -------------------------------------*/ 20 #ifndef __STM32F2xx_HAL_GPIO_EX_H 21 #define __STM32F2xx_HAL_GPIO_EX_H 22 23 #ifdef __cplusplus 24 extern "C" { 25 #endif 26 27 /* Includes ------------------------------------------------------------------*/ 28 #include "stm32f2xx_hal_def.h" 29 30 /** @addtogroup STM32F2xx_HAL_Driver 31 * @{ 32 */ 33 34 /** @defgroup GPIOEx GPIOEx 35 * @{ 36 */ 37 38 /* Exported types ------------------------------------------------------------*/ 39 /* Exported constants --------------------------------------------------------*/ 40 /* Exported constants --------------------------------------------------------*/ 41 42 /** @defgroup GPIOEx_Exported_Constants GPIO Exported Constants 43 * @{ 44 */ 45 46 /** @defgroup GPIO_Alternate_function_selection GPIO Alternate function selection 47 * @{ 48 */ 49 50 /** 51 * @brief AF 0 selection 52 */ 53 #define GPIO_AF0_RTC_50Hz ((uint8_t)0x00) /* RTC_50Hz Alternate Function mapping */ 54 #define GPIO_AF0_MCO ((uint8_t)0x00) /* MCO (MCO1 and MCO2) Alternate Function mapping */ 55 #define GPIO_AF0_TAMPER ((uint8_t)0x00) /* TAMPER (TAMPER_1 and TAMPER_2) Alternate Function mapping */ 56 #define GPIO_AF0_SWJ ((uint8_t)0x00) /* SWJ (SWD and JTAG) Alternate Function mapping */ 57 #define GPIO_AF0_TRACE ((uint8_t)0x00) /* TRACE Alternate Function mapping */ 58 59 /** 60 * @brief AF 1 selection 61 */ 62 #define GPIO_AF1_TIM1 ((uint8_t)0x01) /* TIM1 Alternate Function mapping */ 63 #define GPIO_AF1_TIM2 ((uint8_t)0x01) /* TIM2 Alternate Function mapping */ 64 65 /** 66 * @brief AF 2 selection 67 */ 68 #define GPIO_AF2_TIM3 ((uint8_t)0x02) /* TIM3 Alternate Function mapping */ 69 #define GPIO_AF2_TIM4 ((uint8_t)0x02) /* TIM4 Alternate Function mapping */ 70 #define GPIO_AF2_TIM5 ((uint8_t)0x02) /* TIM5 Alternate Function mapping */ 71 72 /** 73 * @brief AF 3 selection 74 */ 75 #define GPIO_AF3_TIM8 ((uint8_t)0x03) /* TIM8 Alternate Function mapping */ 76 #define GPIO_AF3_TIM9 ((uint8_t)0x03) /* TIM9 Alternate Function mapping */ 77 #define GPIO_AF3_TIM10 ((uint8_t)0x03) /* TIM10 Alternate Function mapping */ 78 #define GPIO_AF3_TIM11 ((uint8_t)0x03) /* TIM11 Alternate Function mapping */ 79 80 /** 81 * @brief AF 4 selection 82 */ 83 #define GPIO_AF4_I2C1 ((uint8_t)0x04) /* I2C1 Alternate Function mapping */ 84 #define GPIO_AF4_I2C2 ((uint8_t)0x04) /* I2C2 Alternate Function mapping */ 85 #define GPIO_AF4_I2C3 ((uint8_t)0x04) /* I2C3 Alternate Function mapping */ 86 87 /** 88 * @brief AF 5 selection 89 */ 90 #define GPIO_AF5_SPI1 ((uint8_t)0x05) /* SPI1 Alternate Function mapping */ 91 #define GPIO_AF5_SPI2 ((uint8_t)0x05) /* SPI2/I2S2 Alternate Function mapping */ 92 /** 93 * @brief AF 6 selection 94 */ 95 #define GPIO_AF6_SPI3 ((uint8_t)0x06) /* SPI3/I2S3 Alternate Function mapping */ 96 97 /** 98 * @brief AF 7 selection 99 */ 100 #define GPIO_AF7_USART1 ((uint8_t)0x07) /* USART1 Alternate Function mapping */ 101 #define GPIO_AF7_USART2 ((uint8_t)0x07) /* USART2 Alternate Function mapping */ 102 #define GPIO_AF7_USART3 ((uint8_t)0x07) /* USART3 Alternate Function mapping */ 103 104 /** 105 * @brief AF 8 selection 106 */ 107 #define GPIO_AF8_UART4 ((uint8_t)0x08) /* UART4 Alternate Function mapping */ 108 #define GPIO_AF8_UART5 ((uint8_t)0x08) /* UART5 Alternate Function mapping */ 109 #define GPIO_AF8_USART6 ((uint8_t)0x08) /* USART6 Alternate Function mapping */ 110 111 /** 112 * @brief AF 9 selection 113 */ 114 #define GPIO_AF9_CAN1 ((uint8_t)0x09) /* CAN1 Alternate Function mapping */ 115 #define GPIO_AF9_CAN2 ((uint8_t)0x09) /* CAN2 Alternate Function mapping */ 116 #define GPIO_AF9_TIM12 ((uint8_t)0x09) /* TIM12 Alternate Function mapping */ 117 #define GPIO_AF9_TIM13 ((uint8_t)0x09) /* TIM13 Alternate Function mapping */ 118 #define GPIO_AF9_TIM14 ((uint8_t)0x09) /* TIM14 Alternate Function mapping */ 119 120 /** 121 * @brief AF 10 selection 122 */ 123 #define GPIO_AF10_OTG_FS ((uint8_t)0x0A) /* OTG_FS Alternate Function mapping */ 124 #define GPIO_AF10_OTG_HS ((uint8_t)0x0A) /* OTG_HS Alternate Function mapping */ 125 126 /** 127 * @brief AF 11 selection 128 */ 129 #if defined(STM32F207xx) || defined(STM32F217xx) 130 #define GPIO_AF11_ETH ((uint8_t)0x0B) /* ETHERNET Alternate Function mapping */ 131 #endif /* STM32F207xx || STM32F217xx */ 132 133 /** 134 * @brief AF 12 selection 135 */ 136 #define GPIO_AF12_FSMC ((uint8_t)0x0C) /* FSMC Alternate Function mapping */ 137 #define GPIO_AF12_OTG_HS_FS ((uint8_t)0x0C) /* OTG HS configured in FS, Alternate Function mapping */ 138 #define GPIO_AF12_SDIO ((uint8_t)0x0C) /* SDIO Alternate Function mapping */ 139 140 /** 141 * @brief AF 13 selection 142 */ 143 #if defined(STM32F207xx) || defined(STM32F217xx) 144 #define GPIO_AF13_DCMI ((uint8_t)0x0D) /* DCMI Alternate Function mapping */ 145 #endif /* STM32F207xx || STM32F217xx */ 146 147 /** 148 * @brief AF 15 selection 149 */ 150 #define GPIO_AF15_EVENTOUT ((uint8_t)0x0F) /* EVENTOUT Alternate Function mapping */ 151 152 /** 153 * @} 154 */ 155 156 /** 157 * @} 158 */ 159 160 /* Exported macro ------------------------------------------------------------*/ 161 /** @defgroup GPIOEx_Exported_Macros GPIO Exported Macros 162 * @{ 163 */ 164 /** 165 * @} 166 */ 167 168 /* Exported functions --------------------------------------------------------*/ 169 /** @defgroup GPIOEx_Exported_Functions GPIO Exported Functions 170 * @{ 171 */ 172 /** 173 * @} 174 */ 175 176 /* Private types -------------------------------------------------------------*/ 177 /* Private variables ---------------------------------------------------------*/ 178 /* Private constants ---------------------------------------------------------*/ 179 /** @defgroup GPIOEx_Private_Constants GPIO Private Constants 180 * @{ 181 */ 182 /** 183 * @} 184 */ 185 186 /* Private macros ------------------------------------------------------------*/ 187 /** @defgroup GPIOEx_Private_Macros GPIO Private Macros 188 * @{ 189 */ 190 /** @defgroup GPIOEx_Get_Port_Index GPIO Get Port Index 191 * @{ 192 */ 193 #define GPIO_GET_INDEX(__GPIOx__) (uint8_t)(((__GPIOx__) == (GPIOA))? 0U :\ 194 ((__GPIOx__) == (GPIOB))? 1U :\ 195 ((__GPIOx__) == (GPIOC))? 2U :\ 196 ((__GPIOx__) == (GPIOD))? 3U :\ 197 ((__GPIOx__) == (GPIOE))? 4U :\ 198 ((__GPIOx__) == (GPIOF))? 5U :\ 199 ((__GPIOx__) == (GPIOG))? 6U :\ 200 ((__GPIOx__) == (GPIOH))? 7U :\ 201 ((__GPIOx__) == (GPIOI))? 8U : 9U) 202 /** 203 * @} 204 */ 205 206 /** @defgroup GPIOEx_IS_Alternat_function_selection GPIO Check Alternate Function 207 * @{ 208 */ 209 #if defined(STM32F207xx) || defined(STM32F217xx) 210 211 #define IS_GPIO_AF(AF) (((AF) == GPIO_AF0_RTC_50Hz) || ((AF) == GPIO_AF9_TIM14) || \ 212 ((AF) == GPIO_AF0_MCO) || ((AF) == GPIO_AF0_TAMPER) || \ 213 ((AF) == GPIO_AF0_SWJ) || ((AF) == GPIO_AF0_TRACE) || \ 214 ((AF) == GPIO_AF1_TIM1) || ((AF) == GPIO_AF1_TIM2) || \ 215 ((AF) == GPIO_AF2_TIM3) || ((AF) == GPIO_AF2_TIM4) || \ 216 ((AF) == GPIO_AF2_TIM5) || ((AF) == GPIO_AF3_TIM8) || \ 217 ((AF) == GPIO_AF4_I2C1) || ((AF) == GPIO_AF4_I2C2) || \ 218 ((AF) == GPIO_AF4_I2C3) || ((AF) == GPIO_AF5_SPI1) || \ 219 ((AF) == GPIO_AF5_SPI2) || ((AF) == GPIO_AF9_TIM13) || \ 220 ((AF) == GPIO_AF6_SPI3) || ((AF) == GPIO_AF9_TIM12) || \ 221 ((AF) == GPIO_AF7_USART1) || ((AF) == GPIO_AF7_USART2) || \ 222 ((AF) == GPIO_AF7_USART3) || ((AF) == GPIO_AF8_UART4) || \ 223 ((AF) == GPIO_AF8_UART5) || ((AF) == GPIO_AF8_USART6) || \ 224 ((AF) == GPIO_AF9_CAN1) || ((AF) == GPIO_AF9_CAN2) || \ 225 ((AF) == GPIO_AF10_OTG_FS) || ((AF) == GPIO_AF10_OTG_HS) || \ 226 ((AF) == GPIO_AF11_ETH) || ((AF) == GPIO_AF12_OTG_HS_FS) || \ 227 ((AF) == GPIO_AF12_SDIO) || ((AF) == GPIO_AF13_DCMI) || \ 228 ((AF) == GPIO_AF12_FSMC) || ((AF) == GPIO_AF15_EVENTOUT)) 229 #else /* STM32F207xx || STM32F217xx */ 230 #define IS_GPIO_AF(AF) (((AF) == GPIO_AF0_RTC_50Hz) || ((AF) == GPIO_AF9_TIM14) || \ 231 ((AF) == GPIO_AF0_MCO) || ((AF) == GPIO_AF0_TAMPER) || \ 232 ((AF) == GPIO_AF0_SWJ) || ((AF) == GPIO_AF0_TRACE) || \ 233 ((AF) == GPIO_AF1_TIM1) || ((AF) == GPIO_AF1_TIM2) || \ 234 ((AF) == GPIO_AF2_TIM3) || ((AF) == GPIO_AF2_TIM4) || \ 235 ((AF) == GPIO_AF2_TIM5) || ((AF) == GPIO_AF3_TIM8) || \ 236 ((AF) == GPIO_AF4_I2C1) || ((AF) == GPIO_AF4_I2C2) || \ 237 ((AF) == GPIO_AF4_I2C3) || ((AF) == GPIO_AF5_SPI1) || \ 238 ((AF) == GPIO_AF5_SPI2) || ((AF) == GPIO_AF9_TIM13) || \ 239 ((AF) == GPIO_AF6_SPI3) || ((AF) == GPIO_AF9_TIM12) || \ 240 ((AF) == GPIO_AF7_USART1) || ((AF) == GPIO_AF7_USART2) || \ 241 ((AF) == GPIO_AF7_USART3) || ((AF) == GPIO_AF8_UART4) || \ 242 ((AF) == GPIO_AF8_UART5) || ((AF) == GPIO_AF8_USART6) || \ 243 ((AF) == GPIO_AF9_CAN1) || ((AF) == GPIO_AF9_CAN2) || \ 244 ((AF) == GPIO_AF10_OTG_FS) || ((AF) == GPIO_AF10_OTG_HS) || \ 245 ((AF) == GPIO_AF12_OTG_HS_FS) || ((AF) == GPIO_AF12_SDIO) || \ 246 ((AF) == GPIO_AF12_FSMC) || ((AF) == GPIO_AF15_EVENTOUT)) 247 #endif /* STM32F207xx || STM32F217xx */ 248 249 /** 250 * @} 251 */ 252 253 /** 254 * @} 255 */ 256 257 /* Private functions ---------------------------------------------------------*/ 258 /** @defgroup GPIOEx_Private_Functions GPIO Private Functions 259 * @{ 260 */ 261 262 /** 263 * @} 264 */ 265 266 /** 267 * @} 268 */ 269 270 /** 271 * @} 272 */ 273 274 #ifdef __cplusplus 275 } 276 #endif 277 278 #endif /* __STM32F2xx_HAL_GPIO_EX_H */ 279 280