stm32f2xx_hal_gpio_ex.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282
  1. /**
  2. ******************************************************************************
  3. * @file stm32f2xx_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 __STM32F2xx_HAL_GPIO_EX_H
  21. #define __STM32F2xx_HAL_GPIO_EX_H
  22. #ifdef __cplusplus
  23. extern "C" {
  24. #endif
  25. /* Includes ------------------------------------------------------------------*/
  26. #include "stm32f2xx_hal_def.h"
  27. /** @addtogroup STM32F2xx_HAL_Driver
  28. * @{
  29. */
  30. /** @defgroup GPIOEx GPIOEx
  31. * @{
  32. */
  33. /* Exported types ------------------------------------------------------------*/
  34. /* Exported constants --------------------------------------------------------*/
  35. /* Exported constants --------------------------------------------------------*/
  36. /** @defgroup GPIOEx_Exported_Constants GPIO Exported Constants
  37. * @{
  38. */
  39. /** @defgroup GPIO_Alternate_function_selection GPIO Alternate function selection
  40. * @{
  41. */
  42. /**
  43. * @brief AF 0 selection
  44. */
  45. #define GPIO_AF0_RTC_50Hz ((uint8_t)0x00) /* RTC_50Hz Alternate Function mapping */
  46. #define GPIO_AF0_MCO ((uint8_t)0x00) /* MCO (MCO1 and MCO2) Alternate Function mapping */
  47. #define GPIO_AF0_TAMPER ((uint8_t)0x00) /* TAMPER (TAMPER_1 and TAMPER_2) Alternate Function mapping */
  48. #define GPIO_AF0_SWJ ((uint8_t)0x00) /* SWJ (SWD and JTAG) Alternate Function mapping */
  49. #define GPIO_AF0_TRACE ((uint8_t)0x00) /* TRACE Alternate Function mapping */
  50. /**
  51. * @brief AF 1 selection
  52. */
  53. #define GPIO_AF1_TIM1 ((uint8_t)0x01) /* TIM1 Alternate Function mapping */
  54. #define GPIO_AF1_TIM2 ((uint8_t)0x01) /* TIM2 Alternate Function mapping */
  55. /**
  56. * @brief AF 2 selection
  57. */
  58. #define GPIO_AF2_TIM3 ((uint8_t)0x02) /* TIM3 Alternate Function mapping */
  59. #define GPIO_AF2_TIM4 ((uint8_t)0x02) /* TIM4 Alternate Function mapping */
  60. #define GPIO_AF2_TIM5 ((uint8_t)0x02) /* TIM5 Alternate Function mapping */
  61. /**
  62. * @brief AF 3 selection
  63. */
  64. #define GPIO_AF3_TIM8 ((uint8_t)0x03) /* TIM8 Alternate Function mapping */
  65. #define GPIO_AF3_TIM9 ((uint8_t)0x03) /* TIM9 Alternate Function mapping */
  66. #define GPIO_AF3_TIM10 ((uint8_t)0x03) /* TIM10 Alternate Function mapping */
  67. #define GPIO_AF3_TIM11 ((uint8_t)0x03) /* TIM11 Alternate Function mapping */
  68. /**
  69. * @brief AF 4 selection
  70. */
  71. #define GPIO_AF4_I2C1 ((uint8_t)0x04) /* I2C1 Alternate Function mapping */
  72. #define GPIO_AF4_I2C2 ((uint8_t)0x04) /* I2C2 Alternate Function mapping */
  73. #define GPIO_AF4_I2C3 ((uint8_t)0x04) /* I2C3 Alternate Function mapping */
  74. /**
  75. * @brief AF 5 selection
  76. */
  77. #define GPIO_AF5_SPI1 ((uint8_t)0x05) /* SPI1 Alternate Function mapping */
  78. #define GPIO_AF5_SPI2 ((uint8_t)0x05) /* SPI2/I2S2 Alternate Function mapping */
  79. /**
  80. * @brief AF 6 selection
  81. */
  82. #define GPIO_AF6_SPI3 ((uint8_t)0x06) /* SPI3/I2S3 Alternate Function mapping */
  83. /**
  84. * @brief AF 7 selection
  85. */
  86. #define GPIO_AF7_USART1 ((uint8_t)0x07) /* USART1 Alternate Function mapping */
  87. #define GPIO_AF7_USART2 ((uint8_t)0x07) /* USART2 Alternate Function mapping */
  88. #define GPIO_AF7_USART3 ((uint8_t)0x07) /* USART3 Alternate Function mapping */
  89. /**
  90. * @brief AF 8 selection
  91. */
  92. #define GPIO_AF8_UART4 ((uint8_t)0x08) /* UART4 Alternate Function mapping */
  93. #define GPIO_AF8_UART5 ((uint8_t)0x08) /* UART5 Alternate Function mapping */
  94. #define GPIO_AF8_USART6 ((uint8_t)0x08) /* USART6 Alternate Function mapping */
  95. /**
  96. * @brief AF 9 selection
  97. */
  98. #define GPIO_AF9_CAN1 ((uint8_t)0x09) /* CAN1 Alternate Function mapping */
  99. #define GPIO_AF9_CAN2 ((uint8_t)0x09) /* CAN2 Alternate Function mapping */
  100. #define GPIO_AF9_TIM12 ((uint8_t)0x09) /* TIM12 Alternate Function mapping */
  101. #define GPIO_AF9_TIM13 ((uint8_t)0x09) /* TIM13 Alternate Function mapping */
  102. #define GPIO_AF9_TIM14 ((uint8_t)0x09) /* TIM14 Alternate Function mapping */
  103. /**
  104. * @brief AF 10 selection
  105. */
  106. #define GPIO_AF10_OTG_FS ((uint8_t)0x0A) /* OTG_FS Alternate Function mapping */
  107. #define GPIO_AF10_OTG_HS ((uint8_t)0x0A) /* OTG_HS Alternate Function mapping */
  108. /**
  109. * @brief AF 11 selection
  110. */
  111. #if defined(STM32F207xx) || defined(STM32F217xx)
  112. #define GPIO_AF11_ETH ((uint8_t)0x0B) /* ETHERNET Alternate Function mapping */
  113. #endif /* STM32F207xx || STM32F217xx */
  114. /**
  115. * @brief AF 12 selection
  116. */
  117. #define GPIO_AF12_FSMC ((uint8_t)0x0C) /* FSMC Alternate Function mapping */
  118. #define GPIO_AF12_OTG_HS_FS ((uint8_t)0x0C) /* OTG HS configured in FS, Alternate Function mapping */
  119. #define GPIO_AF12_SDIO ((uint8_t)0x0C) /* SDIO Alternate Function mapping */
  120. /**
  121. * @brief AF 13 selection
  122. */
  123. #if defined(STM32F207xx) || defined(STM32F217xx)
  124. #define GPIO_AF13_DCMI ((uint8_t)0x0D) /* DCMI Alternate Function mapping */
  125. #endif /* STM32F207xx || STM32F217xx */
  126. /**
  127. * @brief AF 15 selection
  128. */
  129. #define GPIO_AF15_EVENTOUT ((uint8_t)0x0F) /* EVENTOUT Alternate Function mapping */
  130. /**
  131. * @}
  132. */
  133. /**
  134. * @}
  135. */
  136. /* Exported macro ------------------------------------------------------------*/
  137. /** @defgroup GPIOEx_Exported_Macros GPIO Exported Macros
  138. * @{
  139. */
  140. /**
  141. * @}
  142. */
  143. /* Exported functions --------------------------------------------------------*/
  144. /** @defgroup GPIOEx_Exported_Functions GPIO Exported Functions
  145. * @{
  146. */
  147. /**
  148. * @}
  149. */
  150. /* Private types -------------------------------------------------------------*/
  151. /* Private variables ---------------------------------------------------------*/
  152. /* Private constants ---------------------------------------------------------*/
  153. /** @defgroup GPIOEx_Private_Constants GPIO Private Constants
  154. * @{
  155. */
  156. /**
  157. * @}
  158. */
  159. /* Private macros ------------------------------------------------------------*/
  160. /** @defgroup GPIOEx_Private_Macros GPIO Private Macros
  161. * @{
  162. */
  163. /** @defgroup GPIOEx_Get_Port_Index GPIO Get Port Index
  164. * @{
  165. */
  166. #define GPIO_GET_INDEX(__GPIOx__) (uint8_t)(((__GPIOx__) == (GPIOA))? 0U :\
  167. ((__GPIOx__) == (GPIOB))? 1U :\
  168. ((__GPIOx__) == (GPIOC))? 2U :\
  169. ((__GPIOx__) == (GPIOD))? 3U :\
  170. ((__GPIOx__) == (GPIOE))? 4U :\
  171. ((__GPIOx__) == (GPIOF))? 5U :\
  172. ((__GPIOx__) == (GPIOG))? 6U :\
  173. ((__GPIOx__) == (GPIOH))? 7U :\
  174. ((__GPIOx__) == (GPIOI))? 8U : 9U)
  175. /**
  176. * @}
  177. */
  178. /** @defgroup GPIOEx_IS_Alternat_function_selection GPIO Check Alternate Function
  179. * @{
  180. */
  181. #if defined(STM32F207xx) || defined(STM32F217xx)
  182. #define IS_GPIO_AF(AF) (((AF) == GPIO_AF0_RTC_50Hz) || ((AF) == GPIO_AF9_TIM14) || \
  183. ((AF) == GPIO_AF0_MCO) || ((AF) == GPIO_AF0_TAMPER) || \
  184. ((AF) == GPIO_AF0_SWJ) || ((AF) == GPIO_AF0_TRACE) || \
  185. ((AF) == GPIO_AF1_TIM1) || ((AF) == GPIO_AF1_TIM2) || \
  186. ((AF) == GPIO_AF2_TIM3) || ((AF) == GPIO_AF2_TIM4) || \
  187. ((AF) == GPIO_AF2_TIM5) || ((AF) == GPIO_AF3_TIM8) || \
  188. ((AF) == GPIO_AF4_I2C1) || ((AF) == GPIO_AF4_I2C2) || \
  189. ((AF) == GPIO_AF4_I2C3) || ((AF) == GPIO_AF5_SPI1) || \
  190. ((AF) == GPIO_AF5_SPI2) || ((AF) == GPIO_AF9_TIM13) || \
  191. ((AF) == GPIO_AF6_SPI3) || ((AF) == GPIO_AF9_TIM12) || \
  192. ((AF) == GPIO_AF7_USART1) || ((AF) == GPIO_AF7_USART2) || \
  193. ((AF) == GPIO_AF7_USART3) || ((AF) == GPIO_AF8_UART4) || \
  194. ((AF) == GPIO_AF8_UART5) || ((AF) == GPIO_AF8_USART6) || \
  195. ((AF) == GPIO_AF9_CAN1) || ((AF) == GPIO_AF9_CAN2) || \
  196. ((AF) == GPIO_AF10_OTG_FS) || ((AF) == GPIO_AF10_OTG_HS) || \
  197. ((AF) == GPIO_AF11_ETH) || ((AF) == GPIO_AF12_OTG_HS_FS) || \
  198. ((AF) == GPIO_AF12_SDIO) || ((AF) == GPIO_AF13_DCMI) || \
  199. ((AF) == GPIO_AF12_FSMC) || ((AF) == GPIO_AF15_EVENTOUT))
  200. #else /* STM32F207xx || STM32F217xx */
  201. #define IS_GPIO_AF(AF) (((AF) == GPIO_AF0_RTC_50Hz) || ((AF) == GPIO_AF9_TIM14) || \
  202. ((AF) == GPIO_AF0_MCO) || ((AF) == GPIO_AF0_TAMPER) || \
  203. ((AF) == GPIO_AF0_SWJ) || ((AF) == GPIO_AF0_TRACE) || \
  204. ((AF) == GPIO_AF1_TIM1) || ((AF) == GPIO_AF1_TIM2) || \
  205. ((AF) == GPIO_AF2_TIM3) || ((AF) == GPIO_AF2_TIM4) || \
  206. ((AF) == GPIO_AF2_TIM5) || ((AF) == GPIO_AF3_TIM8) || \
  207. ((AF) == GPIO_AF4_I2C1) || ((AF) == GPIO_AF4_I2C2) || \
  208. ((AF) == GPIO_AF4_I2C3) || ((AF) == GPIO_AF5_SPI1) || \
  209. ((AF) == GPIO_AF5_SPI2) || ((AF) == GPIO_AF9_TIM13) || \
  210. ((AF) == GPIO_AF6_SPI3) || ((AF) == GPIO_AF9_TIM12) || \
  211. ((AF) == GPIO_AF7_USART1) || ((AF) == GPIO_AF7_USART2) || \
  212. ((AF) == GPIO_AF7_USART3) || ((AF) == GPIO_AF8_UART4) || \
  213. ((AF) == GPIO_AF8_UART5) || ((AF) == GPIO_AF8_USART6) || \
  214. ((AF) == GPIO_AF9_CAN1) || ((AF) == GPIO_AF9_CAN2) || \
  215. ((AF) == GPIO_AF10_OTG_FS) || ((AF) == GPIO_AF10_OTG_HS) || \
  216. ((AF) == GPIO_AF12_OTG_HS_FS) || ((AF) == GPIO_AF12_SDIO) || \
  217. ((AF) == GPIO_AF12_FSMC) || ((AF) == GPIO_AF15_EVENTOUT))
  218. #endif /* STM32F207xx || STM32F217xx */
  219. /**
  220. * @}
  221. */
  222. /**
  223. * @}
  224. */
  225. /* Private functions ---------------------------------------------------------*/
  226. /** @defgroup GPIOEx_Private_Functions GPIO Private Functions
  227. * @{
  228. */
  229. /**
  230. * @}
  231. */
  232. /**
  233. * @}
  234. */
  235. /**
  236. * @}
  237. */
  238. #ifdef __cplusplus
  239. }
  240. #endif
  241. #endif /* __STM32F2xx_HAL_GPIO_EX_H */
  242. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/