stm32g4xx_hal_gpio_ex.h 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340
  1. /**
  2. ******************************************************************************
  3. * @file stm32g4xx_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) 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. /* Define to prevent recursive inclusion -------------------------------------*/
  19. #ifndef STM32G4xx_HAL_GPIO_EX_H
  20. #define STM32G4xx_HAL_GPIO_EX_H
  21. #ifdef __cplusplus
  22. extern "C" {
  23. #endif
  24. /* Includes ------------------------------------------------------------------*/
  25. #include "stm32g4xx_hal_def.h"
  26. /** @addtogroup STM32G4xx_HAL_Driver
  27. * @{
  28. */
  29. /** @defgroup GPIOEx GPIOEx
  30. * @brief GPIO Extended HAL module driver
  31. * @{
  32. */
  33. /* Exported types ------------------------------------------------------------*/
  34. /* Exported constants --------------------------------------------------------*/
  35. /** @defgroup GPIOEx_Exported_Constants GPIOEx Exported Constants
  36. * @{
  37. */
  38. /** @defgroup GPIOEx_Alternate_function_selection GPIOEx 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_TRACE ((uint8_t)0x00) /* TRACE Alternate Function mapping */
  48. /**
  49. * @brief AF 1 selection
  50. */
  51. #define GPIO_AF1_TIM2 ((uint8_t)0x01) /* TIM2 Alternate Function mapping */
  52. #if defined(TIM5)
  53. #define GPIO_AF1_TIM5 ((uint8_t)0x01) /* TIM5 Alternate Function mapping */
  54. #endif /* TIM5 */
  55. #define GPIO_AF1_TIM16 ((uint8_t)0x01) /* TIM16 Alternate Function mapping */
  56. #define GPIO_AF1_TIM17 ((uint8_t)0x01) /* TIM17 Alternate Function mapping */
  57. #define GPIO_AF1_TIM17_COMP1 ((uint8_t)0x01) /* TIM17/COMP1 Break in Alternate Function mapping */
  58. #define GPIO_AF1_TIM15 ((uint8_t)0x01) /* TIM15 Alternate Function mapping */
  59. #define GPIO_AF1_LPTIM1 ((uint8_t)0x01) /* LPTIM1 Alternate Function mapping */
  60. #define GPIO_AF1_IR ((uint8_t)0x01) /* IR Alternate Function mapping */
  61. /**
  62. * @brief AF 2 selection
  63. */
  64. #define GPIO_AF2_TIM1 ((uint8_t)0x02) /* TIM1 Alternate Function mapping */
  65. #define GPIO_AF2_TIM2 ((uint8_t)0x02) /* TIM2 Alternate Function mapping */
  66. #define GPIO_AF2_TIM3 ((uint8_t)0x02) /* TIM3 Alternate Function mapping */
  67. #define GPIO_AF2_TIM4 ((uint8_t)0x02) /* TIM4 Alternate Function mapping */
  68. #if defined(TIM5)
  69. #define GPIO_AF2_TIM5 ((uint8_t)0x02) /* TIM5 Alternate Function mapping */
  70. #endif /* TIM5 */
  71. #define GPIO_AF2_TIM8 ((uint8_t)0x02) /* TIM8 Alternate Function mapping */
  72. #define GPIO_AF2_TIM15 ((uint8_t)0x02) /* TIM15 Alternate Function mapping */
  73. #define GPIO_AF2_TIM16 ((uint8_t)0x02) /* TIM16 Alternate Function mapping */
  74. #if defined(TIM20)
  75. #define GPIO_AF2_TIM20 ((uint8_t)0x02) /* TIM20 Alternate Function mapping */
  76. #endif /* TIM20 */
  77. #define GPIO_AF2_TIM1_COMP1 ((uint8_t)0x02) /* TIM1/COMP1 Break in Alternate Function mapping */
  78. #define GPIO_AF2_TIM15_COMP1 ((uint8_t)0x02) /* TIM15/COMP1 Break in Alternate Function mapping */
  79. #define GPIO_AF2_TIM16_COMP1 ((uint8_t)0x02) /* TIM16/COMP1 Break in Alternate Function mapping */
  80. #if defined(TIM20)
  81. #define GPIO_AF2_TIM20_COMP1 ((uint8_t)0x02) /* TIM20/COMP1 Break in Alternate Function mapping */
  82. #define GPIO_AF2_TIM20_COMP2 ((uint8_t)0x02) /* TIM20/COMP2 Break in Alternate Function mapping */
  83. #endif /* TIM20 */
  84. #define GPIO_AF2_I2C3 ((uint8_t)0x02) /* I2C3 Alternate Function mapping */
  85. #define GPIO_AF2_COMP1 ((uint8_t)0x02) /* COMP1 Alternate Function mapping */
  86. /**
  87. * @brief AF 3 selection
  88. */
  89. #define GPIO_AF3_TIM15 ((uint8_t)0x03) /* TIM15 Alternate Function mapping */
  90. #if defined(TIM20)
  91. #define GPIO_AF3_TIM20 ((uint8_t)0x03) /* TIM20 Alternate Function mapping */
  92. #endif /* TIM20 */
  93. #define GPIO_AF3_UCPD1 ((uint8_t)0x03) /* UCPD1 Alternate Function mapping */
  94. #define GPIO_AF3_I2C3 ((uint8_t)0x03) /* I2C3 Alternate Function mapping */
  95. #if defined(I2C4)
  96. #define GPIO_AF3_I2C4 ((uint8_t)0x03) /* I2C4 Alternate Function mapping */
  97. #endif /* I2C4 */
  98. #if defined(HRTIM1)
  99. #define GPIO_AF3_HRTIM1 ((uint8_t)0x03) /* HRTIM1 Alternate Function mapping */
  100. #endif /* HRTIM1 */
  101. #if defined(QUADSPI)
  102. #define GPIO_AF3_QUADSPI ((uint8_t)0x03) /* QUADSPI Alternate Function mapping */
  103. #endif /* QUADSPI */
  104. #define GPIO_AF3_TIM8 ((uint8_t)0x03) /* TIM8 Alternate Function mapping */
  105. #define GPIO_AF3_SAI1 ((uint8_t)0x03) /* SAI1 Alternate Function mapping */
  106. #define GPIO_AF3_COMP3 ((uint8_t)0x03) /* COMP3 Alternate Function mapping */
  107. /**
  108. * @brief AF 4 selection
  109. */
  110. #define GPIO_AF4_TIM1 ((uint8_t)0x04) /* TIM1 Alternate Function mapping */
  111. #define GPIO_AF4_TIM8 ((uint8_t)0x04) /* TIM8 Alternate Function mapping */
  112. #define GPIO_AF4_TIM16 ((uint8_t)0x04) /* TIM16 Alternate Function mapping */
  113. #define GPIO_AF4_TIM17 ((uint8_t)0x04) /* TIM17 Alternate Function mapping */
  114. #define GPIO_AF4_TIM8_COMP1 ((uint8_t)0x04) /* TIM8/COMP1 Break in Alternate Function mapping */
  115. #define GPIO_AF4_I2C1 ((uint8_t)0x04) /* I2C1 Alternate Function mapping */
  116. #define GPIO_AF4_I2C2 ((uint8_t)0x04) /* I2C2 Alternate Function mapping */
  117. #define GPIO_AF4_I2C3 ((uint8_t)0x04) /* I2C3 Alternate Function mapping */
  118. #if defined(I2C4)
  119. #define GPIO_AF4_I2C4 ((uint8_t)0x04) /* I2C4 Alternate Function mapping */
  120. #endif /* I2C4 */
  121. /**
  122. * @brief AF 5 selection
  123. */
  124. #define GPIO_AF5_SPI1 ((uint8_t)0x05) /* SPI1 Alternate Function mapping */
  125. #define GPIO_AF5_SPI2 ((uint8_t)0x05) /* SPI2 Alternate Function mapping */
  126. #if defined(SPI4)
  127. #define GPIO_AF5_SPI4 ((uint8_t)0x05) /* SPI4 Alternate Function mapping */
  128. #endif /* SPI4 */
  129. #define GPIO_AF5_IR ((uint8_t)0x05) /* IR Alternate Function mapping */
  130. #define GPIO_AF5_TIM8 ((uint8_t)0x05) /* TIM8 Alternate Function mapping */
  131. #define GPIO_AF5_TIM8_COMP1 ((uint8_t)0x05) /* TIM8/COMP1 Break in Alternate Function mapping */
  132. #define GPIO_AF5_UART4 ((uint8_t)0x05) /* UART4 Alternate Function mapping */
  133. #if defined(UART5)
  134. #define GPIO_AF5_UART5 ((uint8_t)0x05) /* UART5 Alternate Function mapping */
  135. #endif /* UART5 */
  136. #define GPIO_AF5_I2S2ext ((uint8_t)0x05) /* I2S2ext_SD Alternate Function mapping */
  137. /**
  138. * @brief AF 6 selection
  139. */
  140. #define GPIO_AF6_SPI2 ((uint8_t)0x06) /* SPI2 Alternate Function mapping */
  141. #define GPIO_AF6_SPI3 ((uint8_t)0x06) /* SPI3 Alternate Function mapping */
  142. #define GPIO_AF6_TIM1 ((uint8_t)0x06) /* TIM1 Alternate Function mapping */
  143. #if defined(TIM5)
  144. #define GPIO_AF6_TIM5 ((uint8_t)0x06) /* TIM5 Alternate Function mapping */
  145. #endif /* TIM5 */
  146. #define GPIO_AF6_TIM8 ((uint8_t)0x06) /* TIM8 Alternate Function mapping */
  147. #if defined(TIM20)
  148. #define GPIO_AF6_TIM20 ((uint8_t)0x06) /* TIM20 Alternate Function mapping */
  149. #endif /* TIM20 */
  150. #define GPIO_AF6_TIM1_COMP1 ((uint8_t)0x06) /* TIM1/COMP1 Break in Alternate Function mapping */
  151. #define GPIO_AF6_TIM1_COMP2 ((uint8_t)0x06) /* TIM1/COMP2 Break in Alternate Function mapping */
  152. #define GPIO_AF6_TIM8_COMP2 ((uint8_t)0x06) /* TIM8/COMP2 Break in Alternate Function mapping */
  153. #define GPIO_AF6_IR ((uint8_t)0x06) /* IR Alternate Function mapping */
  154. #define GPIO_AF6_I2S3ext ((uint8_t)0x06) /* I2S3ext_SD Alternate Function mapping */
  155. /**
  156. * @brief AF 7 selection
  157. */
  158. #define GPIO_AF7_USART1 ((uint8_t)0x07) /* USART1 Alternate Function mapping */
  159. #define GPIO_AF7_USART2 ((uint8_t)0x07) /* USART2 Alternate Function mapping */
  160. #define GPIO_AF7_USART3 ((uint8_t)0x07) /* USART3 Alternate Function mapping */
  161. #if defined(COMP5)
  162. #define GPIO_AF7_COMP5 ((uint8_t)0x07) /* COMP5 Alternate Function mapping */
  163. #endif /* COMP5 */
  164. #if defined(COMP6)
  165. #define GPIO_AF7_COMP6 ((uint8_t)0x07) /* COMP6 Alternate Function mapping */
  166. #endif /* COMP6 */
  167. #if defined(COMP7)
  168. #define GPIO_AF7_COMP7 ((uint8_t)0x07) /* COMP7 Alternate Function mapping */
  169. #endif /* COMP7 */
  170. /**
  171. * @brief AF 8 selection
  172. */
  173. #define GPIO_AF8_COMP1 ((uint8_t)0x08) /* COMP1 Alternate Function mapping */
  174. #define GPIO_AF8_COMP2 ((uint8_t)0x08) /* COMP2 Alternate Function mapping */
  175. #define GPIO_AF8_COMP3 ((uint8_t)0x08) /* COMP3 Alternate Function mapping */
  176. #define GPIO_AF8_COMP4 ((uint8_t)0x08) /* COMP4 Alternate Function mapping */
  177. #if defined(COMP5)
  178. #define GPIO_AF8_COMP5 ((uint8_t)0x08) /* COMP5 Alternate Function mapping */
  179. #endif /* COMP5 */
  180. #if defined(COMP6)
  181. #define GPIO_AF8_COMP6 ((uint8_t)0x08) /* COMP6 Alternate Function mapping */
  182. #endif /* COMP6 */
  183. #if defined(COMP7)
  184. #define GPIO_AF8_COMP7 ((uint8_t)0x08) /* COMP7 Alternate Function mapping */
  185. #endif /* COMP7 */
  186. #define GPIO_AF8_I2C3 ((uint8_t)0x08) /* I2C3 Alternate Function mapping */
  187. #if defined(I2C4)
  188. #define GPIO_AF8_I2C4 ((uint8_t)0x08) /* I2C4 Alternate Function mapping */
  189. #endif /* I2C4 */
  190. #define GPIO_AF8_LPUART1 ((uint8_t)0x08) /* LPUART1 Alternate Function mapping */
  191. #define GPIO_AF8_UART4 ((uint8_t)0x08) /* UART4 Alternate Function mapping */
  192. #if defined(UART5)
  193. #define GPIO_AF8_UART5 ((uint8_t)0x08) /* UART5 Alternate Function mapping */
  194. #endif /* UART5 */
  195. /**
  196. * @brief AF 9 selection
  197. */
  198. #define GPIO_AF9_TIM1 ((uint8_t)0x09) /* TIM1 Alternate Function mapping */
  199. #define GPIO_AF9_TIM8 ((uint8_t)0x09) /* TIM8 Alternate Function mapping */
  200. #define GPIO_AF9_TIM15 ((uint8_t)0x09) /* TIM15 Alternate Function mapping */
  201. #define GPIO_AF9_TIM1_COMP1 ((uint8_t)0x09) /* TIM1/COMP1 Break in Alternate Function mapping */
  202. #define GPIO_AF9_TIM8_COMP1 ((uint8_t)0x09) /* TIM8/COMP1 Break in Alternate Function mapping */
  203. #define GPIO_AF9_TIM15_COMP1 ((uint8_t)0x09) /* TIM15/COMP1 Break in Alternate Function mapping */
  204. #define GPIO_AF9_FDCAN1 ((uint8_t)0x09) /* FDCAN1 Alternate Function mapping */
  205. #if defined(FDCAN2)
  206. #define GPIO_AF9_FDCAN2 ((uint8_t)0x09) /* FDCAN2 Alternate Function mapping */
  207. #endif /* FDCAN2 */
  208. /**
  209. * @brief AF 10 selection
  210. */
  211. #define GPIO_AF10_TIM2 ((uint8_t)0x0A) /* TIM2 Alternate Function mapping */
  212. #define GPIO_AF10_TIM3 ((uint8_t)0x0A) /* TIM3 Alternate Function mapping */
  213. #define GPIO_AF10_TIM4 ((uint8_t)0x0A) /* TIM4 Alternate Function mapping */
  214. #define GPIO_AF10_TIM8 ((uint8_t)0x0A) /* TIM8 Alternate Function mapping */
  215. #define GPIO_AF10_TIM17 ((uint8_t)0x0A) /* TIM17 Alternate Function mapping */
  216. #define GPIO_AF10_TIM8_COMP2 ((uint8_t)0x0A) /* TIM8/COMP2 Break in Alternate Function mapping */
  217. #define GPIO_AF10_TIM17_COMP1 ((uint8_t)0x0A) /* TIM17/COMP1 Break in Alternate Function mapping */
  218. #if defined(QUADSPI)
  219. #define GPIO_AF10_QUADSPI ((uint8_t)0x0A) /* OctoSPI Manager Port 1 Alternate Function mapping */
  220. #endif /* QUADSPI */
  221. /**
  222. * @brief AF 11 selection
  223. */
  224. #define GPIO_AF11_FDCAN1 ((uint8_t)0x0B) /* FDCAN1 Alternate Function mapping */
  225. #if defined(FDCAN3)
  226. #define GPIO_AF11_FDCAN3 ((uint8_t)0x0B) /* FDCAN3 Alternate Function mapping */
  227. #endif /* FDCAN3 */
  228. #define GPIO_AF11_TIM1 ((uint8_t)0x0B) /* TIM1 Alternate Function mapping */
  229. #define GPIO_AF11_TIM8 ((uint8_t)0x0B) /* TIM8 Alternate Function mapping */
  230. #define GPIO_AF11_TIM8_COMP1 ((uint8_t)0x0B) /* TIM8/COMP1 Break in Alternate Function mapping */
  231. #define GPIO_AF11_LPTIM1 ((uint8_t)0x0B) /* LPTIM1 Alternate Function mapping */
  232. /**
  233. * @brief AF 12 selection
  234. */
  235. #define GPIO_AF12_LPUART1 ((uint8_t)0x0C) /* LPUART1 Alternate Function mapping */
  236. #define GPIO_AF12_TIM1 ((uint8_t)0x0C) /* TIM1 Alternate Function mapping */
  237. #define GPIO_AF12_TIM1_COMP1 ((uint8_t)0x0C) /* TIM1/COMP1 Break in Alternate Function mapping */
  238. #define GPIO_AF12_TIM1_COMP2 ((uint8_t)0x0C) /* TIM1/COMP2 Break in Alternate Function mapping */
  239. #if defined(HRTIM1)
  240. #define GPIO_AF12_HRTIM1 ((uint8_t)0x0C) /* HRTIM1 Alternate Function mapping */
  241. #endif /* HRTIM1 */
  242. #if defined(FMC_BANK1)
  243. #define GPIO_AF12_FMC ((uint8_t)0x0C) /* FMC Alternate Function mapping */
  244. #endif /* FMC_BANK1 */
  245. #define GPIO_AF12_SAI1 ((uint8_t)0x0C) /* SAI1 Alternate Function mapping */
  246. /**
  247. * @brief AF 13 selection
  248. */
  249. #if defined(HRTIM1)
  250. #define GPIO_AF13_HRTIM1 ((uint8_t)0x0D) /* HRTIM1 Alternate Function mapping */
  251. #endif /* HRTIM1 */
  252. #define GPIO_AF13_SAI1 ((uint8_t)0x0D) /* SAI1 Alternate Function mapping */
  253. /**
  254. * @brief AF 14 selection
  255. */
  256. #define GPIO_AF14_TIM2 ((uint8_t)0x0E) /* TIM2 Alternate Function mapping */
  257. #define GPIO_AF14_TIM15 ((uint8_t)0x0E) /* TIM15 Alternate Function mapping */
  258. #define GPIO_AF14_UCPD1 ((uint8_t)0x0E) /* UCPD1 Alternate Function mapping */
  259. #define GPIO_AF14_SAI1 ((uint8_t)0x0E) /* SAI1 Alternate Function mapping */
  260. #define GPIO_AF14_UART4 ((uint8_t)0x0E) /* UART4 Alternate Function mapping */
  261. #if defined(UART5)
  262. #define GPIO_AF14_UART5 ((uint8_t)0x0E) /* UART5 Alternate Function mapping */
  263. #endif /* UART5 */
  264. /**
  265. * @brief AF 15 selection
  266. */
  267. #define GPIO_AF15_EVENTOUT ((uint8_t)0x0F) /* EVENTOUT Alternate Function mapping */
  268. #define IS_GPIO_AF(AF) ((AF) <= (uint8_t)0x0F)
  269. /**
  270. * @}
  271. */
  272. /**
  273. * @}
  274. */
  275. /* Exported macro ------------------------------------------------------------*/
  276. /** @defgroup GPIOEx_Exported_Macros GPIOEx Exported Macros
  277. * @{
  278. */
  279. /** @defgroup GPIOEx_Get_Port_Index GPIOEx Get Port Index
  280. * @{
  281. */
  282. #define GPIO_GET_INDEX(__GPIOx__) (((__GPIOx__) == (GPIOA))? 0UL :\
  283. ((__GPIOx__) == (GPIOB))? 1UL :\
  284. ((__GPIOx__) == (GPIOC))? 2UL :\
  285. ((__GPIOx__) == (GPIOD))? 3UL :\
  286. ((__GPIOx__) == (GPIOE))? 4UL :\
  287. ((__GPIOx__) == (GPIOF))? 5UL : 6UL)
  288. /**
  289. * @}
  290. */
  291. /**
  292. * @}
  293. */
  294. /* Exported functions --------------------------------------------------------*/
  295. /**
  296. * @}
  297. */
  298. /**
  299. * @}
  300. */
  301. #ifdef __cplusplus
  302. }
  303. #endif
  304. #endif /* STM32G4xx_HAL_GPIO_EX_H */