1 /** 2 ****************************************************************************** 3 * @file stm32n6xx_hal_gpio_ex.h 4 * @author GPM Application Team 5 * @brief Header file of GPIO HAL Extended module. 6 ****************************************************************************** 7 * @attention 8 * 9 * Copyright (c) 2023 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 20 /* Define to prevent recursive inclusion -------------------------------------*/ 21 #ifndef STM32N6xx_HAL_GPIO_EX_H 22 #define STM32N6xx_HAL_GPIO_EX_H 23 24 #ifdef __cplusplus 25 extern "C" { 26 #endif 27 28 /* Includes ------------------------------------------------------------------*/ 29 #include "stm32n6xx_hal_def.h" 30 31 /** @addtogroup STM32N6xx_HAL_Driver 32 * @{ 33 */ 34 35 /** @defgroup GPIOEx GPIOEx 36 * @brief GPIO Extended HAL module driver 37 * @{ 38 */ 39 40 /* Exported types ------------------------------------------------------------*/ 41 /* Exported constants --------------------------------------------------------*/ 42 /** @defgroup GPIOEx_Exported_Constants GPIOEx Exported Constants 43 * @{ 44 */ 45 46 /** @defgroup GPIOEx_Alternate_function_selection GPIOEx Alternate function selection 47 * @{ 48 */ 49 50 /** 51 * @brief AF 0 selection 52 */ 53 #define GPIO_AF0_PWR ((uint8_t)0x00) /*!< PWR Alternate Function mapping */ 54 #define GPIO_AF0_MCO ((uint8_t)0x00) /*!< MCO Alternate Function mapping */ 55 #define GPIO_AF0_RTC ((uint8_t)0x00) /*!< RTC 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 #define GPIO_AF0_SYS ((uint8_t)0x00) /*!< BOOT1 Alternate Function mapping */ 59 60 /** 61 * @brief AF 1 selection 62 */ 63 #define GPIO_AF1_LPTIM1 ((uint8_t)0x01) /*!< LPTIM1 Alternate Function mapping */ 64 #define GPIO_AF1_LPTIM5 ((uint8_t)0x01) /*!< LPTIM5 Alternate Function mapping */ 65 #define GPIO_AF1_TIM1 ((uint8_t)0x01) /*!< TIM1 Alternate Function mapping */ 66 #define GPIO_AF1_TIM2 ((uint8_t)0x01) /*!< TIM2 Alternate Function mapping */ 67 #define GPIO_AF1_TIM16 ((uint8_t)0x01) /*!< TIM16 Alternate Function mapping */ 68 #define GPIO_AF1_TIM17 ((uint8_t)0x01) /*!< TIM17 Alternate Function mapping */ 69 70 /** 71 * @brief AF 2 selection 72 */ 73 #define GPIO_AF2_GFXTIM ((uint8_t)0x02) /*!< GFXTIM Alternate Function mapping */ 74 #define GPIO_AF2_I3C2 ((uint8_t)0x02) /*!< I3C2 Alternate Function mapping */ 75 #define GPIO_AF2_SAI1 ((uint8_t)0x02) /*!< SAI1 Alternate Function mapping */ 76 #define GPIO_AF2_TIM2 ((uint8_t)0x02) /*!< TIM2 Alternate Function mapping */ 77 #define GPIO_AF2_TIM3 ((uint8_t)0x02) /*!< TIM3 Alternate Function mapping */ 78 #define GPIO_AF2_TIM4 ((uint8_t)0x02) /*!< TIM4 Alternate Function mapping */ 79 #define GPIO_AF2_TIM5 ((uint8_t)0x02) /*!< TIM5 Alternate Function mapping */ 80 #define GPIO_AF2_TIM8 ((uint8_t)0x02) /*!< TIM8 Alternate Function mapping */ 81 #define GPIO_AF2_TIM12 ((uint8_t)0x02) /*!< TIM12 Alternate Function mapping */ 82 83 /** 84 * @brief AF 3 selection 85 */ 86 #define GPIO_AF3_ADF1 ((uint8_t)0x03) /*!< ADF1 Alternate Function mapping */ 87 #define GPIO_AF3_LPTIM2 ((uint8_t)0x03) /*!< LPTIM2 Alternate Function mapping */ 88 #define GPIO_AF3_LPTIM3 ((uint8_t)0x03) /*!< LPTIM3 Alternate Function mapping */ 89 #define GPIO_AF3_LPTIM4 ((uint8_t)0x03) /*!< LPTIM4 Alternate Function mapping */ 90 #define GPIO_AF3_LPUART1 ((uint8_t)0x03) /*!< LPUART1 Alternate Function mapping */ 91 #define GPIO_AF3_TIM9 ((uint8_t)0x03) /*!< TIM9 Alternate Function mapping */ 92 #define GPIO_AF3_USART3 ((uint8_t)0x03) /*!< USART3 Alternate Function mapping */ 93 94 /** 95 * @brief AF 4 selection 96 */ 97 #define GPIO_AF4_I2C1 ((uint8_t)0x04) /*!< I2C1 Alternate Function mapping */ 98 #define GPIO_AF4_I2C2 ((uint8_t)0x04) /*!< I2C2 Alternate Function mapping */ 99 #define GPIO_AF4_I2C3 ((uint8_t)0x04) /*!< I2C3 Alternate Function mapping */ 100 #define GPIO_AF4_I2C4 ((uint8_t)0x04) /*!< I2C4 Alternate Function mapping */ 101 #define GPIO_AF4_I3C1 ((uint8_t)0x04) /*!< I3C1 Alternate Function mapping */ 102 #define GPIO_AF4_MDF1 ((uint8_t)0x04) /*!< MDF1 Alternate Function mapping */ 103 #define GPIO_AF4_TIM15 ((uint8_t)0x04) /*!< TIM15 Alternate Function mapping */ 104 #define GPIO_AF4_USART1 ((uint8_t)0x04) /*!< UASRT1 Alternate Function mapping */ 105 106 /** 107 * @brief AF 5 selection 108 */ 109 #define GPIO_AF5_I3C1 ((uint8_t)0x05) /*!< I3C1 Alternate Function mapping */ 110 #define GPIO_AF5_SPI1 ((uint8_t)0x05) /*!< SPI1 Alternate Function mapping */ 111 #define GPIO_AF5_SPI2 ((uint8_t)0x05) /*!< SPI2 Alternate Function mapping */ 112 #define GPIO_AF5_SPI3 ((uint8_t)0x05) /*!< SPI3 Alternate Function mapping */ 113 #define GPIO_AF5_SPI4 ((uint8_t)0x05) /*!< SPI4 Alternate Function mapping */ 114 #define GPIO_AF5_SPI5 ((uint8_t)0x05) /*!< SPI5 Alternate Function mapping */ 115 #define GPIO_AF5_SPI6 ((uint8_t)0x05) /*!< SPI6 Alternate Function mapping */ 116 117 /** 118 * @brief AF 6 selection 119 */ 120 #define GPIO_AF6_FDCAN1 ((uint8_t)0x06) /*!< FDCAN1 Alternate Function mapping */ 121 #define GPIO_AF6_FDCAN2 ((uint8_t)0x06) /*!< FDCAN2 Alternate Function mapping */ 122 #define GPIO_AF6_FDCAN3 ((uint8_t)0x06) /*!< FDCAN3 Alternate Function mapping */ 123 #define GPIO_AF6_SAI1 ((uint8_t)0x06) /*!< SAI1 Alternate Function mapping */ 124 #define GPIO_AF6_SPI3 ((uint8_t)0x06) /*!< SPI3 Alternate Function mapping */ 125 #define GPIO_AF6_SPI4 ((uint8_t)0x06) /*!< SPI4 Alternate Function mapping */ 126 #define GPIO_AF6_UCPD1 ((uint8_t)0x06) /*!< UCPD1 Alternate Function mapping */ 127 #define GPIO_AF6_USART10 ((uint8_t)0x06) /*!< USART10 Alternate Function mapping */ 128 129 /** 130 * @brief AF 7 selection 131 */ 132 #define GPIO_AF7_I3C1 ((uint8_t)0x07) /*!< I3C1 Alternate Function mapping */ 133 #define GPIO_AF7_SPI2 ((uint8_t)0x07) /*!< SPI2 Alternate Function mapping */ 134 #define GPIO_AF7_SPI3 ((uint8_t)0x07) /*!< SPI3 Alternate Function mapping */ 135 #define GPIO_AF7_SPI6 ((uint8_t)0x07) /*!< SPI6 Alternate Function mapping */ 136 #define GPIO_AF7_TIM15 ((uint8_t)0x07) /*!< TIM15 Alternate Function mapping */ 137 #define GPIO_AF7_UART9 ((uint8_t)0x07) /*!< UART9 Alternate Function mapping */ 138 #define GPIO_AF7_UCPD1 ((uint8_t)0x07) /*!< UCPD1 Alternate Function mapping */ 139 #define GPIO_AF7_USART1 ((uint8_t)0x07) /*!< USART1 Alternate Function mapping */ 140 #define GPIO_AF7_USART2 ((uint8_t)0x07) /*!< USART2 Alternate Function mapping */ 141 #define GPIO_AF7_USART3 ((uint8_t)0x07) /*!< USART3 Alternate Function mapping */ 142 #define GPIO_AF7_USART6 ((uint8_t)0x07) /*!< USART6 Alternate Function mapping */ 143 144 /** 145 * @brief AF 8 selection 146 */ 147 #define GPIO_AF8_GFXTIM ((uint8_t)0x08) /*!< GFXTIM Alternate Function mapping */ 148 #define GPIO_AF8_SPDIFRX ((uint8_t)0x08) /*!< SPDIFRX Alternate Function mapping */ 149 #define GPIO_AF8_SPI6 ((uint8_t)0x08) /*!< SPI6 Alternate Function mapping */ 150 #define GPIO_AF8_UART4 ((uint8_t)0x08) /*!< UART4 Alternate Function mapping */ 151 #define GPIO_AF8_UART7 ((uint8_t)0x08) /*!< UART7 Alternate Function mapping */ 152 #define GPIO_AF8_UART8 ((uint8_t)0x08) /*!< UART8 Alternate Function mapping */ 153 #define GPIO_AF8_USART2 ((uint8_t)0x08) /*!< USART2 Alternate Function mapping */ 154 155 /** 156 * @brief AF 9 selection 157 */ 158 #define GPIO_AF9_XSPIM_P1 ((uint8_t)0x09) /*!< XSPIM Manager Port 1 Alternate Function mapping */ 159 #define GPIO_AF9_XSPIM_P2 ((uint8_t)0x09) /*!< XSPIM Manager Port 2 Alternate Function mapping */ 160 #define GPIO_AF9_PSSI ((uint8_t)0x09) /*!< PSSI Alternate Function mapping */ 161 #define GPIO_AF9_SPI5 ((uint8_t)0x09) /*!< SPI5 Alternate Function mapping */ 162 #define GPIO_AF9_TIM11 ((uint8_t)0x09) /*!< TIM11 Alternate Function mapping */ 163 #define GPIO_AF9_DCMIPP ((uint8_t)0x09) /*!< DCMIPP Alternate Function mapping */ 164 #define GPIO_AF9_DCMI ((uint8_t)0x09) /*!< DCMI Alternate Function mapping */ 165 166 /** 167 * @brief AF 10 selection 168 */ 169 #define GPIO_AF10_LCD ((uint8_t)0x0A) /*!< LCD Alternate Function mapping */ 170 #define GPIO_AF10_MDIOS ((uint8_t)0x0A) /*!< MDIOS Alternate Function mapping */ 171 #define GPIO_AF10_PSSI ((uint8_t)0x0A) /*!< PSSI Alternate Function mapping */ 172 #define GPIO_AF10_SAI2 ((uint8_t)0x0A) /*!< SAI2 Alternate Function mapping */ 173 #define GPIO_AF10_SDMMC1 ((uint8_t)0x0A) /*!< SDMMC1 Alternate Function mapping */ 174 #define GPIO_AF10_SPI1 ((uint8_t)0x0A) /*!< SPI1 Alternate Function mapping */ 175 #define GPIO_AF10_TIM10 ((uint8_t)0x0A) /*!< TIM10 Alternate Function mapping */ 176 #define GPIO_AF10_TIM13 ((uint8_t)0x0A) /*!< TIM13 Alternate Function mapping */ 177 #define GPIO_AF10_UART7 ((uint8_t)0x0A) /*!< UART7 Alternate Function mapping */ 178 #define GPIO_AF10_FMC ((uint8_t)0x0A) /*!< FMC Alternate Function mapping */ 179 #define GPIO_AF10_DCMIPP ((uint8_t)0x0A) /*!< DCMIPP Alternate Function mapping */ 180 #define GPIO_AF10_DCMI ((uint8_t)0x0A) /*!< DCMI Alternate Function mapping */ 181 182 /** 183 * @brief AF 11 selection 184 */ 185 #define GPIO_AF11_ETH1 ((uint8_t)0x0B) /*!< ETH1 Alternate Function mapping */ 186 #define GPIO_AF11_MDIOS ((uint8_t)0x0B) /*!< MDIOS Alternate Function mapping */ 187 #define GPIO_AF11_SDMMC2 ((uint8_t)0x0B) /*!< SDMMC2 Alternate Function mapping */ 188 #define GPIO_AF11_UART5 ((uint8_t)0x0B) /*!< UART5 Alternate Function mapping */ 189 #define GPIO_AF11_TIM14 ((uint8_t)0x0B) /*!< TIM14 Alternate Function mapping */ 190 191 /** 192 * @brief AF 12 selection 193 */ 194 #define GPIO_AF12_ETH1 ((uint8_t)0x0C) /*!< ETH1 Alternate Function mapping */ 195 #define GPIO_AF12_FMC ((uint8_t)0x0C) /*!< FMC Alternate Function mapping */ 196 #define GPIO_AF12_GFXTIM ((uint8_t)0x0C) /*!< GFXTIM Alternate Function mapping */ 197 #define GPIO_AF12_LCD ((uint8_t)0x0C) /*!< LCD Alternate Function mapping */ 198 #define GPIO_AF12_SDMMC1 ((uint8_t)0x0C) /*!< SDMMC1 Alternate Function mapping */ 199 200 /** 201 * @brief AF 13 selection 202 */ 203 #define GPIO_AF13_GFXTIM ((uint8_t)0x0D) /*!< GFXTIM Alternate Function mapping */ 204 #define GPIO_AF13_TIM1 ((uint8_t)0x0D) /*!< TIM1 Alternate Function mapping */ 205 206 /** 207 * @brief AF 14 selection 208 */ 209 #define GPIO_AF14_FMC ((uint8_t)0x0E) /*!< FMC Alternate Function mapping */ 210 #define GPIO_AF14_LCD ((uint8_t)0x0E) /*!< LCD Alternate Function mapping */ 211 212 /** 213 * @brief AF 15 selection 214 */ 215 #define GPIO_AF15_EVENTOUT ((uint8_t)0x0F) /*!< EVENTOUT Alternate Function mapping */ 216 #define GPIO_AF15_HDP ((uint8_t)0x0F) /*!< HDP Alternate Function mapping */ 217 218 /** 219 * @brief check if AF is valid 220 */ 221 #define IS_GPIO_AF(AF) ((AF) <= (uint8_t)0x0F) 222 223 /** 224 * @} 225 */ 226 227 /** 228 * @} 229 */ 230 231 /* Exported macro ------------------------------------------------------------*/ 232 /** @defgroup GPIOEx_Exported_Macros GPIOEx Exported Macros 233 * @{ 234 */ 235 236 /** @defgroup GPIOEx_Get_Port_Index GPIOEx Get Port Index 237 * @{ 238 */ 239 #define GPIO_GET_INDEX(__GPIOx__) (((__GPIOx__) == (GPIOA))? 0uL :\ 240 ((__GPIOx__) == (GPIOB))? 1uL :\ 241 ((__GPIOx__) == (GPIOC))? 2uL :\ 242 ((__GPIOx__) == (GPIOD))? 3uL :\ 243 ((__GPIOx__) == (GPIOE))? 4uL :\ 244 ((__GPIOx__) == (GPIOF))? 5uL :\ 245 ((__GPIOx__) == (GPIOG))? 6uL :\ 246 ((__GPIOx__) == (GPIOH))? 7uL :\ 247 ((__GPIOx__) == (GPION))? 8uL :\ 248 ((__GPIOx__) == (GPIOO))? 9uL :\ 249 ((__GPIOx__) == (GPIOP))? 10uL :\ 250 ((__GPIOx__) == (GPIOQ))? 11uL : 16uL) 251 252 /** 253 * @} 254 */ 255 256 /** 257 * @} 258 */ 259 260 /* Exported functions --------------------------------------------------------*/ 261 /** 262 * @} 263 */ 264 265 /** 266 * @} 267 */ 268 269 #ifdef __cplusplus 270 } 271 #endif 272 273 #endif /* STM32N6xx_HAL_GPIO_EX_H */ 274 275