1 /**
2   ******************************************************************************
3   * @file    stm32mp1xx_hal_gpio_ex.h
4   * @author  MCD Application Team
5   * @brief   Header file of GPIO HAL Extension module.
6   ******************************************************************************
7   * @attention
8   *
9   * Copyright (c) 2019 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 __STM32MP1xx_HAL_GPIO_EX_H
21 #define __STM32MP1xx_HAL_GPIO_EX_H
22 
23 #ifdef __cplusplus
24  extern "C" {
25 #endif
26 
27 /* Includes ------------------------------------------------------------------*/
28 #include "stm32mp1xx_hal_def.h"
29 
30 /** @addtogroup STM32MP1xx_HAL_Driver
31   * @{
32   */
33 
34 /** @addtogroup GPIOEx GPIOEx
35   * @{
36   */
37 
38 /* Exported types ------------------------------------------------------------*/
39 
40 /* Exported constants --------------------------------------------------------*/
41 /** @defgroup GPIOEx_Exported_Constants GPIO Exported Constants
42   * @{
43   */
44 
45 /** @defgroup GPIO_Alternate_function_selection GPIO Alternate Function Selection
46   * @{
47   */
48 /**
49   * @brief   AF 0 selection
50   */
51 #define GPIO_AF0_RTC_50Hz      ((uint8_t)0x00)  /* RTC_50Hz Alternate Function mapping                       */
52 #define GPIO_AF0_MCO1          ((uint8_t)0x00)  /* MCO1 Alternate Function mapping                           */
53 #define GPIO_AF0_SWJ           ((uint8_t)0x00)  /* SWJ (SWD and JTAG) Alternate Function mapping             */
54 #define GPIO_AF0_LCDBIAS       ((uint8_t)0x00)  /* LCDBIAS Alternate Function mapping                        */
55 #define GPIO_AF0_TRACE         ((uint8_t)0x00)  /* TRACE Alternate Function mapping                          */
56 #define GPIO_AF0_HDP           ((uint8_t)0x00)  /* HDP Alternate Function mapping                            */
57 
58 /**
59  * @brief   AF 1 selection
60  */
61 #define GPIO_AF1_TIM1          ((uint8_t)0x01)  /* TIM1 Alternate Function mapping */
62 #define GPIO_AF1_TIM2          ((uint8_t)0x01)  /* TIM2 Alternate Function mapping */
63 #define GPIO_AF1_TIM16         ((uint8_t)0x01)  /* TIM16 Alternate Function mapping */
64 #define GPIO_AF1_TIM17         ((uint8_t)0x01)  /* TIM17 Alternate Function mapping */
65 #define GPIO_AF1_LPTIM1        ((uint8_t)0x01)  /* LPTIM1 Alternate Function mapping */
66 #define GPIO_AF1_MCO2          ((uint8_t)0x01)  /* MCO2 Alternate Function mapping */
67 #define GPIO_AF1_RTC           ((uint8_t)0x01)  /* RTC Alternate Function mapping */
68 
69 /**
70   * @brief   AF 2 selection
71   */
72 #define GPIO_AF2_TIM3          ((uint8_t)0x02)  /* TIM3 Alternate Function mapping */
73 #define GPIO_AF2_TIM4          ((uint8_t)0x02)  /* TIM4 Alternate Function mapping */
74 #define GPIO_AF2_TIM5          ((uint8_t)0x02)  /* TIM5 Alternate Function mapping */
75 #define GPIO_AF2_TIM12         ((uint8_t)0x02)  /* TIM12 Alternate Function mapping */
76 #define GPIO_AF2_SAI1          ((uint8_t)0x02)  /* SAI1 Alternate Function mapping */
77 #define GPIO_AF2_SAI4          ((uint8_t)0x02)  /* SAI4 Alternate Function mapping */
78 #define GPIO_AF2_I2C6          ((uint8_t)0x02)  /* I2C6 Alternate Function mapping */
79 #define GPIO_AF2_MCO1          ((uint8_t)0x02)  /* MCO1 Alternate Function mapping */
80 #define GPIO_AF2_MCO2          ((uint8_t)0x02)  /* MCO2 Alternate Function mapping */
81 #define GPIO_AF2_HDP           ((uint8_t)0x02)  /* HDP Alternate Function mapping  */
82 /**
83  * @brief   AF 3 selection
84  */
85 #define GPIO_AF3_TIM8          ((uint8_t)0x03)  /* TIM8 Alternate Function mapping  */
86 #define GPIO_AF3_LPTIM2        ((uint8_t)0x03)  /* LPTIM2 Alternate Function mapping  */
87 #define GPIO_AF3_DFSDM1        ((uint8_t)0x03)  /* DFSDM1 Alternate Function mapping  */
88 #define GPIO_AF3_I2C2          ((uint8_t)0x03)  /* I2C6 Alternate Function mapping */
89 #define GPIO_AF3_LPTIM3        ((uint8_t)0x03)  /* LPTIM3 Alternate Function mapping  */
90 #define GPIO_AF3_LPTIM4        ((uint8_t)0x03)  /* LPTIM4 Alternate Function mapping  */
91 #define GPIO_AF3_LPTIM5        ((uint8_t)0x03)  /* LPTIM5 Alternate Function mapping  */
92 #define GPIO_AF3_SAI4          ((uint8_t)0x03)  /* SAI4 Alternate Function mapping */
93 #define GPIO_AF3_SDIO1         ((uint8_t)0x03)  /* SDIO1 Alternate Function mapping */
94 
95 /**
96  * @brief   AF 4 selection
97  */
98 #define GPIO_AF4_I2C1          ((uint8_t)0x04)  /* I2C1 Alternate Function mapping */
99 #define GPIO_AF4_I2C2          ((uint8_t)0x04)  /* I2C2 Alternate Function mapping */
100 #define GPIO_AF4_I2C3          ((uint8_t)0x04)  /* I2C3 Alternate Function mapping */
101 #define GPIO_AF4_I2C4          ((uint8_t)0x04)  /* I2C4 Alternate Function mapping */
102 #define GPIO_AF4_I2C5          ((uint8_t)0x04)  /* I2C5 Alternate Function mapping */
103 #define GPIO_AF4_TIM15         ((uint8_t)0x04)  /* TIM15 Alternate Function mapping */
104 #define GPIO_AF4_CEC           ((uint8_t)0x04)  /* CEC Alternate Function mapping */
105 #define GPIO_AF4_DFSDM1        ((uint8_t)0x04)  /* DFSDM1  Alternate Function mapping   */
106 #define GPIO_AF4_LPTIM2        ((uint8_t)0x04)  /* LPTIM2 Alternate Function mapping  */
107 #define GPIO_AF4_SAI4          ((uint8_t)0x04)  /* SAI4 Alternate Function mapping */
108 #define GPIO_AF4_USART1        ((uint8_t)0x04)  /* USART1 Alternate Function mapping */
109 
110 /**
111  * @brief   AF 5 selection
112  */
113 #define GPIO_AF5_SPI1          ((uint8_t)0x05)  /* SPI1 Alternate Function mapping   */
114 #define GPIO_AF5_SPI2          ((uint8_t)0x05)  /* SPI2 Alternate Function mapping   */
115 #define GPIO_AF5_SPI3          ((uint8_t)0x05)  /* SPI3 Alternate Function mapping   */
116 #define GPIO_AF5_SPI4          ((uint8_t)0x05)  /* SPI4 Alternate Function mapping   */
117 #define GPIO_AF5_SPI5          ((uint8_t)0x05)  /* SPI5 Alternate Function mapping   */
118 #define GPIO_AF5_SPI6          ((uint8_t)0x05)  /* SPI6 Alternate Function mapping   */
119 #define GPIO_AF5_CEC           ((uint8_t)0x05)  /* CEC  Alternate Function mapping   */
120 #define GPIO_AF5_I2C1          ((uint8_t)0x05)  /* I2C1 Alternate Function mapping */
121 #define GPIO_AF5_SDIO1         ((uint8_t)0x05)  /* SDIO1 Alternate Function mapping */
122 #define GPIO_AF5_SDIO3         ((uint8_t)0x05)  /* SDIO3 Alternate Function mapping */
123 
124 /**
125  * @brief   AF 6 selection
126  */
127 #define GPIO_AF6_SPI3          ((uint8_t)0x06)  /* SPI3 Alternate Function mapping  */
128 #define GPIO_AF6_SAI1          ((uint8_t)0x06)  /* SAI1 Alternate Function mapping  */
129 #define GPIO_AF6_SAI3          ((uint8_t)0x06)  /* SAI3 Alternate Function mapping  */
130 #define GPIO_AF6_SAI4          ((uint8_t)0x06)  /* SAI4 Alternate Function mapping */
131 #define GPIO_AF6_I2C4          ((uint8_t)0x06)  /* I2C4 Alternate Function mapping  */
132 #define GPIO_AF6_DFSDM1        ((uint8_t)0x06)  /* DFSDM1 Alternate Function mapping */
133 #define GPIO_AF6_UART4         ((uint8_t)0x06)  /* UART4 Alternate Function mapping */
134 
135 /**
136  * @brief   AF 7 selection
137  */
138 #define GPIO_AF7_SPI2          ((uint8_t)0x07)  /* SPI2 Alternate Function mapping  */
139 #define GPIO_AF7_SPI3          ((uint8_t)0x07)  /* SPI3 Alternate Function mapping  */
140 #define GPIO_AF7_SPI6          ((uint8_t)0x07)  /* SPI6 Alternate Function mapping  */
141 #define GPIO_AF7_USART1        ((uint8_t)0x07)  /* USART1 Alternate Function mapping     */
142 #define GPIO_AF7_USART2        ((uint8_t)0x07)  /* USART2 Alternate Function mapping     */
143 #define GPIO_AF7_USART3        ((uint8_t)0x07)  /* USART3 Alternate Function mapping     */
144 #define GPIO_AF7_USART6        ((uint8_t)0x07)  /* USART6 Alternate Function mapping     */
145 #define GPIO_AF7_UART7         ((uint8_t)0x07)  /* UART7 Alternate Function mapping     */
146 
147 /**
148  * @brief   AF 8 selection
149  */
150 #define GPIO_AF8_SPI6         ((uint8_t)0x08)  /* SPI6 Alternate Function mapping  */
151 #define GPIO_AF8_SAI2         ((uint8_t)0x08)  /* SAI2 Alternate Function mapping  */
152 #define GPIO_AF8_USART3       ((uint8_t)0x08)  /* USART3 Alternate Function mapping */
153 #define GPIO_AF8_UART4        ((uint8_t)0x08)  /* UART4 Alternate Function mapping */
154 #define GPIO_AF8_UART5        ((uint8_t)0x08)  /* UART5 Alternate Function mapping */
155 #define GPIO_AF8_UART8        ((uint8_t)0x08)  /* UART8 Alternate Function mapping */
156 #define GPIO_AF8_SPDIF        ((uint8_t)0x08)  /* SPDIF Alternate Function mapping */
157 #define GPIO_AF8_SDIO1        ((uint8_t)0x08)  /* SDIO1 Alternate Function mapping */
158 
159 /**
160  * @brief   AF 9 selection
161  */
162 #define GPIO_AF9_QUADSPI       ((uint8_t)0x09)  /* QUADSPI Alternate Function mapping */
163 #if defined (FDCAN1)
164 #define GPIO_AF9_FDCAN1        ((uint8_t)0x09)  /* FDCAN1 Alternate Function mapping    */
165 #endif
166 #if defined (FDCAN2)
167 #define GPIO_AF9_FDCAN2        ((uint8_t)0x09)  /* FDCAN2 Alternate Function mapping    */
168 #endif
169 #define GPIO_AF9_TIM13         ((uint8_t)0x09)  /* TIM13 Alternate Function mapping   */
170 #define GPIO_AF9_TIM14         ((uint8_t)0x09)  /* TIM14 Alternate Function mapping   */
171 #define GPIO_AF9_SDIO2         ((uint8_t)0x09)  /* SDIO2 Alternate Function mapping   */
172 #define GPIO_AF9_LCD           ((uint8_t)0x09)  /* LCD Alternate Function mapping   */
173 #define GPIO_AF9_SPDIF         ((uint8_t)0x09)  /* SPDIF Alternate Function mapping   */
174 #define GPIO_AF9_SDIO3         ((uint8_t)0x09)  /* SDIO3 Alternate Function mapping   */
175 #define GPIO_AF9_SDIO2         ((uint8_t)0x09)  /* SDIO3 Alternate Function mapping   */
176 
177 /**
178  * @brief   AF 10 selection
179  */
180 #define GPIO_AF10_QUADSPI       ((uint8_t)0xA)  /* QUADSPI Alternate Function mapping */
181 #define GPIO_AF10_SAI2          ((uint8_t)0xA)  /* SAI2 Alternate Function mapping */
182 #define GPIO_AF10_SAI4          ((uint8_t)0xA)  /* SAI4 Alternate Function mapping */
183 #define GPIO_AF10_SDIO2         ((uint8_t)0xA)  /* SDIO2 Alternate Function mapping */
184 #define GPIO_AF10_SDIO3         ((uint8_t)0xA)  /* SDIO3 Alternate Function mapping */
185 #define GPIO_AF10_OTG2_HS       ((uint8_t)0xA)  /* OTG2_HS Alternate Function mapping */
186 #define GPIO_AF10_OTG1_FS       ((uint8_t)0xA)  /* OTG1_FS Alternate Function mapping */
187 
188 /**
189  * @brief   AF 11 selection
190  */
191 #define GPIO_AF11_DFSDM1        ((uint8_t)0x0B)  /* DFSDM1 Alternate Function mapping */
192 #define GPIO_AF11_QUADSPI       ((uint8_t)0x0B)  /* QUADSPI Alternate Function mapping */
193 #define GPIO_AF11_ETH           ((uint8_t)0x0B)  /* ETH Alternate Function mapping */
194 #if defined (DSI)
195 #define GPIO_AF11_DSI           ((uint8_t)0x0B)  /* DSI Alternate Function mapping */
196 #endif
197 #define GPIO_AF11_SDIO1         ((uint8_t)0x0B)  /* SDIO1 Alternate Function mapping */
198 
199 /**
200  * @brief   AF 12 selection
201  */
202 #define GPIO_AF12_UART5         ((uint8_t)0xC)  /* UART5 Alternate Function mapping */
203 #define GPIO_AF12_FMC           ((uint8_t)0xC)  /* FMC Alternate Function mapping     */
204 #define GPIO_AF12_SDIO1         ((uint8_t)0xC)  /* SDIO1 Alternate Function mapping  */
205 #define GPIO_AF12_MDIOS         ((uint8_t)0xC)  /* MDIOS Alternate Function mapping   */
206 #define GPIO_AF12_SAI4          ((uint8_t)0xC)  /* SAI4 Alternate Function mapping */
207 #define GPIO_AF12_SDIO1         ((uint8_t)0xC)  /* SAI4 Alternate Function mapping */
208 
209 /**
210  * @brief   AF 13 selection
211  */
212 #define GPIO_AF13_UART7         ((uint8_t)0x0D)   /* UART7 Alternate Function mapping */
213 #define GPIO_AF13_DCMI          ((uint8_t)0x0D)   /* DCMI Alternate Function mapping */
214 #define GPIO_AF13_LCD           ((uint8_t)0x0D)   /* LCD Alternate Function mapping */
215 #if defined (DSI)
216 #define GPIO_AF13_DSI           ((uint8_t)0x0D)   /* DSI Alternate Function mapping */
217 #endif
218 #define GPIO_AF13_RNG           ((uint8_t)0x0D)   /* RNG Alternate Function mapping */
219 
220 
221 /**
222  * @brief   AF 14 selection
223  */
224 #define GPIO_AF14_UART5        ((uint8_t)0x0E)   /* UART5 Alternate Function mapping */
225 #define GPIO_AF14_LCD          ((uint8_t)0x0E)   /* LCD Alternate Function mapping */
226 
227 /**
228   * @brief   AF 15 selection
229   */
230 #define GPIO_AF15_EVENTOUT      ((uint8_t)0x0F)  /* EVENTOUT Alternate Function mapping */
231 
232 #define IS_GPIO_AF(AF)   ((AF) <= (uint8_t)0x0F)
233 
234 
235 
236 /**
237   * @}
238   */
239 
240 /**
241   * @}
242   */
243 
244 /* Exported macro ------------------------------------------------------------*/
245 /* Exported functions --------------------------------------------------------*/
246 /* Private types -------------------------------------------------------------*/
247 /* Private variables ---------------------------------------------------------*/
248 /* Private constants ---------------------------------------------------------*/
249 /* Private macros ------------------------------------------------------------*/
250 /** @defgroup GPIOEx_Private_Macros GPIO Private Macros
251   * @{
252   */
253 /** @defgroup GPIOEx_Get_Port_Index GPIO Get Port Index
254   * @{
255   */
256 #define GPIO_GET_INDEX(__GPIOx__)   (uint8_t)(((__GPIOx__) == (GPIOA))? 0U :\
257                                               ((__GPIOx__) == (GPIOB))? 1U :\
258                                               ((__GPIOx__) == (GPIOC))? 2U :\
259                                               ((__GPIOx__) == (GPIOD))? 3U :\
260                                               ((__GPIOx__) == (GPIOE))? 4U :\
261                                               ((__GPIOx__) == (GPIOF))? 5U :\
262                                               ((__GPIOx__) == (GPIOG))? 6U :\
263                                               ((__GPIOx__) == (GPIOH))? 7U :\
264                                               ((__GPIOx__) == (GPIOI))? 8U :\
265                                               ((__GPIOx__) == (GPIOJ))? 9U :\
266                                               ((__GPIOx__) == (GPIOK))? 10U :\
267                                               ((__GPIOx__) == (GPIOZ))? 11U : 25U)
268 /**
269   * @}
270   */
271 
272 /**
273   * @}
274   */
275 
276 /* Private functions ---------------------------------------------------------*/
277 
278 /* Exported functions --------------------------------------------------------*/
279 /** @addtogroup GPIOEx_Exported_Functions GPIO Extended Exported Functions
280   * @{
281   */
282 
283 /** @addtogroup GPIOEx_Exported_Functions_Group1 Extended Peripheral Control functions
284  * @{
285  */
286 
287 void                HAL_GPIOEx_SecurePin(GPIO_TypeDef  *GPIOx, uint16_t GPIO_Pin);
288 void                HAL_GPIOEx_NonSecurePin(GPIO_TypeDef  *GPIOx, uint16_t GPIO_Pin);
289 
290 
291 GPIO_PinState       HAL_GPIOEx_IsPinSecured(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin);
292 
293 /**
294   * @}
295   */
296 
297 /**
298   * @}
299   */
300 
301 
302 /**
303   * @}
304   */
305 
306 /**
307   * @}
308   */
309 
310 #ifdef __cplusplus
311 }
312 #endif
313 
314 #endif /* __STM32MP1xx_HAL_GPIO_EX_H */
315