You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

346 lines
16 KiB

  1. /**
  2. ******************************************************************************
  3. * @file stm32h7xx_hal_gpio_ex.h
  4. * @author MCD Application Team
  5. * @brief Header file of GPIO HAL Extension module.
  6. ******************************************************************************
  7. * @attention
  8. *
  9. * <h2><center>&copy; COPYRIGHT(c) 2017 STMicroelectronics.
  10. * All rights reserved.</center></h2>
  11. *
  12. * This software component is licensed by ST under BSD 3-Clause license,
  13. * the "License"; You may not use this file except in compliance with the
  14. * License. You may obtain a copy of the License at:
  15. * opensource.org/licenses/BSD-3-Clause
  16. *
  17. ******************************************************************************
  18. */
  19. /* Define to prevent recursive inclusion -------------------------------------*/
  20. #ifndef STM32H7xx_HAL_GPIO_EX_H
  21. #define STM32H7xx_HAL_GPIO_EX_H
  22. #ifdef __cplusplus
  23. extern "C" {
  24. #endif
  25. /* Includes ------------------------------------------------------------------*/
  26. #include "stm32h7xx_hal_def.h"
  27. /** @addtogroup STM32H7xx_HAL_Driver
  28. * @{
  29. */
  30. /** @addtogroup GPIOEx GPIOEx
  31. * @{
  32. */
  33. /* Exported types ------------------------------------------------------------*/
  34. /* Exported constants --------------------------------------------------------*/
  35. /** @defgroup GPIOEx_Exported_Constants GPIO Exported Constants
  36. * @{
  37. */
  38. /** @defgroup GPIO_Alternate_function_selection GPIO Alternate Function Selection
  39. * @{
  40. */
  41. /**
  42. * @brief AF 0 selection
  43. */
  44. #define GPIO_AF0_RTC_50Hz ((uint8_t)0x00) /* RTC_50Hz Alternate Function mapping */
  45. #define GPIO_AF0_MCO ((uint8_t)0x00) /* MCO (MCO1 and MCO2) Alternate Function mapping */
  46. #define GPIO_AF0_SWJ ((uint8_t)0x00) /* SWJ (SWD and JTAG) Alternate Function mapping */
  47. #define GPIO_AF0_LCDBIAS ((uint8_t)0x00) /* LCDBIAS Alternate Function mapping */
  48. #define GPIO_AF0_TRACE ((uint8_t)0x00) /* TRACE Alternate Function mapping */
  49. #define GPIO_AF0_C1DSLEEP ((uint8_t)0x00) /* Cortex-M7 Deep Sleep Alternate Function mapping : available on STM32H7 Rev.B and above */
  50. #define GPIO_AF0_C1SLEEP ((uint8_t)0x00) /* Cortex-M7 Sleep Alternate Function mapping : available on STM32H7 Rev.B and above */
  51. #define GPIO_AF0_D1PWREN ((uint8_t)0x00) /* Domain 1 PWR enable Alternate Function mapping : available on STM32H7 Rev.B and above */
  52. #define GPIO_AF0_D2PWREN ((uint8_t)0x00) /* Domain 2 PWR enable Alternate Function mapping : available on STM32H7 Rev.B and above */
  53. #if defined(DUAL_CORE)
  54. #define GPIO_AF0_C2DSLEEP ((uint8_t)0x00) /* Cortex-M4 Deep Sleep Alternate Function mapping : available on STM32H7 Rev.B and above */
  55. #define GPIO_AF0_C2SLEEP ((uint8_t)0x00) /* Cortex-M4 Sleep Alternate Function mapping : available on STM32H7 Rev.B and above */
  56. #endif /* DUAL_CORE */
  57. /**
  58. * @brief AF 1 selection
  59. */
  60. #define GPIO_AF1_TIM1 ((uint8_t)0x01) /* TIM1 Alternate Function mapping */
  61. #define GPIO_AF1_TIM2 ((uint8_t)0x01) /* TIM2 Alternate Function mapping */
  62. #define GPIO_AF1_TIM16 ((uint8_t)0x01) /* TIM16 Alternate Function mapping */
  63. #define GPIO_AF1_TIM17 ((uint8_t)0x01) /* TIM17 Alternate Function mapping */
  64. #define GPIO_AF1_LPTIM1 ((uint8_t)0x01) /* LPTIM1 Alternate Function mapping */
  65. #define GPIO_AF1_HRTIM1 ((uint8_t)0x01) /* HRTIM1 Alternate Function mapping */
  66. /**
  67. * @brief AF 2 selection
  68. */
  69. #define GPIO_AF2_TIM3 ((uint8_t)0x02) /* TIM3 Alternate Function mapping */
  70. #define GPIO_AF2_TIM4 ((uint8_t)0x02) /* TIM4 Alternate Function mapping */
  71. #define GPIO_AF2_TIM5 ((uint8_t)0x02) /* TIM5 Alternate Function mapping */
  72. #define GPIO_AF2_TIM12 ((uint8_t)0x02) /* TIM12 Alternate Function mapping */
  73. #define GPIO_AF2_HRTIM1 ((uint8_t)0x02) /* HRTIM2 Alternate Function mapping */
  74. #define GPIO_AF2_SAI1 ((uint8_t)0x02) /* SAI1 Alternate Function mapping */
  75. /**
  76. * @brief AF 3 selection
  77. */
  78. #define GPIO_AF3_TIM8 ((uint8_t)0x03) /* TIM8 Alternate Function mapping */
  79. #define GPIO_AF3_LPTIM2 ((uint8_t)0x03) /* LPTIM2 Alternate Function mapping */
  80. #define GPIO_AF3_DFSDM1 ((uint8_t)0x03) /* DFSDM Alternate Function mapping */
  81. #define GPIO_AF3_HRTIM1 ((uint8_t)0x03) /* HRTIM3 Alternate Function mapping */
  82. #define GPIO_AF3_LPTIM3 ((uint8_t)0x03) /* LPTIM3 Alternate Function mapping */
  83. #define GPIO_AF3_LPTIM4 ((uint8_t)0x03) /* LPTIM4 Alternate Function mapping */
  84. #define GPIO_AF3_LPTIM5 ((uint8_t)0x03) /* LPTIM5 Alternate Function mapping */
  85. #define GPIO_AF3_LPUART ((uint8_t)0x03) /* LPUART Alternate Function mapping */
  86. /**
  87. * @brief AF 4 selection
  88. */
  89. #define GPIO_AF4_I2C1 ((uint8_t)0x04) /* I2C1 Alternate Function mapping */
  90. #define GPIO_AF4_I2C2 ((uint8_t)0x04) /* I2C2 Alternate Function mapping */
  91. #define GPIO_AF4_I2C3 ((uint8_t)0x04) /* I2C3 Alternate Function mapping */
  92. #define GPIO_AF4_I2C4 ((uint8_t)0x04) /* I2C4 Alternate Function mapping */
  93. #define GPIO_AF4_TIM15 ((uint8_t)0x04) /* TIM15 Alternate Function mapping */
  94. #define GPIO_AF4_CEC ((uint8_t)0x04) /* CEC Alternate Function mapping */
  95. #define GPIO_AF4_LPTIM2 ((uint8_t)0x04) /* LPTIM2 Alternate Function mapping */
  96. #define GPIO_AF4_USART1 ((uint8_t)0x04) /* USART1 Alternate Function mapping */
  97. #define GPIO_AF4_DFSDM1 ((uint8_t)0x04) /* DFSDM Alternate Function mapping */
  98. /**
  99. * @brief AF 5 selection
  100. */
  101. #define GPIO_AF5_SPI1 ((uint8_t)0x05) /* SPI1 Alternate Function mapping */
  102. #define GPIO_AF5_SPI2 ((uint8_t)0x05) /* SPI2 Alternate Function mapping */
  103. #define GPIO_AF5_SPI3 ((uint8_t)0x05) /* SPI3 Alternate Function mapping */
  104. #define GPIO_AF5_SPI4 ((uint8_t)0x05) /* SPI4 Alternate Function mapping */
  105. #define GPIO_AF5_SPI5 ((uint8_t)0x05) /* SPI5 Alternate Function mapping */
  106. #define GPIO_AF5_SPI6 ((uint8_t)0x05) /* SPI6 Alternate Function mapping */
  107. #define GPIO_AF5_CEC ((uint8_t)0x05) /* CEC Alternate Function mapping */
  108. /**
  109. * @brief AF 6 selection
  110. */
  111. #define GPIO_AF6_SPI2 ((uint8_t)0x06) /* SPI2 Alternate Function mapping */
  112. #define GPIO_AF6_SPI3 ((uint8_t)0x06) /* SPI3 Alternate Function mapping */
  113. #define GPIO_AF6_SAI1 ((uint8_t)0x06) /* SAI1 Alternate Function mapping */
  114. #define GPIO_AF6_SAI3 ((uint8_t)0x06) /* SAI3 Alternate Function mapping */
  115. #define GPIO_AF6_I2C4 ((uint8_t)0x06) /* I2C4 Alternate Function mapping */
  116. #define GPIO_AF6_DFSDM1 ((uint8_t)0x06) /* DFSDM Alternate Function mapping */
  117. #define GPIO_AF6_UART4 ((uint8_t)0x06) /* UART4 Alternate Function mapping */
  118. /**
  119. * @brief AF 7 selection
  120. */
  121. #define GPIO_AF7_SPI2 ((uint8_t)0x07) /* SPI2 Alternate Function mapping */
  122. #define GPIO_AF7_SPI3 ((uint8_t)0x07) /* SPI3 Alternate Function mapping */
  123. #define GPIO_AF7_SPI6 ((uint8_t)0x07) /* SPI6 Alternate Function mapping */
  124. #define GPIO_AF7_USART1 ((uint8_t)0x07) /* USART1 Alternate Function mapping */
  125. #define GPIO_AF7_USART2 ((uint8_t)0x07) /* USART2 Alternate Function mapping */
  126. #define GPIO_AF7_USART3 ((uint8_t)0x07) /* USART3 Alternate Function mapping */
  127. #define GPIO_AF7_USART6 ((uint8_t)0x07) /* USART6 Alternate Function mapping */
  128. #define GPIO_AF7_UART7 ((uint8_t)0x07) /* UART7 Alternate Function mapping */
  129. #define GPIO_AF7_DFSDM1 ((uint8_t)0x07) /* DFSDM Alternate Function mapping */
  130. #define GPIO_AF7_SDMMC1 ((uint8_t)0x07) /* SDMMC1 Alternate Function mapping */
  131. /**
  132. * @brief AF 8 selection
  133. */
  134. #define GPIO_AF8_SPI6 ((uint8_t)0x08) /* SPI6 Alternate Function mapping */
  135. #define GPIO_AF8_SAI2 ((uint8_t)0x08) /* SAI2 Alternate Function mapping */
  136. #define GPIO_AF8_SAI4 ((uint8_t)0x08) /* SAI4 Alternate Function mapping */
  137. #define GPIO_AF8_UART4 ((uint8_t)0x08) /* UART4 Alternate Function mapping */
  138. #define GPIO_AF8_UART5 ((uint8_t)0x08) /* UART5 Alternate Function mapping */
  139. #define GPIO_AF8_UART8 ((uint8_t)0x08) /* UART8 Alternate Function mapping */
  140. #define GPIO_AF8_SPDIF ((uint8_t)0x08) /* SPDIF Alternate Function mapping */
  141. #define GPIO_AF8_LPUART ((uint8_t)0x08) /* LPUART Alternate Function mapping */
  142. #define GPIO_AF8_SDMMC1 ((uint8_t)0x08) /* SDMMC1 Alternate Function mapping */
  143. /**
  144. * @brief AF 9 selection
  145. */
  146. #define GPIO_AF9_FDCAN1 ((uint8_t)0x09) /* FDCAN1 Alternate Function mapping */
  147. #define GPIO_AF9_FDCAN2 ((uint8_t)0x09) /* FDCAN2 Alternate Function mapping */
  148. #define GPIO_AF9_TIM13 ((uint8_t)0x09) /* TIM13 Alternate Function mapping */
  149. #define GPIO_AF9_TIM14 ((uint8_t)0x09) /* TIM14 Alternate Function mapping */
  150. #define GPIO_AF9_QUADSPI ((uint8_t)0x09) /* QUADSPI Alternate Function mapping */
  151. #define GPIO_AF9_SDMMC2 ((uint8_t)0x09) /* SDMMC2 Alternate Function mapping */
  152. #define GPIO_AF9_LTDC ((uint8_t)0x09) /* LTDC Alternate Function mapping */
  153. #define GPIO_AF9_SPDIF ((uint8_t)0x09) /* SPDIF Alternate Function mapping */
  154. #define GPIO_AF9_FMC ((uint8_t)0x09) /* FMC Alternate Function mapping */
  155. #define GPIO_AF9_SAI4 ((uint8_t)0x09) /* SAI4 Alternate Function mapping */
  156. /**
  157. * @brief AF 10 selection
  158. */
  159. #define GPIO_AF10_QUADSPI ((uint8_t)0xA) /* QUADSPI Alternate Function mapping */
  160. #define GPIO_AF10_SAI2 ((uint8_t)0xA) /* SAI2 Alternate Function mapping */
  161. #define GPIO_AF10_SAI4 ((uint8_t)0xA) /* SAI4 Alternate Function mapping */
  162. #define GPIO_AF10_SDMMC2 ((uint8_t)0xA) /* SDMMC2 Alternate Function mapping */
  163. #define GPIO_AF10_OTG2_HS ((uint8_t)0xA) /* OTG2_HS Alternate Function mapping */
  164. #define GPIO_AF10_OTG1_FS ((uint8_t)0xA) /* OTG1_FS Alternate Function mapping */
  165. #define GPIO_AF10_COMP1 ((uint8_t)0xA) /* COMP1 Alternate Function mapping */
  166. #define GPIO_AF10_COMP2 ((uint8_t)0xA) /* COMP2 Alternate Function mapping */
  167. #define GPIO_AF10_LTDC ((uint8_t)0xA) /* LTDC Alternate Function mapping */
  168. #define GPIO_AF10_CRS_SYNC ((uint8_t)0xA) /* CRS Sync Alternate Function mapping : available on STM32H7 Rev.B and above */
  169. /**
  170. * @brief AF 11 selection
  171. */
  172. #define GPIO_AF11_SWP ((uint8_t)0x0B) /* SWP Alternate Function mapping */
  173. #define GPIO_AF11_ETH ((uint8_t)0x0B) /* ETH Alternate Function mapping */
  174. #define GPIO_AF11_MDIOS ((uint8_t)0x0B) /* MDIOS Alternate Function mapping */
  175. #define GPIO_AF11_OTG1_HS ((uint8_t)0x0B) /* OTG1_HS Alternate Function mapping */
  176. #define GPIO_AF11_UART7 ((uint8_t)0x0B) /* UART7 Alternate Function mapping */
  177. #define GPIO_AF11_SDMMC2 ((uint8_t)0x0B) /* SDMMC2 Alternate Function mapping */
  178. #define GPIO_AF11_DFSDM1 ((uint8_t)0x0B) /* DFSDM Alternate Function mapping */
  179. #define GPIO_AF11_COMP1 ((uint8_t)0x0B) /* COMP1 Alternate Function mapping */
  180. #define GPIO_AF11_COMP2 ((uint8_t)0x0B) /* COMP2 Alternate Function mapping */
  181. #define GPIO_AF11_I2C4 ((uint8_t)0x0B) /* I2C4 Alternate Function mapping */
  182. /**
  183. * @brief AF 12 selection
  184. */
  185. #define GPIO_AF12_FMC ((uint8_t)0xC) /* FMC Alternate Function mapping */
  186. #define GPIO_AF12_SDMMC1 ((uint8_t)0xC) /* SDMMC1 Alternate Function mapping */
  187. #define GPIO_AF12_MDIOS ((uint8_t)0xC) /* MDIOS Alternate Function mapping */
  188. #define GPIO_AF12_OTG2_FS ((uint8_t)0xC) /* OTG2_FS Alternate Function mapping */
  189. #define GPIO_AF12_COMP1 ((uint8_t)0xC) /* COMP1 Alternate Function mapping */
  190. #define GPIO_AF12_COMP2 ((uint8_t)0xC) /* COMP2 Alternate Function mapping */
  191. #define GPIO_AF12_LTDC ((uint8_t)0xC) /* LTDC Alternate Function mapping */
  192. /**
  193. * @brief AF 13 selection
  194. */
  195. #define GPIO_AF13_DCMI ((uint8_t)0x0D) /* DCMI Alternate Function mapping */
  196. #define GPIO_AF13_DSI ((uint8_t)0x0D) /* DSI Alternate Function mapping */
  197. #define GPIO_AF13_COMP1 ((uint8_t)0x0D) /* COMP1 Alternate Function mapping */
  198. #define GPIO_AF13_COMP2 ((uint8_t)0x0D) /* COMP2 Alternate Function mapping */
  199. #define GPIO_AF13_LTDC ((uint8_t)0x0D) /* LTDC Alternate Function mapping */
  200. /**
  201. * @brief AF 14 selection
  202. */
  203. #define GPIO_AF14_LTDC ((uint8_t)0x0E) /* LTDC Alternate Function mapping */
  204. #define GPIO_AF14_UART5 ((uint8_t)0x0E) /* UART5 Alternate Function mapping */
  205. /**
  206. * @brief AF 15 selection
  207. */
  208. #define GPIO_AF15_EVENTOUT ((uint8_t)0x0F) /* EVENTOUT Alternate Function mapping */
  209. #define IS_GPIO_AF(AF) ((AF) <= (uint8_t)0x0F)
  210. /**
  211. * @}
  212. */
  213. /**
  214. * @}
  215. */
  216. /* Exported macro ------------------------------------------------------------*/
  217. /** @defgroup GPIOEx_Exported_Macros GPIO Exported Macros
  218. * @{
  219. */
  220. /**
  221. * @}
  222. */
  223. /* Exported functions --------------------------------------------------------*/
  224. /** @defgroup GPIOEx_Exported_Functions GPIO Exported Functions
  225. * @{
  226. */
  227. /**
  228. * @}
  229. */
  230. /* Private types -------------------------------------------------------------*/
  231. /* Private variables ---------------------------------------------------------*/
  232. /* Private constants ---------------------------------------------------------*/
  233. /** @defgroup GPIOEx_Private_Constants GPIO Private Constants
  234. * @{
  235. */
  236. /**
  237. * @brief GPIO pin available on the platform
  238. */
  239. /* Defines the available pins per GPIOs */
  240. #define GPIOA_PIN_AVAILABLE GPIO_PIN_All
  241. #define GPIOB_PIN_AVAILABLE GPIO_PIN_All
  242. #define GPIOC_PIN_AVAILABLE GPIO_PIN_All
  243. #define GPIOD_PIN_AVAILABLE GPIO_PIN_All
  244. #define GPIOE_PIN_AVAILABLE GPIO_PIN_All
  245. #define GPIOF_PIN_AVAILABLE GPIO_PIN_All
  246. #define GPIOG_PIN_AVAILABLE GPIO_PIN_All
  247. #define GPIOI_PIN_AVAILABLE GPIO_PIN_All
  248. #define GPIOJ_PIN_AVAILABLE GPIO_PIN_All
  249. #define GPIOH_PIN_AVAILABLE GPIO_PIN_All
  250. #define GPIOK_PIN_AVAILABLE (GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_3 | GPIO_PIN_4 | \
  251. GPIO_PIN_5 | GPIO_PIN_6 | GPIO_PIN_7)
  252. /**
  253. * @}
  254. */
  255. /* Private macros ------------------------------------------------------------*/
  256. /** @defgroup GPIOEx_Private_Macros GPIO Private Macros
  257. * @{
  258. */
  259. /** @defgroup GPIOEx_Get_Port_Index GPIO Get Port Index
  260. * @{
  261. */
  262. #define GPIO_GET_INDEX(__GPIOx__) (((__GPIOx__) == (GPIOA))? 0UL :\
  263. ((__GPIOx__) == (GPIOB))? 1UL :\
  264. ((__GPIOx__) == (GPIOC))? 2UL :\
  265. ((__GPIOx__) == (GPIOD))? 3UL :\
  266. ((__GPIOx__) == (GPIOE))? 4UL :\
  267. ((__GPIOx__) == (GPIOF))? 5UL :\
  268. ((__GPIOx__) == (GPIOG))? 6UL :\
  269. ((__GPIOx__) == (GPIOH))? 7UL :\
  270. ((__GPIOx__) == (GPIOI))? 8UL :\
  271. ((__GPIOx__) == (GPIOJ))? 9UL : 10UL)
  272. /**
  273. * @}
  274. */
  275. /** @defgroup GPIOEx_IS_Alternat_function_selection GPIO Check Alternate Function
  276. * @{
  277. */
  278. /**
  279. * @}
  280. */
  281. /**
  282. * @}
  283. */
  284. /* Private functions ---------------------------------------------------------*/
  285. /** @defgroup GPIOEx_Private_Functions GPIO Private Functions
  286. * @{
  287. */
  288. /**
  289. * @}
  290. */
  291. /**
  292. * @}
  293. */
  294. /**
  295. * @}
  296. */
  297. #ifdef __cplusplus
  298. }
  299. #endif
  300. #endif /* STM32H7xx_HAL_GPIO_EX_H */
  301. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/