1 /** 2 ****************************************************************************** 3 * @file stm32wb0x_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) 2024 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 STM32WB0x_HAL_GPIO_EX_H 21 #define STM32WB0x_HAL_GPIO_EX_H 22 23 #ifdef __cplusplus 24 extern "C" { 25 #endif 26 27 /* Includes ------------------------------------------------------------------*/ 28 #include "stm32wb0x_hal_def.h" 29 30 /** @addtogroup STM32WB0x_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 50 /* The table below gives an overview of the different alternate functions per port. 51 * For more details refer yourself to the product data sheet. 52 * 53 */ 54 55 #if defined (STM32WB05) || defined (STM32WB09) 56 /** 57 * @brief AF 0 selection 58 */ 59 60 #define GPIO_AF0_MCO ((uint8_t)0x00) /*!< MCO Alternate Function mapping */ 61 #define GPIO_AF0_SWDIO ((uint8_t)0x00) /*!< SWDIO Alternate Function mapping */ 62 #define GPIO_AF0_SWCLK ((uint8_t)0x00) /*!< SWCLK Alternate Function mapping */ 63 #define GPIO_AF0_I2C1 ((uint8_t)0x00) /*!< I2C1 Alternate Function mapping */ 64 #define GPIO_AF0_LPUART1 ((uint8_t)0x00) /*!< LPUART1 Alternate Function mapping */ 65 #define GPIO_AF0_USART1 ((uint8_t)0x00) /*!< USART1 Alternate Function mapping */ 66 67 /** 68 * @brief AF 1 selection 69 */ 70 #define GPIO_AF1_IR_OUT ((uint8_t)0x01) /*!< IR_OUT Alternate Function mapping */ 71 #define GPIO_AF1_LCO ((uint8_t)0x01) /*!< LCO Alternate Function mapping */ 72 #define GPIO_AF1_USART1 ((uint8_t)0x01) /*!< USART1 Alternate Function mapping */ 73 #define GPIO_AF1_LPUART1 ((uint8_t)0x01) /*!< LPUART1 Alternate Function mapping */ 74 #define GPIO_AF1_TX_SEQUENCE ((uint8_t)0x01) /*!< TX Sequence Alternate Function mapping */ 75 #define GPIO_AF1_RTC ((uint8_t)0x01) /*!< RTC Alternate Function mapping */ 76 77 /** 78 * @brief AF 2 selection 79 */ 80 #define GPIO_AF2_IR_OUT ((uint8_t)0x02) /*!< IR Alternate Function mapping */ 81 #define GPIO_AF2_TIM2 ((uint8_t)0x02) /*!< TIM1 Alternate Function mapping */ 82 #define GPIO_AF2_TIM16 ((uint8_t)0x02) /*!< TIM16 Alternate Function mapping */ 83 #define GPIO_AF2_TIM17 ((uint8_t)0x02) /*!< TIM17 Alternate Function mapping */ 84 #define GPIO_AF2_LPUART1 ((uint8_t)0x02) /*!< LPUART1 Alternate Function mapping */ 85 #define GPIO_AF2_USART1 ((uint8_t)0x02) /*!< USART1 Alternate Function mapping */ 86 #define GPIO_AF2_RTC ((uint8_t)0x02) /*!< RTC Alternate Function mapping */ 87 #define GPIO_AF2_TX_SEQUENCE ((uint8_t)0x02) /*!< TX_SEQUENCE Alternate Function mapping */ 88 #define GPIO_AF2_RX_SEQUENCE ((uint8_t)0x02) /*!< RX_SEQUENCE Alternate Function mapping */ 89 90 /** 91 * @brief AF 3 selection 92 */ 93 94 #define GPIO_AF3_SPI3 ((uint8_t)0x03) /*!< SPI3 Alternate Function mapping */ 95 #define GPIO_AF3_TIM2 ((uint8_t)0x03) /*!< TIM2 Alternate Function mapping */ 96 #define GPIO_AF3_LPUART1 ((uint8_t)0x03) /*!< LPUART1 Alternate Function mapping */ 97 #define GPIO_AF3_MCO ((uint8_t)0x03) /*!< MCO Alternate Function mapping */ 98 99 /** 100 * @brief AF 4 selection 101 */ 102 #define GPIO_AF4_TIM2 ((uint8_t)0x04) /*!< TIM2 Alternate Function mapping */ 103 #define GPIO_AF4_SPI3 ((uint8_t)0x04) /*!< SPI3 Alternate Function mapping */ 104 105 /** 106 * @brief AF 5 selection 107 */ 108 #define GPIO_AF5_SWDIO ((uint8_t)0x05) /*!< SWDIO Alternate Function mapping */ 109 #define GPIO_AF5_SWCLK ((uint8_t)0x05) /*!< SWCLK Alternate Function mapping */ 110 111 /** 112 * @brief AF 6 selection 113 */ 114 #define GPIO_AF6_ANT ((uint8_t)0x06) /*!< ANT Alternate Function mapping */ 115 #define GPIO_AF6_RXACTIVITY ((uint8_t)0x06) /*!< RXACTIVITY Alternate Function mapping */ 116 #define GPIO_AF6_TIM16 ((uint8_t)0x06) /*!< TIM16 Alternate Function mapping */ 117 #define GPIO_AF6_TIM17 ((uint8_t)0x06) /*!< TIM17 Alternate Function mapping */ 118 #define GPIO_AF6_USART1 ((uint8_t)0x06) /*!< USART1 Alternate Function mapping */ 119 120 /** 121 * @brief AF 7 selection 122 */ 123 #define GPIO_AF7_SWDIO ((uint8_t)0x07) /*!< SWDIO Alternate Function mapping */ 124 #define GPIO_AF7_SWCLK ((uint8_t)0x07) /*!< SWCLK Alternate Function mapping */ 125 126 #define IS_GPIO_AF(AF) ((AF) <= (uint8_t)0x07) 127 128 #endif /* STM32WB05 || STM32WB09 */ 129 130 131 #if defined (STM32WB06) || defined (STM32WB07) 132 /** 133 * @brief AF 0 selection 134 */ 135 #define GPIO_AF0_I2C1 ((uint8_t)0x00) /*!< I2C1 Alternate Function mapping */ 136 #define GPIO_AF0_I2C2 ((uint8_t)0x00) /*!< I2C2 Alternate Function mapping */ 137 #define GPIO_AF0_MCO ((uint8_t)0x00) /*!< MCO Alternate Function mapping */ 138 #define GPIO_AF0_LCO ((uint8_t)0x00) /*!< LCO Alternate Function mapping */ 139 #define GPIO_AF0_SWDIO ((uint8_t)0x00) /*!< SWDIO Alternate Function mapping */ 140 #define GPIO_AF0_SWCLK ((uint8_t)0x00) /*!< SWCLK Alternate Function mapping */ 141 #define GPIO_AF0_LPUART1 ((uint8_t)0x00) /*!< LPUART1 Alternate Function mapping */ 142 #define GPIO_AF0_USART1 ((uint8_t)0x00) /*!< USART1 Alternate Function mapping */ 143 #define GPIO_AF0_SPI1 ((uint8_t)0x00) /*!< SPI1 Alternate Function mapping */ 144 145 /** 146 * @brief AF 1 selection 147 */ 148 #define GPIO_AF1_SPI1 ((uint8_t)0x01) /*!< SPI1 Alternate Function mapping */ 149 #define GPIO_AF1_SPI2 ((uint8_t)0x01) /*!< SPI2 Alternate Function mapping */ 150 #define GPIO_AF1_SWDIO ((uint8_t)0x01) /*!< SWDIO Alternate Function mapping */ 151 #define GPIO_AF1_SWCLK ((uint8_t)0x01) /*!< SWCLK Alternate Function mapping */ 152 #define GPIO_AF1_I2C2 ((uint8_t)0x01) /*!< I2C2 Alternate Function mapping */ 153 #define GPIO_AF1_USART1 ((uint8_t)0x01) /*!< USART1 Alternate Function mapping */ 154 #define GPIO_AF1_LPUART1 ((uint8_t)0x01) /*!< LPUART1 Alternate Function mapping */ 155 #define GPIO_AF1_PDM ((uint8_t)0x01) /*!< PDM Alternate Function mapping */ 156 #define GPIO_AF1_LCO ((uint8_t)0x01) /*!< LCO Alternate Function mapping */ 157 #define GPIO_AF1_TX_SEQUENCE ((uint8_t)0x01) /*!< TX Sequence Alternate Function mapping */ 158 159 /** 160 * @brief AF 2 selection 161 */ 162 #define GPIO_AF2_SPI1 ((uint8_t)0x02) /*!< SPI1 Alternate Function mapping */ 163 #define GPIO_AF2_SPI2 ((uint8_t)0x02) /*!< SPI2 Alternate Function mapping */ 164 #define GPIO_AF2_RTC ((uint8_t)0x02) /*!< RTC Alternate Function mapping */ 165 #define GPIO_AF2_USART1 ((uint8_t)0x02) /*!< USART1 Alternate Function mapping */ 166 #define GPIO_AF2_TIM1 ((uint8_t)0x02) /*!< TIM1 Alternate Function mapping */ 167 #define GPIO_AF2_I2C1 ((uint8_t)0x02) /*!< I2C1 Alternate Function mapping */ 168 #define GPIO_AF2_PDM ((uint8_t)0x02) /*!< PDM Alternate Function mapping */ 169 #define GPIO_AF2_MCO ((uint8_t)0x02) /*!< MCO Alternate Function mapping */ 170 #define GPIO_AF2_TX_SEQUENCE ((uint8_t)0x02) /*!< TX_SEQUENCE Alternate Function mapping */ 171 #define GPIO_AF2_RX_SEQUENCE ((uint8_t)0x02) /*!< RX_SEQUENCE Alternate Function mapping */ 172 173 /** 174 * @brief AF 3 selection 175 */ 176 #define GPIO_AF3_SPI2 ((uint8_t)0x03) /*!< SPI2 Alternate Function mapping */ 177 #define GPIO_AF3_SPI3 ((uint8_t)0x03) /*!< SPI3 Alternate Function mapping */ 178 #define GPIO_AF3_LPUART1 ((uint8_t)0x03) /*!< LPUART1 Alternate Function mapping */ 179 #define GPIO_AF3_TIM1 ((uint8_t)0x03) /*!< TIM1 Alternate Function mapping */ 180 #define GPIO_AF3_PDM ((uint8_t)0x03) /*!< PDM Alternate Function mapping */ 181 182 /** 183 * @brief AF 4 selection 184 */ 185 #define GPIO_AF4_TIM1 ((uint8_t)0x04) /*!< TIM1 Alternate Function mapping */ 186 187 /** 188 * @brief AF 5 selection 189 */ 190 #define GPIO_AF5_SWDIO ((uint8_t)0x05) /*!< SWDIO Alternate Function mapping */ 191 #define GPIO_AF5_SWCLK ((uint8_t)0x05) /*!< SWCLK Alternate Function mapping */ 192 193 /** 194 * @brief AF 7 selection 195 */ 196 #define GPIO_AF7_SWDIO ((uint8_t)0x07) /*!< SWDIO Alternate Function mapping */ 197 #define GPIO_AF7_SWCLK ((uint8_t)0x07) /*!< SWCLK Alternate Function mapping */ 198 #define GPIO_AF7_USART1 ((uint8_t)0x07) /*!< USART1 Alternate Function mapping */ 199 200 #define IS_GPIO_AF(AF) ((AF) <= (uint8_t)0x07) 201 202 #endif /* STM32WB06 || STM32WB07 */ 203 204 /** 205 * @} 206 */ 207 208 /** 209 * @} 210 */ 211 212 /* Exported macro ------------------------------------------------------------*/ 213 /** @defgroup GPIOEx_Exported_Macros GPIOEx Exported Macros 214 * @{ 215 */ 216 217 /** @defgroup GPIOEx_Get_Port_Index GPIOEx Get Port Index 218 * @{ 219 */ 220 #define GPIO_GET_INDEX(__GPIOx__) (((__GPIOx__) == (GPIOA))? 0uL : 1uL) 221 /** 222 * @} 223 */ 224 225 /** 226 * @} 227 */ 228 229 /* Exported functions --------------------------------------------------------*/ 230 /** 231 * @} 232 */ 233 234 /** 235 * @} 236 */ 237 238 #ifdef __cplusplus 239 } 240 #endif 241 242 #endif /* STM32WB0x_HAL_GPIO_EX_H */ 243