1 /** 2 ****************************************************************************** 3 * @file stm32c0xx_hal_gpio_ex.h 4 * @author MCD Application Team 5 * @brief Header file of GPIO HAL Extended module. 6 ****************************************************************************** 7 * @attention 8 * 9 * Copyright (c) 2022 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 STM32C0xx_HAL_GPIO_EX_H 21 #define STM32C0xx_HAL_GPIO_EX_H 22 23 #ifdef __cplusplus 24 extern "C" { 25 #endif 26 27 /* Includes ------------------------------------------------------------------*/ 28 #include "stm32c0xx_hal_def.h" 29 30 /** @addtogroup STM32C0xx_HAL_Driver 31 * @{ 32 */ 33 34 /** @defgroup GPIOEx GPIOEx 35 * @brief GPIO Extended HAL module driver 36 * @{ 37 */ 38 39 /* Exported types ------------------------------------------------------------*/ 40 /* Exported constants --------------------------------------------------------*/ 41 /** @defgroup GPIOEx_Exported_Constants GPIOEx Exported Constants 42 * @{ 43 */ 44 45 /** @defgroup GPIOEx_Alternate_function_selection GPIOEx Alternate function selection 46 * @{ 47 */ 48 49 #if defined(STM32C011xx) 50 /*------------------------- STM32C011xx --------------------------------------*/ 51 /** 52 * @brief AF 0 selection 53 */ 54 #define GPIO_AF0_MCO ((uint8_t)0x00) /*!< MCO (MCO1 and MCO2) Alternate Function mapping */ 55 #define GPIO_AF0_OSC32 ((uint8_t)0x00) /*!< OSC32 (By pass and Enable) Alternate Function mapping */ 56 #define GPIO_AF0_SWJ ((uint8_t)0x00) /*!< SWJ (SWD) Alternate Function mapping */ 57 #define GPIO_AF0_SPI1 ((uint8_t)0x00) /*!< SPI1 Alternate Function mapping */ 58 #define GPIO_AF0_I2S1 ((uint8_t)0x00) /*!< I2S1 Alternate Function mapping */ 59 #define GPIO_AF0_USART1 ((uint8_t)0x00) /*!< USART1 Alternate Function mapping */ 60 61 /** 62 * @brief AF 1 selection 63 */ 64 #define GPIO_AF1_IR ((uint8_t)0x01) /*!< IR Alternate Function mapping */ 65 #define GPIO_AF1_OSC ((uint8_t)0x01) /*!< OSC (By pass and Enable) Alternate Function mapping */ 66 #define GPIO_AF1_TIM1 ((uint8_t)0x01) /*!< TIM1 Alternate Function mapping */ 67 #define GPIO_AF1_TIM3 ((uint8_t)0x01) /*!< TIM3 Alternate Function mapping */ 68 #define GPIO_AF1_USART1 ((uint8_t)0x01) /*!< USART1 Alternate Function mapping */ 69 #define GPIO_AF1_USART2 ((uint8_t)0x01) /*!< USART2 Alternate Function mapping */ 70 71 /** 72 * @brief AF 2 selection 73 */ 74 #define GPIO_AF2_TIM1 ((uint8_t)0x02) /*!< TIM1 Alternate Function mapping */ 75 #define GPIO_AF2_TIM16 ((uint8_t)0x02) /*!< TIM16 Alternate Function mapping */ 76 #define GPIO_AF2_TIM17 ((uint8_t)0x02) /*!< TIM17 Alternate Function mapping */ 77 78 /** 79 * @brief AF 3 selection 80 */ 81 #define GPIO_AF3_MCO2 ((uint8_t)0x03) /*!< MCO2 Alternate Function mapping */ 82 #define GPIO_AF3_TIM3 ((uint8_t)0x03) /*!< TIM3 Alternate Function mapping */ 83 /** 84 * @brief AF 4 selection 85 */ 86 #define GPIO_AF4_TIM14 ((uint8_t)0x04) /*!< TIM14 Alternate Function mapping */ 87 #define GPIO_AF4_USART2 ((uint8_t)0x04) /*!< USART2 Alternate Function mapping */ 88 #define GPIO_AF4_USART1 ((uint8_t)0x04) /*!< USART1 Alternate Function mapping */ 89 90 /** 91 * @brief AF 5 selection 92 */ 93 #define GPIO_AF5_I2S ((uint8_t)0x05) /*!< I2S Alternate Function mapping */ 94 #define GPIO_AF5_USART1 ((uint8_t)0x05) /*!< USART1 Alternate Function mapping */ 95 #define GPIO_AF5_TIM1 ((uint8_t)0x05) /*!< TIM1 Alternate Function mapping */ 96 #define GPIO_AF5_TIM16 ((uint8_t)0x05) /*!< TIM16 Alternate Function mapping */ 97 #define GPIO_AF5_TIM17 ((uint8_t)0x05) /*!< TIM17 Alternate Function mapping */ 98 99 /** 100 * @brief AF 6 selection 101 */ 102 #define GPIO_AF6_I2C1 ((uint8_t)0x06) /*!< I2C1 Alternate Function mapping */ 103 104 /** 105 * @brief AF 7 selection 106 */ 107 #define GPIO_AF7_EVENTOUT ((uint8_t)0x07) /*!< EVENTOUT Alternate Function mapping */ 108 #define GPIO_AF7_I2C1 ((uint8_t)0x07) /*!< I2C1 Alternate Function mapping */ 109 110 /** 111 * @brief AF 8 selection 112 */ 113 #define GPIO_AF8_I2S1 ((uint8_t)0x08) /*!< I2S1 Alternate Function mapping */ 114 #define GPIO_AF8_SPI1 ((uint8_t)0x08) /*!< SPI1 Alternate Function mapping */ 115 #define GPIO_AF8_IR ((uint8_t)0x08) /*!< IR Alternate Function mapping */ 116 /** 117 * @brief AF 9 selection 118 */ 119 #define GPIO_AF9_TIM1 ((uint8_t)0x09) /*!< TIM1 Alternate Function mapping */ 120 #define GPIO_AF9_USART2 ((uint8_t)0x09) /*!< USART2 Alternate Function mapping */ 121 #define GPIO_AF9_SPI1 ((uint8_t)0x09) /*!< SPI1 Alternate Function mapping */ 122 #define GPIO_AF9_I2S1 ((uint8_t)0x09) /*!< I2S1 Alternate Function mapping */ 123 /** 124 * @brief AF 10 selection 125 */ 126 #define GPIO_AF10_TIM1 ((uint8_t)0x0A) /*!< TIM1 Alternate Function mapping */ 127 #define GPIO_AF10_I2C1 ((uint8_t)0x0A) /*!< I2C1 Alternate Function mapping */ 128 #define GPIO_AF10_SPI1 ((uint8_t)0x0A) /*!< SPI1 Alternate Function mapping */ 129 #define GPIO_AF10_TIM16 ((uint8_t)0x0A) /*!< TIM16 Alternate Function mapping */ 130 #define GPIO_AF10_TIM17 ((uint8_t)0x0A) /*!< TIM17 Alternate Function mapping */ 131 /** 132 * @brief AF 11 selection 133 */ 134 #define GPIO_AF11_TIM1 ((uint8_t)0x0B) /*!< TIM1 Alternate Function mapping */ 135 #define GPIO_AF11_TIM3 ((uint8_t)0x0B) /*!< TIM3 Alternate Function mapping */ 136 #define GPIO_AF11_MCO2 ((uint8_t)0x0B) /*!< MCO2 Alternate Function mapping */ 137 /** 138 * @brief AF 12 selection 139 */ 140 #define GPIO_AF12_TIM3 ((uint8_t)0x0C) /*!< TIM3 Alternate Function mapping */ 141 #define GPIO_AF12_USART1 ((uint8_t)0x0C) /*!< USART1 Alternate Function mapping */ 142 /** 143 * @brief AF 13 selection 144 */ 145 #define GPIO_AF13_TIM14 ((uint8_t)0x0D) /*!< TIM14 Alternate Function mapping */ 146 #define GPIO_AF13_TIM3 ((uint8_t)0x0D) /*!< TIM3 Alternate Function mapping */ 147 /** 148 * @brief AF 14 selection 149 */ 150 #define GPIO_AF14_USART1 ((uint8_t)0x0E) /*!< USART1 Alternate Function mapping */ 151 #define GPIO_AF14_I2C1 ((uint8_t)0x0E) /*!< I2C1 Alternate Function mapping */ 152 #define GPIO_AF14_TIM16 ((uint8_t)0x0E) /*!< TIM16 Alternate Function mapping */ 153 /** 154 * @brief AF 15 selection 155 */ 156 #define GPIO_AF15_EVENTOUT ((uint8_t)0x0F) /*!< EVENTOUT Alternate Function mapping */ 157 #define GPIO_AF15_MCO2 ((uint8_t)0x0F) /*!< MCO2 Alternate Function mapping */ 158 #define GPIO_AF15_TIM17 ((uint8_t)0x0F) /*!< TIM17 Alternate Function mapping */ 159 160 #define IS_GPIO_AF(AF) ((AF) <= (uint8_t)0x0F) 161 #endif /* STM32C011xx */ 162 163 #if defined(STM32C031xx) 164 /*------------------------- STM32C031xx --------------------------------------*/ 165 /** 166 * @brief AF 0 selection 167 */ 168 #define GPIO_AF0_EVENTOUT ((uint8_t)0x00) /*!< EVENTOUT Alternate Function mapping */ 169 #define GPIO_AF0_IR ((uint8_t)0x00) /*!< IR Alternate Function mapping */ 170 #define GPIO_AF0_MCO ((uint8_t)0x00) /*!< MCO (MCO1 and MCO2) Alternate Function mapping */ 171 #define GPIO_AF0_OSC ((uint8_t)0x00) /*!< OSC (By pass and Enable) Alternate Function mapping */ 172 #define GPIO_AF0_OSC32 ((uint8_t)0x00) /*!< OSC32 (By pass and Enable) Alternate Function mapping */ 173 #define GPIO_AF0_SWJ ((uint8_t)0x00) /*!< SWJ (SWD) Alternate Function mapping */ 174 #define GPIO_AF0_SPI1 ((uint8_t)0x00) /*!< SPI1 Alternate Function mapping */ 175 #define GPIO_AF0_I2S1 ((uint8_t)0x00) /*!< I2S1 Alternate Function mapping */ 176 #define GPIO_AF0_TIM14 ((uint8_t)0x00) /*!< TIM14 Alternate Function mapping */ 177 #define GPIO_AF0_USART1 ((uint8_t)0x00) /*!< USART1 Alternate Function mapping */ 178 #define GPIO_AF0_USART2 ((uint8_t)0x00) /*!< USART2 Alternate Function mapping */ 179 180 /** 181 * @brief AF 1 selection 182 */ 183 #define GPIO_AF1_IR ((uint8_t)0x01) /*!< IR Alternate Function mapping */ 184 #define GPIO_AF1_OSC ((uint8_t)0x01) /*!< OSC (By pass and Enable) Alternate Function mapping */ 185 #define GPIO_AF1_TIM1 ((uint8_t)0x01) /*!< TIM1 Alternate Function mapping */ 186 #define GPIO_AF1_TIM3 ((uint8_t)0x01) /*!< TIM3 Alternate Function mapping */ 187 #define GPIO_AF1_USART1 ((uint8_t)0x01) /*!< USART1 Alternate Function mapping */ 188 #define GPIO_AF1_USART2 ((uint8_t)0x01) /*!< USART2 Alternate Function mapping */ 189 190 /** 191 * @brief AF 2 selection 192 */ 193 #define GPIO_AF2_TIM1 ((uint8_t)0x02) /*!< TIM1 Alternate Function mapping */ 194 #define GPIO_AF2_TIM14 ((uint8_t)0x02) /*!< TIM14 Alternate Function mapping */ 195 #define GPIO_AF2_TIM16 ((uint8_t)0x02) /*!< TIM16 Alternate Function mapping */ 196 #define GPIO_AF2_TIM17 ((uint8_t)0x02) /*!< TIM17 Alternate Function mapping */ 197 198 /** 199 * @brief AF 3 selection 200 */ 201 #define GPIO_AF3_MCO2 ((uint8_t)0x03) /*!< MCO2 Alternate Function mapping */ 202 #define GPIO_AF3_TIM3 ((uint8_t)0x03) /*!< TIM3 Alternate Function mapping */ 203 /** 204 * @brief AF 4 selection 205 */ 206 #define GPIO_AF4_TIM14 ((uint8_t)0x04) /*!< TIM14 Alternate Function mapping */ 207 #define GPIO_AF4_USART2 ((uint8_t)0x04) /*!< USART2 Alternate Function mapping */ 208 #define GPIO_AF4_USART1 ((uint8_t)0x04) /*!< USART1 Alternate Function mapping */ 209 210 /** 211 * @brief AF 5 selection 212 */ 213 #define GPIO_AF5_I2S ((uint8_t)0x05) /*!< I2S Alternate Function mapping */ 214 #define GPIO_AF5_USART1 ((uint8_t)0x05) /*!< USART1 Alternate Function mapping */ 215 #define GPIO_AF5_TIM1 ((uint8_t)0x05) /*!< TIM1 Alternate Function mapping */ 216 #define GPIO_AF5_TIM16 ((uint8_t)0x05) /*!< TIM16 Alternate Function mapping */ 217 #define GPIO_AF5_TIM17 ((uint8_t)0x05) /*!< TIM17 Alternate Function mapping */ 218 219 /** 220 * @brief AF 6 selection 221 */ 222 #define GPIO_AF6_I2C1 ((uint8_t)0x06) /*!< I2C1 Alternate Function mapping */ 223 224 /** 225 * @brief AF 7 selection 226 */ 227 #define GPIO_AF7_EVENTOUT ((uint8_t)0x07) /*!< EVENTOUT Alternate Function mapping */ 228 #define GPIO_AF7_I2C1 ((uint8_t)0x07) /*!< I2C1 Alternate Function mapping */ 229 230 /** 231 * @brief AF 8 selection 232 */ 233 #define GPIO_AF8_I2S1 ((uint8_t)0x08) /*!< I2S1 Alternate Function mapping */ 234 #define GPIO_AF8_SPI1 ((uint8_t)0x08) /*!< SPI1 Alternate Function mapping */ 235 #define GPIO_AF8_IR ((uint8_t)0x08) /*!< IR Alternate Function mapping */ 236 /** 237 * @brief AF 9 selection 238 */ 239 #define GPIO_AF9_TIM1 ((uint8_t)0x09) /*!< TIM1 Alternate Function mapping */ 240 #define GPIO_AF9_USART2 ((uint8_t)0x09) /*!< USART2 Alternate Function mapping */ 241 #define GPIO_AF9_SPI1 ((uint8_t)0x09) /*!< SPI1 Alternate Function mapping */ 242 #define GPIO_AF9_I2S1 ((uint8_t)0x09) /*!< I2S1 Alternate Function mapping */ 243 /** 244 * @brief AF 10 selection 245 */ 246 #define GPIO_AF10_TIM1 ((uint8_t)0x0A) /*!< TIM1 Alternate Function mapping */ 247 #define GPIO_AF10_I2C1 ((uint8_t)0x0A) /*!< I2C1 Alternate Function mapping */ 248 #define GPIO_AF10_SPI1 ((uint8_t)0x0A) /*!< SPI1 Alternate Function mapping */ 249 #define GPIO_AF10_TIM16 ((uint8_t)0x0A) /*!< TIM16 Alternate Function mapping */ 250 #define GPIO_AF10_TIM17 ((uint8_t)0x0A) /*!< TIM17 Alternate Function mapping */ 251 /** 252 * @brief AF 11 selection 253 */ 254 #define GPIO_AF11_TIM1 ((uint8_t)0x0B) /*!< TIM1 Alternate Function mapping */ 255 #define GPIO_AF11_TIM3 ((uint8_t)0x0B) /*!< TIM3 Alternate Function mapping */ 256 #define GPIO_AF11_MCO2 ((uint8_t)0x0B) /*!< MCO2 Alternate Function mapping */ 257 /** 258 * @brief AF 12 selection 259 */ 260 #define GPIO_AF12_TIM3 ((uint8_t)0x0C) /*!< TIM3 Alternate Function mapping */ 261 #define GPIO_AF12_USART1 ((uint8_t)0x0C) /*!< USART1 Alternate Function mapping */ 262 /** 263 * @brief AF 13 selection 264 */ 265 #define GPIO_AF13_TIM14 ((uint8_t)0x0D) /*!< TIM14 Alternate Function mapping */ 266 #define GPIO_AF13_TIM3 ((uint8_t)0x0D) /*!< TIM3 Alternate Function mapping */ 267 /** 268 * @brief AF 14 selection 269 */ 270 #define GPIO_AF14_USART1 ((uint8_t)0x0E) /*!< USART1 Alternate Function mapping */ 271 #define GPIO_AF14_I2C1 ((uint8_t)0x0E) /*!< I2C1 Alternate Function mapping */ 272 #define GPIO_AF14_TIM16 ((uint8_t)0x0E) /*!< TIM16 Alternate Function mapping */ 273 /** 274 * @brief AF 15 selection 275 */ 276 #define GPIO_AF15_EVENTOUT ((uint8_t)0x0F) /*!< EVENTOUT Alternate Function mapping */ 277 #define GPIO_AF15_MCO2 ((uint8_t)0x0F) /*!< MCO2 Alternate Function mapping */ 278 #define GPIO_AF15_TIM17 ((uint8_t)0x0F) /*!< TIM17 Alternate Function mapping */ 279 280 #define IS_GPIO_AF(AF) ((AF) <= (uint8_t)0x0F) 281 #endif /* STM32C031xx */ 282 /** 283 * @} 284 */ 285 286 /** 287 * @} 288 */ 289 290 /* Exported macro ------------------------------------------------------------*/ 291 /** @defgroup GPIOEx_Exported_Macros GPIOEx Exported Macros 292 * @{ 293 */ 294 295 /** @defgroup GPIOEx_Get_Port_Index GPIOEx Get Port Index 296 * @{ 297 */ 298 #if defined(STM32C011xx) 299 #define GPIO_GET_INDEX(__GPIOx__) (((__GPIOx__) == (GPIOA))? 0UL :\ 300 ((__GPIOx__) == (GPIOB))? 1UL :\ 301 ((__GPIOx__) == (GPIOC))? 2UL :\ 302 ((__GPIOx__) == (GPIOF))? 5UL : 6UL) 303 #elif defined(STM32C031xx) 304 #define GPIO_GET_INDEX(__GPIOx__) (((__GPIOx__) == (GPIOA))? 0UL :\ 305 ((__GPIOx__) == (GPIOB))? 1UL :\ 306 ((__GPIOx__) == (GPIOC))? 2UL :\ 307 ((__GPIOx__) == (GPIOD))? 3UL :\ 308 ((__GPIOx__) == (GPIOF))? 5UL : 6UL) 309 #endif /* STM32C011xx */ 310 /** 311 * @} 312 */ 313 314 /** 315 * @} 316 */ 317 318 /* Exported functions --------------------------------------------------------*/ 319 /** 320 * @} 321 */ 322 323 /** 324 * @} 325 */ 326 327 #ifdef __cplusplus 328 } 329 #endif 330 331 #endif /* STM32C0xx_HAL_GPIO_EX_H */ 332