1 /**
2   ******************************************************************************
3   * @file    stm32wbaxx_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 STM32WBAxx_HAL_GPIO_EX_H
21 #define STM32WBAxx_HAL_GPIO_EX_H
22 
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
26 
27 /* Includes ------------------------------------------------------------------*/
28 #include "stm32wbaxx_hal_def.h"
29 
30 /** @addtogroup STM32WBAxx_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 /* Private defines -----------------------------------------------------------*/
42 
43 /** @defgroup GPIOEx_Exported_Constants GPIOEx Exported Constants
44   * @{
45   */
46 
47 /** @defgroup GPIOEx_Alternate_function_selection GPIOEx Alternate function selection
48   * @{
49   */
50 
51 #if defined(STM32WBA54xx) || defined(STM32WBA55xx)
52 /**
53   * @brief   AF 0 selection
54   */
55 #define GPIO_AF0_RTC_50Hz      ((uint8_t)0x00)  /*!< RTC_50Hz Alternate Function mapping           */
56 #define GPIO_AF0_MCO           ((uint8_t)0x00)  /*!< MCO Alternate Function mapping                */
57 #define GPIO_AF0_SWJ           ((uint8_t)0x00)  /*!< SWJ (SWD and JTAG) Alternate Function mapping */
58 #define GPIO_AF0_TRACE         ((uint8_t)0x00)  /*!< TRACE Alternate Function mapping              */
59 #define GPIO_AF0_LPTIM1        ((uint8_t)0x00)  /*!< LPTIM1 Alternate Function mapping             */
60 #define GPIO_AF0_PWR           ((uint8_t)0x00)  /*!< PWR Alternate Function mapping                */
61 
62 /**
63   * @brief   AF 1 selection
64   */
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_IR            ((uint8_t)0x01)  /*!< IR Alternate Function mapping   */
68 
69 /**
70   * @brief   AF 2 selection
71   */
72 #define GPIO_AF2_TIM1          ((uint8_t)0x02)  /*!< TIM1 Alternate Function mapping   */
73 #define GPIO_AF2_TIM2          ((uint8_t)0x02)  /*!< TIM2 Alternate Function mapping   */
74 #define GPIO_AF2_TIM3          ((uint8_t)0x02)  /*!< TIM3 Alternate Function mapping   */
75 #define GPIO_AF2_LPTIM1        ((uint8_t)0x02)  /*!< LPTIM1 Alternate Function mapping */
76 #define GPIO_AF2_LPTIM2        ((uint8_t)0x02)  /*!< LPTIM2 Alternate Function mapping */
77 
78 /**
79   * @brief   AF 3 selection
80   */
81 #define GPIO_AF3_SAI1          ((uint8_t)0x03)  /*!< SAI1 Alternate Function mapping   */
82 #define GPIO_AF3_USART2        ((uint8_t)0x03)  /*!< USART2 Alternate Function mapping */
83 #define GPIO_AF3_IR            ((uint8_t)0x03)  /*!< IR Alternate Function mapping     */
84 
85 /**
86   * @brief   AF 4 selection
87   */
88 #define GPIO_AF4_I2C1          ((uint8_t)0x04)  /*!< I2C1 Alternate Function mapping */
89 #define GPIO_AF4_I2C3          ((uint8_t)0x04)  /*!< I2C3 Alternate Function mapping */
90 
91 /**
92   * @brief   AF 5 selection
93   */
94 #define GPIO_AF5_SPI1          ((uint8_t)0x05)  /*!< SPI1 Alternate Function mapping */
95 
96 /**
97   * @brief   AF 6 selection
98   */
99 #define GPIO_AF6_I2C3          ((uint8_t)0x06)  /*!< I2C3 Alternate Function mapping */
100 #define GPIO_AF6_SPI3          ((uint8_t)0x06)  /*!< SPI3 Alternate Function mapping */
101 
102 /**
103   * @brief   AF 7 selection
104   */
105 #define GPIO_AF7_USART1        ((uint8_t)0x07)  /*!< USART1 Alternate Function mapping */
106 
107 /**
108   * @brief   AF 8 selection
109   */
110 #define GPIO_AF8_LPUART1       ((uint8_t)0x08)  /*!< LPUART1 Alternate Function mapping */
111 
112 /**
113   * @brief   AF 9 selection
114   */
115 #define GPIO_AF9_TSC           ((uint8_t)0x09)  /*!< TSC Alternate Function mapping */
116 
117 /**
118   * @brief   AF 11 selection
119   */
120 #define GPIO_AF11_RF_ANTSW0    ((uint8_t)0x0B)  /*!< RF_ANTSW0 Alternate Function mapping */
121 #define GPIO_AF11_RF_ANTSW1    ((uint8_t)0x0B)  /*!< RF_ANTSW1 Alternate Function mapping */
122 #define GPIO_AF11_RF_ANTSW2    ((uint8_t)0x0B)  /*!< RF_ANTSW2 Alternate Function mapping */
123 #define GPIO_AF11_RF_IO1       ((uint8_t)0x0B)  /*!< RF_IO1 Alternate Function mapping    */
124 #define GPIO_AF11_RF_IO2       ((uint8_t)0x0B)  /*!< RF_IO2 Alternate Function mapping    */
125 #define GPIO_AF11_RF_IO3       ((uint8_t)0x0B)  /*!< RF_IO3 Alternate Function mapping    */
126 #define GPIO_AF11_RF_IO4       ((uint8_t)0x0B)  /*!< RF_IO4 Alternate Function mapping    */
127 #define GPIO_AF11_RF_IO5       ((uint8_t)0x0B)  /*!< RF_IO5 Alternate Function mapping    */
128 #define GPIO_AF11_RF_IO6       ((uint8_t)0x0B)  /*!< RF_IO6 Alternate Function mapping    */
129 #define GPIO_AF11_RF_IO7       ((uint8_t)0x0B)  /*!< RF_IO7 Alternate Function mapping    */
130 #define GPIO_AF11_RF_IO8       ((uint8_t)0x0B)  /*!< RF_IO8 Alternate Function mapping    */
131 #define GPIO_AF11_RF_IO9       ((uint8_t)0x0B)  /*!< RF_IO9 Alternate Function mapping    */
132 
133 /**
134   * @brief   AF 12 selection
135   */
136 #define GPIO_AF12_COMP1        ((uint8_t)0x0C)  /*!< COMP1 Alternate Function mapping */
137 #define GPIO_AF12_COMP2        ((uint8_t)0x0C)  /*!< COMP2 Alternate Function mapping */
138 
139 /**
140   * @brief   AF 13 selection
141   */
142 #define GPIO_AF13_SAI1         ((uint8_t)0x0D)  /*!< SAI1 Alternate Function mapping   */
143 #define GPIO_AF13_LPTIM2       ((uint8_t)0x0D)  /*!< LPTIM2 Alternate Function mapping */
144 
145 /**
146   * @brief   AF 14 selection
147   */
148 #define GPIO_AF14_LPTIM2       ((uint8_t)0x0E)  /*!< LPTIM2 Alternate Function mapping */
149 #define GPIO_AF14_TIM3         ((uint8_t)0x0E)  /*!< TIM3 Alternate Function mapping   */
150 #define GPIO_AF14_TIM16        ((uint8_t)0x0E)  /*!< TIM16 Alternate Function mapping  */
151 #define GPIO_AF14_TIM17        ((uint8_t)0x0E)  /*!< TIM17 Alternate Function mapping  */
152 
153 /**
154   * @brief   AF 15 selection
155   */
156 #define GPIO_AF15_EVENTOUT     ((uint8_t)0x0F)  /*!< EVENTOUT Alternate Function mapping */
157 
158 #define IS_GPIO_AF(AF)         ((AF) <= (uint8_t)0x0F)
159 
160 #endif /* (defined(STM32WBA54xx) || defined(STM32WBA55xx)) */
161 
162 #if defined(STM32WBA52xx)
163 /**
164   * @brief   AF 0 selection
165   */
166 #define GPIO_AF0_RTC_50Hz      ((uint8_t)0x00)  /*!< RTC_50Hz Alternate Function mapping           */
167 #define GPIO_AF0_MCO           ((uint8_t)0x00)  /*!< MCO Alternate Function mapping                */
168 #define GPIO_AF0_SWJ           ((uint8_t)0x00)  /*!< SWJ (SWD and JTAG) Alternate Function mapping */
169 #define GPIO_AF0_TRACE         ((uint8_t)0x00)  /*!< TRACE Alternate Function mapping              */
170 #define GPIO_AF0_LPTIM1        ((uint8_t)0x00)  /*!< LPTIM1 Alternate Function mapping             */
171 #define GPIO_AF0_PWR           ((uint8_t)0x00)  /*!< PWR Alternate Function mapping                */
172 
173 /**
174   * @brief   AF 1 selection
175   */
176 #define GPIO_AF1_TIM1          ((uint8_t)0x01)  /*!< TIM1 Alternate Function mapping */
177 #define GPIO_AF1_TIM2          ((uint8_t)0x01)  /*!< TIM2 Alternate Function mapping */
178 #define GPIO_AF1_IR            ((uint8_t)0x01)  /*!< IR Alternate Function mapping   */
179 
180 /**
181   * @brief   AF 2 selection
182   */
183 #define GPIO_AF2_TIM1          ((uint8_t)0x02)  /*!< TIM1 Alternate Function mapping   */
184 #define GPIO_AF2_TIM2          ((uint8_t)0x02)  /*!< TIM2 Alternate Function mapping   */
185 #define GPIO_AF2_TIM3          ((uint8_t)0x02)  /*!< TIM3 Alternate Function mapping   */
186 #define GPIO_AF2_LPTIM1        ((uint8_t)0x02)  /*!< LPTIM1 Alternate Function mapping */
187 #define GPIO_AF2_LPTIM2        ((uint8_t)0x02)  /*!< LPTIM2 Alternate Function mapping */
188 
189 /**
190   * @brief   AF 3 selection
191   */
192 #define GPIO_AF3_SAI1          ((uint8_t)0x03)  /*!< SAI1 Alternate Function mapping   */
193 #define GPIO_AF3_USART2        ((uint8_t)0x03)  /*!< USART2 Alternate Function mapping */
194 #define GPIO_AF3_IR            ((uint8_t)0x03)  /*!< IR Alternate Function mapping     */
195 
196 /**
197   * @brief   AF 4 selection
198   */
199 #define GPIO_AF4_I2C1          ((uint8_t)0x04)  /*!< I2C1 Alternate Function mapping */
200 #define GPIO_AF4_I2C3          ((uint8_t)0x04)  /*!< I2C3 Alternate Function mapping */
201 
202 /**
203   * @brief   AF 5 selection
204   */
205 #define GPIO_AF5_SPI1          ((uint8_t)0x05)  /*!< SPI1 Alternate Function mapping */
206 
207 /**
208   * @brief   AF 6 selection
209   */
210 #define GPIO_AF6_I2C3          ((uint8_t)0x06)  /*!< I2C3 Alternate Function mapping */
211 #define GPIO_AF6_SPI3          ((uint8_t)0x06)  /*!< SPI3 Alternate Function mapping */
212 
213 /**
214   * @brief   AF 7 selection
215   */
216 #define GPIO_AF7_USART1        ((uint8_t)0x07)  /*!< USART1 Alternate Function mapping */
217 
218 /**
219   * @brief   AF 8 selection
220   */
221 #define GPIO_AF8_LPUART1       ((uint8_t)0x08)  /*!< LPUART1 Alternate Function mapping */
222 
223 /**
224   * @brief   AF 9 selection
225   */
226 #define GPIO_AF9_TSC           ((uint8_t)0x09)  /*!< TSC Alternate Function mapping */
227 
228 /**
229   * @brief   AF 11 selection
230   */
231 #define GPIO_AF11_RF_ANTSW0    ((uint8_t)0x0B)  /*!< RF_ANTSW0 Alternate Function mapping */
232 #define GPIO_AF11_RF_ANTSW1    ((uint8_t)0x0B)  /*!< RF_ANTSW1 Alternate Function mapping */
233 #define GPIO_AF11_RF_ANTSW2    ((uint8_t)0x0B)  /*!< RF_ANTSW2 Alternate Function mapping */
234 #define GPIO_AF11_RF_IO1       ((uint8_t)0x0B)  /*!< RF_IO1 Alternate Function mapping    */
235 #define GPIO_AF11_RF_IO2       ((uint8_t)0x0B)  /*!< RF_IO2 Alternate Function mapping    */
236 #define GPIO_AF11_RF_IO3       ((uint8_t)0x0B)  /*!< RF_IO3 Alternate Function mapping    */
237 #define GPIO_AF11_RF_IO4       ((uint8_t)0x0B)  /*!< RF_IO4 Alternate Function mapping    */
238 #define GPIO_AF11_RF_IO5       ((uint8_t)0x0B)  /*!< RF_IO5 Alternate Function mapping    */
239 #define GPIO_AF11_RF_IO6       ((uint8_t)0x0B)  /*!< RF_IO6 Alternate Function mapping    */
240 #define GPIO_AF11_RF_IO7       ((uint8_t)0x0B)  /*!< RF_IO7 Alternate Function mapping    */
241 #define GPIO_AF11_RF_IO8       ((uint8_t)0x0B)  /*!< RF_IO8 Alternate Function mapping    */
242 #define GPIO_AF11_RF_IO9       ((uint8_t)0x0B)  /*!< RF_IO9 Alternate Function mapping    */
243 
244 /**
245   * @brief   AF 13 selection
246   */
247 #define GPIO_AF13_LPTIM2       ((uint8_t)0x0D)  /*!< LPTIM2 Alternate Function mapping */
248 
249 /**
250   * @brief   AF 14 selection
251   */
252 #define GPIO_AF14_LPTIM2       ((uint8_t)0x0E)  /*!< LPTIM2 Alternate Function mapping */
253 #define GPIO_AF14_TIM3         ((uint8_t)0x0E)  /*!< TIM3 Alternate Function mapping   */
254 #define GPIO_AF14_TIM16        ((uint8_t)0x0E)  /*!< TIM16 Alternate Function mapping  */
255 #define GPIO_AF14_TIM17        ((uint8_t)0x0E)  /*!< TIM17 Alternate Function mapping  */
256 
257 /**
258   * @brief   AF 15 selection
259   */
260 #define GPIO_AF15_EVENTOUT     ((uint8_t)0x0F)  /*!< EVENTOUT Alternate Function mapping */
261 
262 #define IS_GPIO_AF(AF)         ((AF) <= (uint8_t)0x0F)
263 
264 #endif /* (defined(STM32WBA54xx) || defined(STM32WBA55xx)) */
265 
266 #if defined(STM32WBA50xx)
267 /**
268   * @brief   AF 0 selection
269   */
270 #define GPIO_AF0_RTC_50Hz      ((uint8_t)0x00)  /*!< RTC_50Hz Alternate Function mapping           */
271 #define GPIO_AF0_MCO           ((uint8_t)0x00)  /*!< MCO Alternate Function mapping                */
272 #define GPIO_AF0_SWJ           ((uint8_t)0x00)  /*!< SWJ (SWD and JTAG) Alternate Function mapping */
273 #define GPIO_AF0_TRACE         ((uint8_t)0x00)  /*!< TRACE Alternate Function mapping              */
274 #define GPIO_AF0_LPTIM1        ((uint8_t)0x00)  /*!< LPTIM1 Alternate Function mapping             */
275 #define GPIO_AF0_PWR           ((uint8_t)0x00)  /*!< PWR Alternate Function mapping                */
276 
277 /**
278   * @brief   AF 1 selection
279   */
280 #define GPIO_AF1_TIM1          ((uint8_t)0x01)  /*!< TIM1 Alternate Function mapping */
281 #define GPIO_AF1_TIM2          ((uint8_t)0x01)  /*!< TIM2 Alternate Function mapping */
282 
283 /**
284   * @brief   AF 2 selection
285   */
286 #define GPIO_AF2_TIM1          ((uint8_t)0x02)  /*!< TIM1 Alternate Function mapping   */
287 #define GPIO_AF2_TIM2          ((uint8_t)0x02)  /*!< TIM2 Alternate Function mapping   */
288 #define GPIO_AF2_LPTIM1        ((uint8_t)0x02)  /*!< LPTIM1 Alternate Function mapping */
289 
290 /**
291   * @brief   AF 4 selection
292   */
293 #define GPIO_AF4_I2C3          ((uint8_t)0x04)  /*!< I2C3 Alternate Function mapping */
294 
295 /**
296   * @brief   AF 6 selection
297   */
298 #define GPIO_AF6_I2C3          ((uint8_t)0x06)  /*!< I2C3 Alternate Function mapping */
299 #define GPIO_AF6_SPI3          ((uint8_t)0x06)  /*!< SPI3 Alternate Function mapping */
300 
301 /**
302   * @brief   AF 7 selection
303   */
304 #define GPIO_AF7_USART1        ((uint8_t)0x07)  /*!< USART1 Alternate Function mapping */
305 
306 /**
307   * @brief   AF 8 selection
308   */
309 #define GPIO_AF8_LPUART1       ((uint8_t)0x08)  /*!< LPUART1 Alternate Function mapping */
310 
311 /**
312   * @brief   AF 9 selection
313   */
314 #define GPIO_AF9_TSC           ((uint8_t)0x09)  /*!< TSC Alternate Function mapping */
315 
316 /**
317   * @brief   AF 11 selection
318   */
319 #define GPIO_AF11_RF_ANTSW0    ((uint8_t)0x0B)  /*!< RF_ANTSW0 Alternate Function mapping */
320 #define GPIO_AF11_RF_ANTSW1    ((uint8_t)0x0B)  /*!< RF_ANTSW1 Alternate Function mapping */
321 #define GPIO_AF11_RF_ANTSW2    ((uint8_t)0x0B)  /*!< RF_ANTSW2 Alternate Function mapping */
322 #define GPIO_AF11_RF_IO1       ((uint8_t)0x0B)  /*!< RF_IO1 Alternate Function mapping    */
323 #define GPIO_AF11_RF_IO2       ((uint8_t)0x0B)  /*!< RF_IO2 Alternate Function mapping    */
324 #define GPIO_AF11_RF_IO3       ((uint8_t)0x0B)  /*!< RF_IO3 Alternate Function mapping    */
325 #define GPIO_AF11_RF_IO4       ((uint8_t)0x0B)  /*!< RF_IO4 Alternate Function mapping    */
326 #define GPIO_AF11_RF_IO5       ((uint8_t)0x0B)  /*!< RF_IO5 Alternate Function mapping    */
327 #define GPIO_AF11_RF_IO6       ((uint8_t)0x0B)  /*!< RF_IO6 Alternate Function mapping    */
328 #define GPIO_AF11_RF_IO7       ((uint8_t)0x0B)  /*!< RF_IO7 Alternate Function mapping    */
329 #define GPIO_AF11_RF_IO8       ((uint8_t)0x0B)  /*!< RF_IO8 Alternate Function mapping    */
330 #define GPIO_AF11_RF_IO9       ((uint8_t)0x0B)  /*!< RF_IO9 Alternate Function mapping    */
331 
332 /**
333   * @brief   AF 14 selection
334   */
335 #define GPIO_AF14_TIM16        ((uint8_t)0x0E)  /*!< TIM16 Alternate Function mapping */
336 
337 /**
338   * @brief   AF 15 selection
339   */
340 #define GPIO_AF15_EVENTOUT     ((uint8_t)0x0F)  /*!< EVENTOUT Alternate Function mapping */
341 #define GPIO_AF15_RF_DTB0      ((uint8_t)0x0F)  /*!< RF_DTB0 Alternate Function mapping  */
342 #define GPIO_AF15_RF_DTB1      ((uint8_t)0x0F)  /*!< RF_DTB1 Alternate Function mapping  */
343 #define GPIO_AF15_RF_DTB2      ((uint8_t)0x0F)  /*!< RF_DTB2 Alternate Function mapping  */
344 #define GPIO_AF15_RF_DTB3      ((uint8_t)0x0F)  /*!< RF_DTB3 Alternate Function mapping  */
345 #define GPIO_AF15_RF_DTB4      ((uint8_t)0x0F)  /*!< RF_DTB4 Alternate Function mapping  */
346 #define GPIO_AF15_RF_DTB5      ((uint8_t)0x0F)  /*!< RF_DTB5 Alternate Function mapping  */
347 #define GPIO_AF15_RF_DTB6      ((uint8_t)0x0F)  /*!< RF_DTB6 Alternate Function mapping  */
348 #define GPIO_AF15_RF_DTB7      ((uint8_t)0x0F)  /*!< RF_DTB7 Alternate Function mapping  */
349 
350 #define IS_GPIO_AF(AF)         ((AF) <= (uint8_t)0x0F)
351 
352 #endif /* defined(STM32WBA50xx) */
353 /**
354   * @}
355   */
356 
357 /**
358   * @}
359   */
360 
361 /* Exported macro ------------------------------------------------------------*/
362 /** @defgroup GPIOEx_Exported_Macros GPIOEx Exported Macros
363   * @{
364   */
365 
366 /** @defgroup GPIOEx_Get_Port_Index GPIOEx Get Port Index
367   * @{
368   */
369 #define GPIO_GET_INDEX(__GPIOx__)           (((uint32_t )(__GPIOx__) & (~GPIOA_BASE)) >> 10)
370 
371 /**
372   * @}
373   */
374 
375 /**
376   * @}
377   */
378 
379 /* Exported functions --------------------------------------------------------*/
380 /**
381   * @}
382   */
383 
384 /**
385   * @}
386   */
387 
388 #ifdef __cplusplus
389 }
390 #endif
391 
392 #endif /* STM32WBAxx_HAL_GPIO_EX_H */
393 
394