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) || defined(STM32WBA5Mxx)
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          ((uint8_t)0x0B)  /*!< RF_ANTSW0 Alternate Function mapping */
121 
122 /**
123   * @brief   AF 12 selection
124   */
125 #define GPIO_AF12_COMP1        ((uint8_t)0x0C)  /*!< COMP1 Alternate Function mapping */
126 #define GPIO_AF12_COMP2        ((uint8_t)0x0C)  /*!< COMP2 Alternate Function mapping */
127 
128 /**
129   * @brief   AF 13 selection
130   */
131 #define GPIO_AF13_SAI1         ((uint8_t)0x0D)  /*!< SAI1 Alternate Function mapping   */
132 #define GPIO_AF13_LPTIM2       ((uint8_t)0x0D)  /*!< LPTIM2 Alternate Function mapping */
133 
134 /**
135   * @brief   AF 14 selection
136   */
137 #define GPIO_AF14_LPTIM2       ((uint8_t)0x0E)  /*!< LPTIM2 Alternate Function mapping */
138 #define GPIO_AF14_TIM3         ((uint8_t)0x0E)  /*!< TIM3 Alternate Function mapping   */
139 #define GPIO_AF14_TIM16        ((uint8_t)0x0E)  /*!< TIM16 Alternate Function mapping  */
140 #define GPIO_AF14_TIM17        ((uint8_t)0x0E)  /*!< TIM17 Alternate Function mapping  */
141 
142 /**
143   * @brief   AF 15 selection
144   */
145 #define GPIO_AF15_EVENTOUT     ((uint8_t)0x0F)  /*!< EVENTOUT Alternate Function mapping */
146 
147 #define IS_GPIO_AF(AF)         ((AF) <= (uint8_t)0x0F)
148 
149 #endif /* (defined(STM32WBA54xx) || defined(STM32WBA55xx) || defined(STM32WBA5Mxx)) */
150 
151 #if defined(STM32WBA52xx)
152 /**
153   * @brief   AF 0 selection
154   */
155 #define GPIO_AF0_RTC_50Hz      ((uint8_t)0x00)  /*!< RTC_50Hz Alternate Function mapping           */
156 #define GPIO_AF0_MCO           ((uint8_t)0x00)  /*!< MCO Alternate Function mapping                */
157 #define GPIO_AF0_SWJ           ((uint8_t)0x00)  /*!< SWJ (SWD and JTAG) Alternate Function mapping */
158 #define GPIO_AF0_TRACE         ((uint8_t)0x00)  /*!< TRACE Alternate Function mapping              */
159 #define GPIO_AF0_LPTIM1        ((uint8_t)0x00)  /*!< LPTIM1 Alternate Function mapping             */
160 #define GPIO_AF0_PWR           ((uint8_t)0x00)  /*!< PWR Alternate Function mapping                */
161 
162 /**
163   * @brief   AF 1 selection
164   */
165 #define GPIO_AF1_TIM1          ((uint8_t)0x01)  /*!< TIM1 Alternate Function mapping */
166 #define GPIO_AF1_TIM2          ((uint8_t)0x01)  /*!< TIM2 Alternate Function mapping */
167 #define GPIO_AF1_IR            ((uint8_t)0x01)  /*!< IR Alternate Function mapping   */
168 
169 /**
170   * @brief   AF 2 selection
171   */
172 #define GPIO_AF2_TIM1          ((uint8_t)0x02)  /*!< TIM1 Alternate Function mapping   */
173 #define GPIO_AF2_TIM2          ((uint8_t)0x02)  /*!< TIM2 Alternate Function mapping   */
174 #define GPIO_AF2_TIM3          ((uint8_t)0x02)  /*!< TIM3 Alternate Function mapping   */
175 #define GPIO_AF2_LPTIM1        ((uint8_t)0x02)  /*!< LPTIM1 Alternate Function mapping */
176 #define GPIO_AF2_LPTIM2        ((uint8_t)0x02)  /*!< LPTIM2 Alternate Function mapping */
177 
178 /**
179   * @brief   AF 3 selection
180   */
181 #define GPIO_AF3_SAI1          ((uint8_t)0x03)  /*!< SAI1 Alternate Function mapping   */
182 #define GPIO_AF3_USART2        ((uint8_t)0x03)  /*!< USART2 Alternate Function mapping */
183 #define GPIO_AF3_IR            ((uint8_t)0x03)  /*!< IR Alternate Function mapping     */
184 
185 /**
186   * @brief   AF 4 selection
187   */
188 #define GPIO_AF4_I2C1          ((uint8_t)0x04)  /*!< I2C1 Alternate Function mapping */
189 #define GPIO_AF4_I2C3          ((uint8_t)0x04)  /*!< I2C3 Alternate Function mapping */
190 
191 /**
192   * @brief   AF 5 selection
193   */
194 #define GPIO_AF5_SPI1          ((uint8_t)0x05)  /*!< SPI1 Alternate Function mapping */
195 
196 /**
197   * @brief   AF 6 selection
198   */
199 #define GPIO_AF6_I2C3          ((uint8_t)0x06)  /*!< I2C3 Alternate Function mapping */
200 #define GPIO_AF6_SPI3          ((uint8_t)0x06)  /*!< SPI3 Alternate Function mapping */
201 
202 /**
203   * @brief   AF 7 selection
204   */
205 #define GPIO_AF7_USART1        ((uint8_t)0x07)  /*!< USART1 Alternate Function mapping */
206 
207 /**
208   * @brief   AF 8 selection
209   */
210 #define GPIO_AF8_LPUART1       ((uint8_t)0x08)  /*!< LPUART1 Alternate Function mapping */
211 
212 /**
213   * @brief   AF 9 selection
214   */
215 #define GPIO_AF9_TSC           ((uint8_t)0x09)  /*!< TSC Alternate Function mapping */
216 
217 /**
218   * @brief   AF 11 selection
219   */
220 #define GPIO_AF11_RF          ((uint8_t)0x0B)  /*!< RF_ANTSW0 Alternate Function mapping */
221 
222 /**
223   * @brief   AF 13 selection
224   */
225 #define GPIO_AF13_LPTIM2       ((uint8_t)0x0D)  /*!< LPTIM2 Alternate Function mapping */
226 
227 /**
228   * @brief   AF 14 selection
229   */
230 #define GPIO_AF14_LPTIM2       ((uint8_t)0x0E)  /*!< LPTIM2 Alternate Function mapping */
231 #define GPIO_AF14_TIM3         ((uint8_t)0x0E)  /*!< TIM3 Alternate Function mapping   */
232 #define GPIO_AF14_TIM16        ((uint8_t)0x0E)  /*!< TIM16 Alternate Function mapping  */
233 #define GPIO_AF14_TIM17        ((uint8_t)0x0E)  /*!< TIM17 Alternate Function mapping  */
234 
235 /**
236   * @brief   AF 15 selection
237   */
238 #define GPIO_AF15_EVENTOUT     ((uint8_t)0x0F)  /*!< EVENTOUT Alternate Function mapping */
239 
240 #define IS_GPIO_AF(AF)         ((AF) <= (uint8_t)0x0F)
241 
242 #endif /* defined(STM32WBA52xx) */
243 
244 #if defined(STM32WBA50xx)
245 /**
246   * @brief   AF 0 selection
247   */
248 #define GPIO_AF0_RTC_50Hz      ((uint8_t)0x00)  /*!< RTC_50Hz Alternate Function mapping           */
249 #define GPIO_AF0_MCO           ((uint8_t)0x00)  /*!< MCO Alternate Function mapping                */
250 #define GPIO_AF0_SWJ           ((uint8_t)0x00)  /*!< SWJ (SWD and JTAG) Alternate Function mapping */
251 #define GPIO_AF0_TRACE         ((uint8_t)0x00)  /*!< TRACE Alternate Function mapping              */
252 #define GPIO_AF0_LPTIM1        ((uint8_t)0x00)  /*!< LPTIM1 Alternate Function mapping             */
253 #define GPIO_AF0_PWR           ((uint8_t)0x00)  /*!< PWR Alternate Function mapping                */
254 
255 /**
256   * @brief   AF 1 selection
257   */
258 #define GPIO_AF1_TIM1          ((uint8_t)0x01)  /*!< TIM1 Alternate Function mapping */
259 #define GPIO_AF1_TIM2          ((uint8_t)0x01)  /*!< TIM2 Alternate Function mapping */
260 
261 /**
262   * @brief   AF 2 selection
263   */
264 #define GPIO_AF2_TIM1          ((uint8_t)0x02)  /*!< TIM1 Alternate Function mapping   */
265 #define GPIO_AF2_TIM2          ((uint8_t)0x02)  /*!< TIM2 Alternate Function mapping   */
266 #define GPIO_AF2_LPTIM1        ((uint8_t)0x02)  /*!< LPTIM1 Alternate Function mapping */
267 
268 /**
269   * @brief   AF 4 selection
270   */
271 #define GPIO_AF4_I2C3          ((uint8_t)0x04)  /*!< I2C3 Alternate Function mapping */
272 
273 /**
274   * @brief   AF 6 selection
275   */
276 #define GPIO_AF6_I2C3          ((uint8_t)0x06)  /*!< I2C3 Alternate Function mapping */
277 #define GPIO_AF6_SPI3          ((uint8_t)0x06)  /*!< SPI3 Alternate Function mapping */
278 
279 /**
280   * @brief   AF 7 selection
281   */
282 #define GPIO_AF7_USART1        ((uint8_t)0x07)  /*!< USART1 Alternate Function mapping */
283 
284 /**
285   * @brief   AF 8 selection
286   */
287 #define GPIO_AF8_LPUART1       ((uint8_t)0x08)  /*!< LPUART1 Alternate Function mapping */
288 
289 /**
290   * @brief   AF 9 selection
291   */
292 #define GPIO_AF9_TSC           ((uint8_t)0x09)  /*!< TSC Alternate Function mapping */
293 
294 /**
295   * @brief   AF 11 selection
296   */
297 #define GPIO_AF11_RF          ((uint8_t)0x0B)  /*!< RF_ANTSW0 Alternate Function mapping */
298 
299 /**
300   * @brief   AF 14 selection
301   */
302 #define GPIO_AF14_TIM16        ((uint8_t)0x0E)  /*!< TIM16 Alternate Function mapping */
303 
304 /**
305   * @brief   AF 15 selection
306   */
307 #define GPIO_AF15_EVENTOUT     ((uint8_t)0x0F)  /*!< EVENTOUT Alternate Function mapping */
308 #define GPIO_AF15_RF_DTB0      ((uint8_t)0x0F)  /*!< RF_DTB0 Alternate Function mapping  */
309 #define GPIO_AF15_RF_DTB1      ((uint8_t)0x0F)  /*!< RF_DTB1 Alternate Function mapping  */
310 #define GPIO_AF15_RF_DTB2      ((uint8_t)0x0F)  /*!< RF_DTB2 Alternate Function mapping  */
311 #define GPIO_AF15_RF_DTB3      ((uint8_t)0x0F)  /*!< RF_DTB3 Alternate Function mapping  */
312 #define GPIO_AF15_RF_DTB4      ((uint8_t)0x0F)  /*!< RF_DTB4 Alternate Function mapping  */
313 #define GPIO_AF15_RF_DTB5      ((uint8_t)0x0F)  /*!< RF_DTB5 Alternate Function mapping  */
314 #define GPIO_AF15_RF_DTB6      ((uint8_t)0x0F)  /*!< RF_DTB6 Alternate Function mapping  */
315 #define GPIO_AF15_RF_DTB7      ((uint8_t)0x0F)  /*!< RF_DTB7 Alternate Function mapping  */
316 
317 #define IS_GPIO_AF(AF)         ((AF) <= (uint8_t)0x0F)
318 
319 #endif /* defined(STM32WBA50xx) */
320 
321 /**
322   * @}
323   */
324 
325 /**
326   * @}
327   */
328 
329 /* Exported macro ------------------------------------------------------------*/
330 /** @defgroup GPIOEx_Exported_Macros GPIOEx Exported Macros
331   * @{
332   */
333 
334 /** @defgroup GPIOEx_Get_Port_Index GPIOEx Get Port Index
335   * @{
336   */
337 #define GPIO_GET_INDEX(__GPIOx__)           (((uint32_t )(__GPIOx__) & (~GPIOA_BASE)) >> 10)
338 
339 /**
340   * @}
341   */
342 
343 /**
344   * @}
345   */
346 
347 /**
348   * @}
349   */
350 
351 /* Exported functions --------------------------------------------------------*/
352 /**
353   * @}
354   */
355 
356 /**
357   * @}
358   */
359 
360 #ifdef __cplusplus
361 }
362 #endif
363 
364 #endif /* STM32WBAxx_HAL_GPIO_EX_H */
365 
366