stm32l4xx_hal_gpio_ex.h 38 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822
  1. /**
  2. ******************************************************************************
  3. * @file stm32l4xx_hal_gpio_ex.h
  4. * @author MCD Application Team
  5. * @brief Header file of GPIO HAL Extended module.
  6. ******************************************************************************
  7. * @attention
  8. *
  9. * <h2><center>&copy; COPYRIGHT(c) 2017 STMicroelectronics</center></h2>
  10. *
  11. * Redistribution and use in source and binary forms, with or without modification,
  12. * are permitted provided that the following conditions are met:
  13. * 1. Redistributions of source code must retain the above copyright notice,
  14. * this list of conditions and the following disclaimer.
  15. * 2. Redistributions in binary form must reproduce the above copyright notice,
  16. * this list of conditions and the following disclaimer in the documentation
  17. * and/or other materials provided with the distribution.
  18. * 3. Neither the name of STMicroelectronics nor the names of its contributors
  19. * may be used to endorse or promote products derived from this software
  20. * without specific prior written permission.
  21. *
  22. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  23. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  24. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  25. * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
  26. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  27. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  28. * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  29. * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  30. * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  31. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  32. *
  33. ******************************************************************************
  34. */
  35. /* Define to prevent recursive inclusion -------------------------------------*/
  36. #ifndef __STM32L4xx_HAL_GPIO_EX_H
  37. #define __STM32L4xx_HAL_GPIO_EX_H
  38. #ifdef __cplusplus
  39. extern "C" {
  40. #endif
  41. /* Includes ------------------------------------------------------------------*/
  42. #include "stm32l4xx_hal_def.h"
  43. /** @addtogroup STM32L4xx_HAL_Driver
  44. * @{
  45. */
  46. /** @defgroup GPIOEx GPIOEx
  47. * @brief GPIO Extended HAL module driver
  48. * @{
  49. */
  50. /* Exported types ------------------------------------------------------------*/
  51. /* Exported constants --------------------------------------------------------*/
  52. /** @defgroup GPIOEx_Exported_Constants GPIOEx Exported Constants
  53. * @{
  54. */
  55. /** @defgroup GPIOEx_Alternate_function_selection GPIOEx Alternate function selection
  56. * @{
  57. */
  58. #if defined(STM32L431xx) || defined(STM32L432xx) || defined(STM32L433xx) || defined(STM32L442xx) || defined(STM32L443xx)
  59. /*--------------STM32L431xx/STM32L432xx/STM32L433xx/STM32L442xx/STM32L443xx---*/
  60. /**
  61. * @brief AF 0 selection
  62. */
  63. #define GPIO_AF0_RTC_50Hz ((uint8_t)0x00) /* RTC_50Hz Alternate Function mapping */
  64. #define GPIO_AF0_MCO ((uint8_t)0x00) /* MCO (MCO1 and MCO2) Alternate Function mapping */
  65. #define GPIO_AF0_SWJ ((uint8_t)0x00) /* SWJ (SWD and JTAG) Alternate Function mapping */
  66. #if defined(STM32L433xx) || defined(STM32L443xx)
  67. #define GPIO_AF0_LCDBIAS ((uint8_t)0x00) /* LCDBIAS Alternate Function mapping */
  68. #endif /* STM32L433xx || STM32L443xx */
  69. #define GPIO_AF0_TRACE ((uint8_t)0x00) /* TRACE Alternate Function mapping */
  70. /**
  71. * @brief AF 1 selection
  72. */
  73. #define GPIO_AF1_TIM1 ((uint8_t)0x01) /* TIM1 Alternate Function mapping */
  74. #define GPIO_AF1_TIM2 ((uint8_t)0x01) /* TIM2 Alternate Function mapping */
  75. #define GPIO_AF1_LPTIM1 ((uint8_t)0x01) /* LPTIM1 Alternate Function mapping */
  76. #define GPIO_AF1_IR ((uint8_t)0x01) /* IR Alternate Function mapping */
  77. /**
  78. * @brief AF 2 selection
  79. */
  80. #define GPIO_AF2_TIM1 ((uint8_t)0x02) /* TIM1 Alternate Function mapping */
  81. #define GPIO_AF2_TIM2 ((uint8_t)0x02) /* TIM2 Alternate Function mapping */
  82. /**
  83. * @brief AF 3 selection
  84. */
  85. #define GPIO_AF3_USART2 ((uint8_t)0x03) /* USART1 Alternate Function mapping */
  86. #define GPIO_AF3_TIM1_COMP2 ((uint8_t)0x03) /* TIM1/COMP2 Break in Alternate Function mapping */
  87. #define GPIO_AF3_TIM1_COMP1 ((uint8_t)0x03) /* TIM1/COMP1 Break in Alternate Function mapping */
  88. /**
  89. * @brief AF 4 selection
  90. */
  91. #define GPIO_AF4_I2C1 ((uint8_t)0x04) /* I2C1 Alternate Function mapping */
  92. #define GPIO_AF4_I2C2 ((uint8_t)0x04) /* I2C2 Alternate Function mapping */
  93. #define GPIO_AF4_I2C3 ((uint8_t)0x04) /* I2C3 Alternate Function mapping */
  94. /**
  95. * @brief AF 5 selection
  96. */
  97. #define GPIO_AF5_SPI1 ((uint8_t)0x05) /* SPI1 Alternate Function mapping */
  98. #define GPIO_AF5_SPI2 ((uint8_t)0x05) /* SPI2 Alternate Function mapping */
  99. /**
  100. * @brief AF 6 selection
  101. */
  102. #define GPIO_AF6_SPI3 ((uint8_t)0x06) /* SPI3 Alternate Function mapping */
  103. #define GPIO_AF6_COMP1 ((uint8_t)0x06) /* COMP1 Alternate Function mapping */
  104. /**
  105. * @brief AF 7 selection
  106. */
  107. #define GPIO_AF7_USART1 ((uint8_t)0x07) /* USART1 Alternate Function mapping */
  108. #define GPIO_AF7_USART2 ((uint8_t)0x07) /* USART2 Alternate Function mapping */
  109. #define GPIO_AF7_USART3 ((uint8_t)0x07) /* USART3 Alternate Function mapping */
  110. /**
  111. * @brief AF 8 selection
  112. */
  113. #define GPIO_AF8_LPUART1 ((uint8_t)0x08) /* LPUART1 Alternate Function mapping */
  114. /**
  115. * @brief AF 9 selection
  116. */
  117. #define GPIO_AF9_CAN1 ((uint8_t)0x09) /* CAN1 Alternate Function mapping */
  118. #define GPIO_AF9_TSC ((uint8_t)0x09) /* TSC Alternate Function mapping */
  119. /**
  120. * @brief AF 10 selection
  121. */
  122. #if defined(STM32L432xx) || defined(STM32L433xx) || defined(STM32L442xx) || defined(STM32L443xx)
  123. #define GPIO_AF10_USB_FS ((uint8_t)0x0A) /* USB_FS Alternate Function mapping */
  124. #endif /* STM32L432xx || STM32L433xx || STM32L442xx || STM32L443xx */
  125. #define GPIO_AF10_QUADSPI ((uint8_t)0x0A) /* QUADSPI Alternate Function mapping */
  126. #if defined(STM32L433xx) || defined(STM32L443xx)
  127. /**
  128. * @brief AF 11 selection
  129. */
  130. #define GPIO_AF11_LCD ((uint8_t)0x0B) /* LCD Alternate Function mapping */
  131. #endif /* STM32L433xx || STM32L443xx */
  132. /**
  133. * @brief AF 12 selection
  134. */
  135. #define GPIO_AF12_SWPMI1 ((uint8_t)0x0C) /* SWPMI1 Alternate Function mapping */
  136. #define GPIO_AF12_COMP1 ((uint8_t)0x0C) /* COMP1 Alternate Function mapping */
  137. #define GPIO_AF12_COMP2 ((uint8_t)0x0C) /* COMP2 Alternate Function mapping */
  138. #define GPIO_AF12_SDMMC1 ((uint8_t)0x0C) /* SDMMC1 Alternate Function mapping */
  139. /**
  140. * @brief AF 13 selection
  141. */
  142. #define GPIO_AF13_SAI1 ((uint8_t)0x0D) /* SAI1 Alternate Function mapping */
  143. /**
  144. * @brief AF 14 selection
  145. */
  146. #define GPIO_AF14_TIM2 ((uint8_t)0x0E) /* TIM2 Alternate Function mapping */
  147. #define GPIO_AF14_TIM15 ((uint8_t)0x0E) /* TIM15 Alternate Function mapping */
  148. #define GPIO_AF14_TIM16 ((uint8_t)0x0E) /* TIM16 Alternate Function mapping */
  149. #define GPIO_AF14_LPTIM2 ((uint8_t)0x0E) /* LPTIM2 Alternate Function mapping */
  150. /**
  151. * @brief AF 15 selection
  152. */
  153. #define GPIO_AF15_EVENTOUT ((uint8_t)0x0F) /* EVENTOUT Alternate Function mapping */
  154. #define IS_GPIO_AF(AF) ((AF) <= (uint8_t)0x0F)
  155. #endif /* STM32L431xx || STM32L432xx || STM32L433xx || STM32L442xx || STM32L443xx */
  156. #if defined(STM32L451xx) || defined(STM32L452xx) || defined(STM32L462xx)
  157. /*--------------STM32L451xx/STM32L452xx/STM32L462xx---------------------------*/
  158. /**
  159. * @brief AF 0 selection
  160. */
  161. #define GPIO_AF0_RTC_50Hz ((uint8_t)0x00) /* RTC_50Hz Alternate Function mapping */
  162. #define GPIO_AF0_MCO ((uint8_t)0x00) /* MCO (MCO1 and MCO2) Alternate Function mapping */
  163. #define GPIO_AF0_SWJ ((uint8_t)0x00) /* SWJ (SWD and JTAG) Alternate Function mapping */
  164. #define GPIO_AF0_TRACE ((uint8_t)0x00) /* TRACE Alternate Function mapping */
  165. /**
  166. * @brief AF 1 selection
  167. */
  168. #define GPIO_AF1_TIM1 ((uint8_t)0x01) /* TIM1 Alternate Function mapping */
  169. #define GPIO_AF1_TIM2 ((uint8_t)0x01) /* TIM2 Alternate Function mapping */
  170. #define GPIO_AF1_LPTIM1 ((uint8_t)0x01) /* LPTIM1 Alternate Function mapping */
  171. #define GPIO_AF1_IR ((uint8_t)0x01) /* IR Alternate Function mapping */
  172. /**
  173. * @brief AF 2 selection
  174. */
  175. #define GPIO_AF2_TIM1 ((uint8_t)0x02) /* TIM1 Alternate Function mapping */
  176. #define GPIO_AF2_TIM2 ((uint8_t)0x02) /* TIM2 Alternate Function mapping */
  177. #define GPIO_AF2_TIM3 ((uint8_t)0x02) /* TIM3 Alternate Function mapping */
  178. #define GPIO_AF2_I2C4 ((uint8_t)0x02) /* I2C4 Alternate Function mapping */
  179. /**
  180. * @brief AF 3 selection
  181. */
  182. #define GPIO_AF3_TIM1_COMP2 ((uint8_t)0x03) /* TIM1/COMP2 Break in Alternate Function mapping */
  183. #define GPIO_AF3_TIM1_COMP1 ((uint8_t)0x03) /* TIM1/COMP1 Break in Alternate Function mapping */
  184. #define GPIO_AF3_USART2 ((uint8_t)0x03) /* USART2 Alternate Function mapping */
  185. #define GPIO_AF3_CAN1 ((uint8_t)0x03) /* CAN1 Alternate Function mapping */
  186. #define GPIO_AF3_I2C4 ((uint8_t)0x03) /* I2C4 Alternate Function mapping */
  187. /**
  188. * @brief AF 4 selection
  189. */
  190. #define GPIO_AF4_I2C1 ((uint8_t)0x04) /* I2C1 Alternate Function mapping */
  191. #define GPIO_AF4_I2C2 ((uint8_t)0x04) /* I2C2 Alternate Function mapping */
  192. #define GPIO_AF4_I2C3 ((uint8_t)0x04) /* I2C3 Alternate Function mapping */
  193. #define GPIO_AF4_I2C4 ((uint8_t)0x04) /* I2C4 Alternate Function mapping */
  194. /**
  195. * @brief AF 5 selection
  196. */
  197. #define GPIO_AF5_SPI1 ((uint8_t)0x05) /* SPI1 Alternate Function mapping */
  198. #define GPIO_AF5_SPI2 ((uint8_t)0x05) /* SPI2 Alternate Function mapping */
  199. #define GPIO_AF5_I2C4 ((uint8_t)0x05) /* I2C4 Alternate Function mapping */
  200. /**
  201. * @brief AF 6 selection
  202. */
  203. #define GPIO_AF6_SPI3 ((uint8_t)0x06) /* SPI3 Alternate Function mapping */
  204. #define GPIO_AF6_DFSDM1 ((uint8_t)0x06) /* DFSDM1 Alternate Function mapping */
  205. #define GPIO_AF6_COMP1 ((uint8_t)0x06) /* COMP1 Alternate Function mapping */
  206. /**
  207. * @brief AF 7 selection
  208. */
  209. #define GPIO_AF7_USART1 ((uint8_t)0x07) /* USART1 Alternate Function mapping */
  210. #define GPIO_AF7_USART2 ((uint8_t)0x07) /* USART2 Alternate Function mapping */
  211. #define GPIO_AF7_USART3 ((uint8_t)0x07) /* USART3 Alternate Function mapping */
  212. /**
  213. * @brief AF 8 selection
  214. */
  215. #define GPIO_AF8_UART4 ((uint8_t)0x08) /* UART4 Alternate Function mapping */
  216. #define GPIO_AF8_LPUART1 ((uint8_t)0x08) /* LPUART1 Alternate Function mapping */
  217. #define GPIO_AF8_CAN1 ((uint8_t)0x08) /* CAN1 Alternate Function mapping */
  218. /**
  219. * @brief AF 9 selection
  220. */
  221. #define GPIO_AF9_CAN1 ((uint8_t)0x09) /* CAN1 Alternate Function mapping */
  222. #define GPIO_AF9_TSC ((uint8_t)0x09) /* TSC Alternate Function mapping */
  223. /**
  224. * @brief AF 10 selection
  225. */
  226. #if defined(STM32L452xx) || defined(STM32L462xx)
  227. #define GPIO_AF10_USB_FS ((uint8_t)0x0A) /* USB_FS Alternate Function mapping */
  228. #endif /* STM32L452xx || STM32L462xx */
  229. #define GPIO_AF10_QUADSPI ((uint8_t)0x0A) /* QUADSPI Alternate Function mapping */
  230. #define GPIO_AF10_CAN1 ((uint8_t)0x0A) /* CAN1 Alternate Function mapping */
  231. /**
  232. * @brief AF 11 selection
  233. */
  234. /**
  235. * @brief AF 12 selection
  236. */
  237. #define GPIO_AF12_COMP1 ((uint8_t)0x0C) /* COMP1 Alternate Function mapping */
  238. #define GPIO_AF12_COMP2 ((uint8_t)0x0C) /* COMP2 Alternate Function mapping */
  239. #define GPIO_AF12_SDMMC1 ((uint8_t)0x0C) /* SDMMC1 Alternate Function mapping */
  240. /**
  241. * @brief AF 13 selection
  242. */
  243. #define GPIO_AF13_SAI1 ((uint8_t)0x0D) /* SAI1 Alternate Function mapping */
  244. /**
  245. * @brief AF 14 selection
  246. */
  247. #define GPIO_AF14_TIM2 ((uint8_t)0x0E) /* TIM2 Alternate Function mapping */
  248. #define GPIO_AF14_TIM15 ((uint8_t)0x0E) /* TIM15 Alternate Function mapping */
  249. #define GPIO_AF14_TIM16 ((uint8_t)0x0E) /* TIM16 Alternate Function mapping */
  250. #define GPIO_AF14_TIM17 ((uint8_t)0x0E) /* TIM17 Alternate Function mapping */
  251. #define GPIO_AF14_LPTIM2 ((uint8_t)0x0E) /* LPTIM2 Alternate Function mapping */
  252. /**
  253. * @brief AF 15 selection
  254. */
  255. #define GPIO_AF15_EVENTOUT ((uint8_t)0x0F) /* EVENTOUT Alternate Function mapping */
  256. #define IS_GPIO_AF(AF) ((AF) <= (uint8_t)0x0F)
  257. #endif /* STM32L451xx || STM32L452xx || STM32L462xx */
  258. #if defined(STM32L471xx) || defined(STM32L475xx) || defined(STM32L476xx) || defined(STM32L485xx) || defined(STM32L486xx)
  259. /*--------------STM32L471xx/STM32L475xx/STM32L476xx/STM32L485xx/STM32L486xx---*/
  260. /**
  261. * @brief AF 0 selection
  262. */
  263. #define GPIO_AF0_RTC_50Hz ((uint8_t)0x00) /* RTC_50Hz Alternate Function mapping */
  264. #define GPIO_AF0_MCO ((uint8_t)0x00) /* MCO (MCO1 and MCO2) Alternate Function mapping */
  265. #define GPIO_AF0_SWJ ((uint8_t)0x00) /* SWJ (SWD and JTAG) Alternate Function mapping */
  266. #if defined(STM32L476xx) || defined(STM32L486xx)
  267. #define GPIO_AF0_LCDBIAS ((uint8_t)0x00) /* LCDBIAS Alternate Function mapping */
  268. #endif /* STM32L476xx || STM32L486xx */
  269. #define GPIO_AF0_TRACE ((uint8_t)0x00) /* TRACE Alternate Function mapping */
  270. /**
  271. * @brief AF 1 selection
  272. */
  273. #define GPIO_AF1_TIM1 ((uint8_t)0x01) /* TIM1 Alternate Function mapping */
  274. #define GPIO_AF1_TIM2 ((uint8_t)0x01) /* TIM2 Alternate Function mapping */
  275. #define GPIO_AF1_TIM5 ((uint8_t)0x01) /* TIM5 Alternate Function mapping */
  276. #define GPIO_AF1_TIM8 ((uint8_t)0x01) /* TIM8 Alternate Function mapping */
  277. #define GPIO_AF1_LPTIM1 ((uint8_t)0x01) /* LPTIM1 Alternate Function mapping */
  278. #define GPIO_AF1_IR ((uint8_t)0x01) /* IR Alternate Function mapping */
  279. /**
  280. * @brief AF 2 selection
  281. */
  282. #define GPIO_AF2_TIM1 ((uint8_t)0x02) /* TIM1 Alternate Function mapping */
  283. #define GPIO_AF2_TIM2 ((uint8_t)0x02) /* TIM2 Alternate Function mapping */
  284. #define GPIO_AF2_TIM3 ((uint8_t)0x02) /* TIM3 Alternate Function mapping */
  285. #define GPIO_AF2_TIM4 ((uint8_t)0x02) /* TIM4 Alternate Function mapping */
  286. #define GPIO_AF2_TIM5 ((uint8_t)0x02) /* TIM5 Alternate Function mapping */
  287. /**
  288. * @brief AF 3 selection
  289. */
  290. #define GPIO_AF3_TIM8 ((uint8_t)0x03) /* TIM8 Alternate Function mapping */
  291. #define GPIO_AF3_TIM1_COMP2 ((uint8_t)0x03) /* TIM1/COMP2 Break in Alternate Function mapping */
  292. #define GPIO_AF3_TIM1_COMP1 ((uint8_t)0x03) /* TIM1/COMP1 Break in Alternate Function mapping */
  293. /**
  294. * @brief AF 4 selection
  295. */
  296. #define GPIO_AF4_I2C1 ((uint8_t)0x04) /* I2C1 Alternate Function mapping */
  297. #define GPIO_AF4_I2C2 ((uint8_t)0x04) /* I2C2 Alternate Function mapping */
  298. #define GPIO_AF4_I2C3 ((uint8_t)0x04) /* I2C3 Alternate Function mapping */
  299. /**
  300. * @brief AF 5 selection
  301. */
  302. #define GPIO_AF5_SPI1 ((uint8_t)0x05) /* SPI1 Alternate Function mapping */
  303. #define GPIO_AF5_SPI2 ((uint8_t)0x05) /* SPI2 Alternate Function mapping */
  304. /**
  305. * @brief AF 6 selection
  306. */
  307. #define GPIO_AF6_SPI3 ((uint8_t)0x06) /* SPI3 Alternate Function mapping */
  308. #define GPIO_AF6_DFSDM1 ((uint8_t)0x06) /* DFSDM1 Alternate Function mapping */
  309. /**
  310. * @brief AF 7 selection
  311. */
  312. #define GPIO_AF7_USART1 ((uint8_t)0x07) /* USART1 Alternate Function mapping */
  313. #define GPIO_AF7_USART2 ((uint8_t)0x07) /* USART2 Alternate Function mapping */
  314. #define GPIO_AF7_USART3 ((uint8_t)0x07) /* USART3 Alternate Function mapping */
  315. /**
  316. * @brief AF 8 selection
  317. */
  318. #define GPIO_AF8_UART4 ((uint8_t)0x08) /* UART4 Alternate Function mapping */
  319. #define GPIO_AF8_UART5 ((uint8_t)0x08) /* UART5 Alternate Function mapping */
  320. #define GPIO_AF8_LPUART1 ((uint8_t)0x08) /* LPUART1 Alternate Function mapping */
  321. /**
  322. * @brief AF 9 selection
  323. */
  324. #define GPIO_AF9_CAN1 ((uint8_t)0x09) /* CAN1 Alternate Function mapping */
  325. #define GPIO_AF9_TSC ((uint8_t)0x09) /* TSC Alternate Function mapping */
  326. /**
  327. * @brief AF 10 selection
  328. */
  329. #if defined(STM32L475xx) || defined(STM32L476xx) || defined(STM32L485xx) || defined(STM32L486xx)
  330. #define GPIO_AF10_OTG_FS ((uint8_t)0x0A) /* OTG_FS Alternate Function mapping */
  331. #endif /* STM32L475xx || STM32L476xx || STM32L485xx || STM32L486xx */
  332. #define GPIO_AF10_QUADSPI ((uint8_t)0x0A) /* QUADSPI Alternate Function mapping */
  333. #if defined(STM32L476xx) || defined(STM32L486xx)
  334. /**
  335. * @brief AF 11 selection
  336. */
  337. #define GPIO_AF11_LCD ((uint8_t)0x0B) /* LCD Alternate Function mapping */
  338. #endif /* STM32L476xx || STM32L486xx */
  339. /**
  340. * @brief AF 12 selection
  341. */
  342. #define GPIO_AF12_FMC ((uint8_t)0x0C) /* FMC Alternate Function mapping */
  343. #define GPIO_AF12_SWPMI1 ((uint8_t)0x0C) /* SWPMI1 Alternate Function mapping */
  344. #define GPIO_AF12_COMP1 ((uint8_t)0x0C) /* COMP1 Alternate Function mapping */
  345. #define GPIO_AF12_COMP2 ((uint8_t)0x0C) /* COMP2 Alternate Function mapping */
  346. #define GPIO_AF12_SDMMC1 ((uint8_t)0x0C) /* SDMMC1 Alternate Function mapping */
  347. /**
  348. * @brief AF 13 selection
  349. */
  350. #define GPIO_AF13_SAI1 ((uint8_t)0x0D) /* SAI1 Alternate Function mapping */
  351. #define GPIO_AF13_SAI2 ((uint8_t)0x0D) /* SAI2 Alternate Function mapping */
  352. #define GPIO_AF13_TIM8_COMP2 ((uint8_t)0x0D) /* TIM8/COMP2 Break in Alternate Function mapping */
  353. #define GPIO_AF13_TIM8_COMP1 ((uint8_t)0x0D) /* TIM8/COMP1 Break in Alternate Function mapping */
  354. /**
  355. * @brief AF 14 selection
  356. */
  357. #define GPIO_AF14_TIM2 ((uint8_t)0x0E) /* TIM2 Alternate Function mapping */
  358. #define GPIO_AF14_TIM15 ((uint8_t)0x0E) /* TIM15 Alternate Function mapping */
  359. #define GPIO_AF14_TIM16 ((uint8_t)0x0E) /* TIM16 Alternate Function mapping */
  360. #define GPIO_AF14_TIM17 ((uint8_t)0x0E) /* TIM17 Alternate Function mapping */
  361. #define GPIO_AF14_LPTIM2 ((uint8_t)0x0E) /* LPTIM2 Alternate Function mapping */
  362. #define GPIO_AF14_TIM8_COMP1 ((uint8_t)0x0E) /* TIM8/COMP1 Break in Alternate Function mapping */
  363. /**
  364. * @brief AF 15 selection
  365. */
  366. #define GPIO_AF15_EVENTOUT ((uint8_t)0x0F) /* EVENTOUT Alternate Function mapping */
  367. #define IS_GPIO_AF(AF) ((AF) <= (uint8_t)0x0F)
  368. #endif /* STM32L471xx || STM32L475xx || STM32L476xx || STM32L485xx || STM32L486xx */
  369. #if defined(STM32L496xx) || defined(STM32L4A6xx)
  370. /*--------------------------------STM32L496xx/STM32L4A6xx---------------------*/
  371. /**
  372. * @brief AF 0 selection
  373. */
  374. #define GPIO_AF0_RTC_50Hz ((uint8_t)0x00) /* RTC_50Hz Alternate Function mapping */
  375. #define GPIO_AF0_MCO ((uint8_t)0x00) /* MCO (MCO1 and MCO2) Alternate Function mapping */
  376. #define GPIO_AF0_SWJ ((uint8_t)0x00) /* SWJ (SWD and JTAG) Alternate Function mapping */
  377. #define GPIO_AF0_TRACE ((uint8_t)0x00) /* TRACE Alternate Function mapping */
  378. /**
  379. * @brief AF 1 selection
  380. */
  381. #define GPIO_AF1_TIM1 ((uint8_t)0x01) /* TIM1 Alternate Function mapping */
  382. #define GPIO_AF1_TIM2 ((uint8_t)0x01) /* TIM2 Alternate Function mapping */
  383. #define GPIO_AF1_TIM5 ((uint8_t)0x01) /* TIM5 Alternate Function mapping */
  384. #define GPIO_AF1_TIM8 ((uint8_t)0x01) /* TIM8 Alternate Function mapping */
  385. #define GPIO_AF1_LPTIM1 ((uint8_t)0x01) /* LPTIM1 Alternate Function mapping */
  386. #define GPIO_AF1_IR ((uint8_t)0x01) /* IR Alternate Function mapping */
  387. /**
  388. * @brief AF 2 selection
  389. */
  390. #define GPIO_AF2_TIM1 ((uint8_t)0x02) /* TIM1 Alternate Function mapping */
  391. #define GPIO_AF2_TIM2 ((uint8_t)0x02) /* TIM2 Alternate Function mapping */
  392. #define GPIO_AF2_TIM3 ((uint8_t)0x02) /* TIM3 Alternate Function mapping */
  393. #define GPIO_AF2_TIM4 ((uint8_t)0x02) /* TIM4 Alternate Function mapping */
  394. #define GPIO_AF2_TIM5 ((uint8_t)0x02) /* TIM5 Alternate Function mapping */
  395. #define GPIO_AF2_I2C4 ((uint8_t)0x02) /* I2C4 Alternate Function mapping */
  396. /**
  397. * @brief AF 3 selection
  398. */
  399. #define GPIO_AF3_TIM8 ((uint8_t)0x03) /* TIM8 Alternate Function mapping */
  400. #define GPIO_AF3_TIM1_COMP2 ((uint8_t)0x03) /* TIM1/COMP2 Break in Alternate Function mapping */
  401. #define GPIO_AF3_TIM1_COMP1 ((uint8_t)0x03) /* TIM1/COMP1 Break in Alternate Function mapping */
  402. #define GPIO_AF3_CAN2 ((uint8_t)0x03) /* CAN2 Alternate Function mapping */
  403. #define GPIO_AF3_I2C4 ((uint8_t)0x03) /* I2C4 Alternate Function mapping */
  404. #define GPIO_AF3_QUADSPI ((uint8_t)0x03) /* QUADSPI Alternate Function mapping */
  405. #define GPIO_AF3_SPI2 ((uint8_t)0x03) /* SPI2 Alternate Function mapping */
  406. #define GPIO_AF3_USART2 ((uint8_t)0x03) /* USART2 Alternate Function mapping */
  407. /**
  408. * @brief AF 4 selection
  409. */
  410. #define GPIO_AF4_I2C1 ((uint8_t)0x04) /* I2C1 Alternate Function mapping */
  411. #define GPIO_AF4_I2C2 ((uint8_t)0x04) /* I2C2 Alternate Function mapping */
  412. #define GPIO_AF4_I2C3 ((uint8_t)0x04) /* I2C3 Alternate Function mapping */
  413. #define GPIO_AF4_I2C4 ((uint8_t)0x04) /* I2C4 Alternate Function mapping */
  414. #define GPIO_AF4_DCMI ((uint8_t)0x04) /* DCMI Alternate Function mapping */
  415. /**
  416. * @brief AF 5 selection
  417. */
  418. #define GPIO_AF5_SPI1 ((uint8_t)0x05) /* SPI1 Alternate Function mapping */
  419. #define GPIO_AF5_SPI2 ((uint8_t)0x05) /* SPI2 Alternate Function mapping */
  420. #define GPIO_AF5_DCMI ((uint8_t)0x05) /* DCMI Alternate Function mapping */
  421. #define GPIO_AF5_I2C4 ((uint8_t)0x05) /* I2C4 Alternate Function mapping */
  422. #define GPIO_AF5_QUADSPI ((uint8_t)0x05) /* QUADSPI Alternate Function mapping */
  423. /**
  424. * @brief AF 6 selection
  425. */
  426. #define GPIO_AF6_SPI3 ((uint8_t)0x06) /* SPI3 Alternate Function mapping */
  427. #define GPIO_AF6_DFSDM1 ((uint8_t)0x06) /* DFSDM1 Alternate Function mapping */
  428. #define GPIO_AF6_I2C3 ((uint8_t)0x06) /* I2C3 Alternate Function mapping */
  429. /**
  430. * @brief AF 7 selection
  431. */
  432. #define GPIO_AF7_USART1 ((uint8_t)0x07) /* USART1 Alternate Function mapping */
  433. #define GPIO_AF7_USART2 ((uint8_t)0x07) /* USART2 Alternate Function mapping */
  434. #define GPIO_AF7_USART3 ((uint8_t)0x07) /* USART3 Alternate Function mapping */
  435. /**
  436. * @brief AF 8 selection
  437. */
  438. #define GPIO_AF8_UART4 ((uint8_t)0x08) /* UART4 Alternate Function mapping */
  439. #define GPIO_AF8_UART5 ((uint8_t)0x08) /* UART5 Alternate Function mapping */
  440. #define GPIO_AF8_LPUART1 ((uint8_t)0x08) /* LPUART1 Alternate Function mapping */
  441. #define GPIO_AF8_CAN2 ((uint8_t)0x08) /* CAN2 Alternate Function mapping */
  442. /**
  443. * @brief AF 9 selection
  444. */
  445. #define GPIO_AF9_CAN1 ((uint8_t)0x09) /* CAN1 Alternate Function mapping */
  446. #define GPIO_AF9_TSC ((uint8_t)0x09) /* TSC Alternate Function mapping */
  447. /**
  448. * @brief AF 10 selection
  449. */
  450. #define GPIO_AF10_OTG_FS ((uint8_t)0x0A) /* OTG_FS Alternate Function mapping */
  451. #define GPIO_AF10_QUADSPI ((uint8_t)0x0A) /* QUADSPI Alternate Function mapping */
  452. #define GPIO_AF10_CAN2 ((uint8_t)0x0A) /* CAN2 Alternate Function mapping */
  453. #define GPIO_AF10_DCMI ((uint8_t)0x0A) /* DCMI Alternate Function mapping */
  454. /**
  455. * @brief AF 11 selection
  456. */
  457. #define GPIO_AF11_LCD ((uint8_t)0x0B) /* LCD Alternate Function mapping */
  458. /**
  459. * @brief AF 12 selection
  460. */
  461. #define GPIO_AF12_FMC ((uint8_t)0x0C) /* FMC Alternate Function mapping */
  462. #define GPIO_AF12_SWPMI1 ((uint8_t)0x0C) /* SWPMI1 Alternate Function mapping */
  463. #define GPIO_AF12_COMP1 ((uint8_t)0x0C) /* COMP1 Alternate Function mapping */
  464. #define GPIO_AF12_COMP2 ((uint8_t)0x0C) /* COMP2 Alternate Function mapping */
  465. #define GPIO_AF12_SDMMC1 ((uint8_t)0x0C) /* SDMMC1 Alternate Function mapping */
  466. #define GPIO_AF12_TIM1_COMP2 ((uint8_t)0x0C) /* TIM1/COMP2 Break in Alternate Function mapping */
  467. #define GPIO_AF12_TIM1_COMP1 ((uint8_t)0x0C) /* TIM1/COMP1 Break in Alternate Function mapping */
  468. #define GPIO_AF12_TIM8_COMP2 ((uint8_t)0x0C) /* TIM8/COMP2 Break in Alternate Function mapping */
  469. /**
  470. * @brief AF 13 selection
  471. */
  472. #define GPIO_AF13_SAI1 ((uint8_t)0x0D) /* SAI1 Alternate Function mapping */
  473. #define GPIO_AF13_SAI2 ((uint8_t)0x0D) /* SAI2 Alternate Function mapping */
  474. #define GPIO_AF13_TIM8_COMP2 ((uint8_t)0x0D) /* TIM8/COMP2 Break in Alternate Function mapping */
  475. #define GPIO_AF13_TIM8_COMP1 ((uint8_t)0x0D) /* TIM8/COMP1 Break in Alternate Function mapping */
  476. /**
  477. * @brief AF 14 selection
  478. */
  479. #define GPIO_AF14_TIM2 ((uint8_t)0x0E) /* TIM2 Alternate Function mapping */
  480. #define GPIO_AF14_TIM15 ((uint8_t)0x0E) /* TIM15 Alternate Function mapping */
  481. #define GPIO_AF14_TIM16 ((uint8_t)0x0E) /* TIM16 Alternate Function mapping */
  482. #define GPIO_AF14_TIM17 ((uint8_t)0x0E) /* TIM17 Alternate Function mapping */
  483. #define GPIO_AF14_LPTIM2 ((uint8_t)0x0E) /* LPTIM2 Alternate Function mapping */
  484. #define GPIO_AF14_TIM8_COMP1 ((uint8_t)0x0E) /* TIM8/COMP1 Break in Alternate Function mapping */
  485. /**
  486. * @brief AF 15 selection
  487. */
  488. #define GPIO_AF15_EVENTOUT ((uint8_t)0x0F) /* EVENTOUT Alternate Function mapping */
  489. #define IS_GPIO_AF(AF) ((AF) <= (uint8_t)0x0F)
  490. #endif /* STM32L496xx || STM32L4A6xx */
  491. #if defined (STM32L4R5xx) || defined (STM32L4R7xx) || defined (STM32L4R9xx) || defined (STM32L4S5xx) || defined (STM32L4S7xx) || defined (STM32L4S9xx)
  492. /*---STM32L4R5xx/STM32L4R7xx/STM32L4R9xx/STM32L4S5xx/STM32L4S7xx/STM32L4S9xx--*/
  493. /**
  494. * @brief AF 0 selection
  495. */
  496. #define GPIO_AF0_RTC_50Hz ((uint8_t)0x00) /* RTC_50Hz Alternate Function mapping */
  497. #define GPIO_AF0_MCO ((uint8_t)0x00) /* MCO (MCO1 and MCO2) Alternate Function mapping */
  498. #define GPIO_AF0_SWJ ((uint8_t)0x00) /* SWJ (SWD and JTAG) Alternate Function mapping */
  499. #define GPIO_AF0_TRACE ((uint8_t)0x00) /* TRACE Alternate Function mapping */
  500. /**
  501. * @brief AF 1 selection
  502. */
  503. #define GPIO_AF1_TIM1 ((uint8_t)0x01) /* TIM1 Alternate Function mapping */
  504. #define GPIO_AF1_TIM2 ((uint8_t)0x01) /* TIM2 Alternate Function mapping */
  505. #define GPIO_AF1_TIM5 ((uint8_t)0x01) /* TIM5 Alternate Function mapping */
  506. #define GPIO_AF1_TIM8 ((uint8_t)0x01) /* TIM8 Alternate Function mapping */
  507. #define GPIO_AF1_LPTIM1 ((uint8_t)0x01) /* LPTIM1 Alternate Function mapping */
  508. #define GPIO_AF1_IR ((uint8_t)0x01) /* IR Alternate Function mapping */
  509. /**
  510. * @brief AF 2 selection
  511. */
  512. #define GPIO_AF2_TIM1 ((uint8_t)0x02) /* TIM1 Alternate Function mapping */
  513. #define GPIO_AF2_TIM2 ((uint8_t)0x02) /* TIM2 Alternate Function mapping */
  514. #define GPIO_AF2_TIM3 ((uint8_t)0x02) /* TIM3 Alternate Function mapping */
  515. #define GPIO_AF2_TIM4 ((uint8_t)0x02) /* TIM4 Alternate Function mapping */
  516. #define GPIO_AF2_TIM5 ((uint8_t)0x02) /* TIM5 Alternate Function mapping */
  517. /**
  518. * @brief AF 3 selection
  519. */
  520. #define GPIO_AF3_I2C4 ((uint8_t)0x03) /* I2C4 Alternate Function mapping */
  521. #define GPIO_AF3_OCTOSPIM_P1 ((uint8_t)0x03) /* OctoSPI Manager Port 1 Alternate Function mapping */
  522. #define GPIO_AF3_SAI1 ((uint8_t)0x03) /* SAI1 Alternate Function mapping */
  523. #define GPIO_AF3_SPI2 ((uint8_t)0x03) /* SPI2 Alternate Function mapping */
  524. #define GPIO_AF3_TIM1_COMP1 ((uint8_t)0x03) /* TIM1/COMP1 Break in Alternate Function mapping */
  525. #define GPIO_AF3_TIM1_COMP2 ((uint8_t)0x03) /* TIM1/COMP2 Break in Alternate Function mapping */
  526. #define GPIO_AF3_TIM8 ((uint8_t)0x03) /* TIM8 Alternate Function mapping */
  527. #define GPIO_AF3_TIM8_COMP1 ((uint8_t)0x03) /* TIM8/COMP1 Break in Alternate Function mapping */
  528. #define GPIO_AF3_TIM8_COMP2 ((uint8_t)0x03) /* TIM8/COMP2 Break in Alternate Function mapping */
  529. #define GPIO_AF3_USART2 ((uint8_t)0x03) /* USART2 Alternate Function mapping */
  530. /**
  531. * @brief AF 4 selection
  532. */
  533. #define GPIO_AF4_I2C1 ((uint8_t)0x04) /* I2C1 Alternate Function mapping */
  534. #define GPIO_AF4_I2C2 ((uint8_t)0x04) /* I2C2 Alternate Function mapping */
  535. #define GPIO_AF4_I2C3 ((uint8_t)0x04) /* I2C3 Alternate Function mapping */
  536. #define GPIO_AF4_I2C4 ((uint8_t)0x04) /* I2C4 Alternate Function mapping */
  537. #define GPIO_AF4_DCMI ((uint8_t)0x04) /* DCMI Alternate Function mapping */
  538. /**
  539. * @brief AF 5 selection
  540. */
  541. #define GPIO_AF5_DCMI ((uint8_t)0x05) /* DCMI Alternate Function mapping */
  542. #define GPIO_AF5_DFSDM1 ((uint8_t)0x05) /* DFSDM1 Alternate Function mapping */
  543. #define GPIO_AF5_I2C4 ((uint8_t)0x05) /* I2C4 Alternate Function mapping */
  544. #define GPIO_AF5_OCTOSPIM_P1 ((uint8_t)0x05) /* OctoSPI Manager Port 1 Alternate Function mapping */
  545. #define GPIO_AF5_OCTOSPIM_P2 ((uint8_t)0x05) /* OctoSPI Manager Port 2 Alternate Function mapping */
  546. #define GPIO_AF5_SPI1 ((uint8_t)0x05) /* SPI1 Alternate Function mapping */
  547. #define GPIO_AF5_SPI2 ((uint8_t)0x05) /* SPI2 Alternate Function mapping */
  548. #define GPIO_AF5_SPI3 ((uint8_t)0x05) /* SPI2 Alternate Function mapping */
  549. /**
  550. * @brief AF 6 selection
  551. */
  552. #define GPIO_AF6_DFSDM1 ((uint8_t)0x06) /* DFSDM1 Alternate Function mapping */
  553. #define GPIO_AF6_I2C3 ((uint8_t)0x06) /* I2C3 Alternate Function mapping */
  554. #define GPIO_AF6_SPI3 ((uint8_t)0x06) /* SPI3 Alternate Function mapping */
  555. /**
  556. * @brief AF 7 selection
  557. */
  558. #define GPIO_AF7_USART1 ((uint8_t)0x07) /* USART1 Alternate Function mapping */
  559. #define GPIO_AF7_USART2 ((uint8_t)0x07) /* USART2 Alternate Function mapping */
  560. #define GPIO_AF7_USART3 ((uint8_t)0x07) /* USART3 Alternate Function mapping */
  561. /**
  562. * @brief AF 8 selection
  563. */
  564. #define GPIO_AF8_LPUART1 ((uint8_t)0x08) /* LPUART1 Alternate Function mapping */
  565. #define GPIO_AF8_SDMMC1 ((uint8_t)0x08) /* SDMMC1 Alternate Function mapping */
  566. #define GPIO_AF8_UART4 ((uint8_t)0x08) /* UART4 Alternate Function mapping */
  567. #define GPIO_AF8_UART5 ((uint8_t)0x08) /* UART5 Alternate Function mapping */
  568. /**
  569. * @brief AF 9 selection
  570. */
  571. #define GPIO_AF9_CAN1 ((uint8_t)0x09) /* CAN1 Alternate Function mapping */
  572. #define GPIO_AF9_LTDC ((uint8_t)0x09) /* LTDC Alternate Function mapping */
  573. #define GPIO_AF9_TSC ((uint8_t)0x09) /* TSC Alternate Function mapping */
  574. /**
  575. * @brief AF 10 selection
  576. */
  577. #define GPIO_AF10_DCMI ((uint8_t)0x0A) /* DCMI Alternate Function mapping */
  578. #define GPIO_AF10_OCTOSPIM_P1 ((uint8_t)0x0A) /* OctoSPI Manager Port 1 Alternate Function mapping */
  579. #define GPIO_AF10_OCTOSPIM_P2 ((uint8_t)0x0A) /* OctoSPI Manager Port 2 Alternate Function mapping */
  580. #define GPIO_AF10_OTG_FS ((uint8_t)0x0A) /* OTG_FS Alternate Function mapping */
  581. /**
  582. * @brief AF 11 selection
  583. */
  584. #define GPIO_AF11_DSI ((uint8_t)0x0B) /* DSI Alternate Function mapping */
  585. #define GPIO_AF11_LTDC ((uint8_t)0x0B) /* LTDC Alternate Function mapping */
  586. /**
  587. * @brief AF 12 selection
  588. */
  589. #define GPIO_AF12_COMP1 ((uint8_t)0x0C) /* COMP1 Alternate Function mapping */
  590. #define GPIO_AF12_COMP2 ((uint8_t)0x0C) /* COMP2 Alternate Function mapping */
  591. #define GPIO_AF12_DSI ((uint8_t)0x0C) /* FMC Alternate Function mapping */
  592. #define GPIO_AF12_FMC ((uint8_t)0x0C) /* FMC Alternate Function mapping */
  593. #define GPIO_AF12_SDMMC1 ((uint8_t)0x0C) /* SDMMC1 Alternate Function mapping */
  594. #define GPIO_AF12_TIM1_COMP1 ((uint8_t)0x0C) /* TIM1/COMP1 Break in Alternate Function mapping */
  595. #define GPIO_AF12_TIM1_COMP2 ((uint8_t)0x0C) /* TIM1/COMP2 Break in Alternate Function mapping */
  596. #define GPIO_AF12_TIM8_COMP2 ((uint8_t)0x0C) /* TIM8/COMP2 Break in Alternate Function mapping */
  597. /**
  598. * @brief AF 13 selection
  599. */
  600. #define GPIO_AF13_SAI1 ((uint8_t)0x0D) /* SAI1 Alternate Function mapping */
  601. #define GPIO_AF13_SAI2 ((uint8_t)0x0D) /* SAI2 Alternate Function mapping */
  602. #define GPIO_AF13_TIM8_COMP1 ((uint8_t)0x0D) /* TIM8/COMP1 Break in Alternate Function mapping */
  603. /**
  604. * @brief AF 14 selection
  605. */
  606. #define GPIO_AF14_TIM15 ((uint8_t)0x0E) /* TIM15 Alternate Function mapping */
  607. #define GPIO_AF14_TIM16 ((uint8_t)0x0E) /* TIM16 Alternate Function mapping */
  608. #define GPIO_AF14_TIM17 ((uint8_t)0x0E) /* TIM17 Alternate Function mapping */
  609. #define GPIO_AF14_LPTIM2 ((uint8_t)0x0E) /* LPTIM2 Alternate Function mapping */
  610. #define GPIO_AF14_TIM8_COMP2 ((uint8_t)0x0E) /* TIM8/COMP2 Break in Alternate Function mapping */
  611. /**
  612. * @brief AF 15 selection
  613. */
  614. #define GPIO_AF15_EVENTOUT ((uint8_t)0x0F) /* EVENTOUT Alternate Function mapping */
  615. #define IS_GPIO_AF(AF) ((AF) <= (uint8_t)0x0F)
  616. #endif /* STM32L4R5xx || STM32L4R7xx || STM32L4R9xx || STM32L4S5xx || STM32L4S7xx || STM32L4S9xx */
  617. /**
  618. * @}
  619. */
  620. /**
  621. * @}
  622. */
  623. /* Exported macro ------------------------------------------------------------*/
  624. /** @defgroup GPIOEx_Exported_Macros GPIOEx Exported Macros
  625. * @{
  626. */
  627. /** @defgroup GPIOEx_Get_Port_Index GPIOEx_Get Port Index
  628. * @{
  629. */
  630. #if defined(STM32L431xx) || defined(STM32L433xx) || defined(STM32L443xx)
  631. #define GPIO_GET_INDEX(__GPIOx__) (((__GPIOx__) == (GPIOA))? 0U :\
  632. ((__GPIOx__) == (GPIOB))? 1U :\
  633. ((__GPIOx__) == (GPIOC))? 2U :\
  634. ((__GPIOx__) == (GPIOD))? 3U :\
  635. ((__GPIOx__) == (GPIOE))? 4U : 7U)
  636. #endif /* STM32L431xx || STM32L433xx || STM32L443xx */
  637. #if defined(STM32L432xx) || defined(STM32L442xx)
  638. #define GPIO_GET_INDEX(__GPIOx__) (((__GPIOx__) == (GPIOA))? 0U :\
  639. ((__GPIOx__) == (GPIOB))? 1U :\
  640. ((__GPIOx__) == (GPIOC))? 2U : 7U)
  641. #endif /* STM32L432xx || STM32L442xx */
  642. #if defined(STM32L451xx) || defined(STM32L452xx) || defined(STM32L462xx)
  643. #define GPIO_GET_INDEX(__GPIOx__) (((__GPIOx__) == (GPIOA))? 0U :\
  644. ((__GPIOx__) == (GPIOB))? 1U :\
  645. ((__GPIOx__) == (GPIOC))? 2U :\
  646. ((__GPIOx__) == (GPIOD))? 3U :\
  647. ((__GPIOx__) == (GPIOE))? 4U : 7U)
  648. #endif /* STM32L451xx || STM32L452xx || STM32L462xx */
  649. #if defined(STM32L471xx) || defined(STM32L475xx) || defined(STM32L476xx) || defined(STM32L485xx) || defined(STM32L486xx)
  650. #define GPIO_GET_INDEX(__GPIOx__) (((__GPIOx__) == (GPIOA))? 0U :\
  651. ((__GPIOx__) == (GPIOB))? 1U :\
  652. ((__GPIOx__) == (GPIOC))? 2U :\
  653. ((__GPIOx__) == (GPIOD))? 3U :\
  654. ((__GPIOx__) == (GPIOE))? 4U :\
  655. ((__GPIOx__) == (GPIOF))? 5U :\
  656. ((__GPIOx__) == (GPIOG))? 6U : 7U)
  657. #endif /* STM32L471xx || STM32L475xx || STM32L476xx || STM32L485xx || STM32L486xx */
  658. #if defined(STM32L496xx) || defined(STM32L4A6xx)
  659. #define GPIO_GET_INDEX(__GPIOx__) (((__GPIOx__) == (GPIOA))? 0U :\
  660. ((__GPIOx__) == (GPIOB))? 1U :\
  661. ((__GPIOx__) == (GPIOC))? 2U :\
  662. ((__GPIOx__) == (GPIOD))? 3U :\
  663. ((__GPIOx__) == (GPIOE))? 4U :\
  664. ((__GPIOx__) == (GPIOF))? 5U :\
  665. ((__GPIOx__) == (GPIOG))? 6U :\
  666. ((__GPIOx__) == (GPIOH))? 7U : 8U)
  667. #endif /* STM32L496xx || STM32L4A6xx */
  668. #if defined (STM32L4R5xx) || defined (STM32L4R7xx) || defined (STM32L4R9xx) || defined (STM32L4S5xx) || defined (STM32L4S7xx) || defined (STM32L4S9xx)
  669. #define GPIO_GET_INDEX(__GPIOx__) (((__GPIOx__) == (GPIOA))? 0U :\
  670. ((__GPIOx__) == (GPIOB))? 1U :\
  671. ((__GPIOx__) == (GPIOC))? 2U :\
  672. ((__GPIOx__) == (GPIOD))? 3U :\
  673. ((__GPIOx__) == (GPIOE))? 4U :\
  674. ((__GPIOx__) == (GPIOF))? 5U :\
  675. ((__GPIOx__) == (GPIOG))? 6U :\
  676. ((__GPIOx__) == (GPIOH))? 7U : 8U)
  677. #endif /* STM32L4R5xx || STM32L4R7xx || STM32L4R9xx || STM32L4S5xx || STM32L4S7xx || STM32L4S9xx */
  678. /**
  679. * @}
  680. */
  681. /**
  682. * @}
  683. */
  684. /* Exported functions --------------------------------------------------------*/
  685. /**
  686. * @}
  687. */
  688. /**
  689. * @}
  690. */
  691. #ifdef __cplusplus
  692. }
  693. #endif
  694. #endif /* __STM32L4xx_HAL_GPIO_EX_H */
  695. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/