stm32l1xx_hal_gpio_ex.h 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260
  1. /**
  2. ******************************************************************************
  3. * @file stm32l1xx_hal_gpio_ex.h
  4. * @author MCD Application Team
  5. * @version V1.0.0
  6. * @date 5-September-2014
  7. * @brief Header file of GPIO HAL Extension module.
  8. ******************************************************************************
  9. * @attention
  10. *
  11. * <h2><center>&copy; COPYRIGHT(c) 2014 STMicroelectronics</center></h2>
  12. *
  13. * Redistribution and use in source and binary forms, with or without modification,
  14. * are permitted provided that the following conditions are met:
  15. * 1. Redistributions of source code must retain the above copyright notice,
  16. * this list of conditions and the following disclaimer.
  17. * 2. Redistributions in binary form must reproduce the above copyright notice,
  18. * this list of conditions and the following disclaimer in the documentation
  19. * and/or other materials provided with the distribution.
  20. * 3. Neither the name of STMicroelectronics nor the names of its contributors
  21. * may be used to endorse or promote products derived from this software
  22. * without specific prior written permission.
  23. *
  24. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  25. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  26. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  27. * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
  28. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  29. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  30. * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  31. * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  32. * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  33. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  34. *
  35. ******************************************************************************
  36. */
  37. /* Define to prevent recursive inclusion -------------------------------------*/
  38. #ifndef __STM32L1xx_HAL_GPIO_EX_H
  39. #define __STM32L1xx_HAL_GPIO_EX_H
  40. #ifdef __cplusplus
  41. extern "C" {
  42. #endif
  43. /* Includes ------------------------------------------------------------------*/
  44. #include "stm32l1xx_hal_def.h"
  45. /** @addtogroup STM32L1xx_HAL_Driver
  46. * @{
  47. */
  48. /** @defgroup GPIOEx GPIOEx
  49. * @{
  50. */
  51. /* Exported types ------------------------------------------------------------*/
  52. /* Exported constants --------------------------------------------------------*/
  53. /** @defgroup GPIOEx_Exported_Constants GPIOEx Exported Constants
  54. * @{
  55. */
  56. /** @defgroup GPIOEx_Alternate_function_selection GPIOEx Alternate function selection
  57. * @{
  58. */
  59. /**
  60. * @brief AF 0 selection
  61. */
  62. #define GPIO_AF0_MCO ((uint8_t)0x00) /* MCO Alternate Function mapping */
  63. #define GPIO_AF0_TAMPER ((uint8_t)0x00) /* TAMPER Alternate Function mapping */
  64. #define GPIO_AF0_SWJ ((uint8_t)0x00) /* SWJ (SWD and JTAG) Alternate Function mapping */
  65. #define GPIO_AF0_TRACE ((uint8_t)0x00) /* TRACE Alternate Function mapping */
  66. #define GPIO_AF0_RTC_50Hz ((uint8_t)0x00) /* RTC_OUT Alternate Function mapping */
  67. /**
  68. * @brief AF 1 selection
  69. */
  70. #define GPIO_AF1_TIM2 ((uint8_t)0x01) /* TIM2 Alternate Function mapping */
  71. /**
  72. * @brief AF 2 selection
  73. */
  74. #define GPIO_AF2_TIM3 ((uint8_t)0x02) /* TIM3 Alternate Function mapping */
  75. #define GPIO_AF2_TIM4 ((uint8_t)0x02) /* TIM4 Alternate Function mapping */
  76. #if defined (STM32L151xCA) || defined (STM32L151xD) || defined (STM32L152xCA) || defined (STM32L152xD) || defined (STM32L162xCA) || defined (STM32L162xD) || defined (STM32L151xE) || defined (STM32L152xE) || defined (STM32L162xE) || defined (STM32L162xC) || defined (STM32L152xC) || defined (STM32L151xC)
  77. #define GPIO_AF2_TIM5 ((uint8_t)0x02) /* TIM5 Alternate Function mapping */
  78. #endif /* STM32L151xCA || STM32L151xD || STM32L152xCA || STM32L152xD || STM32L162xCA || STM32L162xD ...STM32L151xC */
  79. /**
  80. * @brief AF 3 selection
  81. */
  82. #define GPIO_AF3_TIM9 ((uint8_t)0x03) /* TIM9 Alternate Function mapping */
  83. #define GPIO_AF3_TIM10 ((uint8_t)0x03) /* TIM10 Alternate Function mapping */
  84. #define GPIO_AF3_TIM11 ((uint8_t)0x03) /* TIM11 Alternate Function mapping */
  85. /**
  86. * @brief AF 4 selection
  87. */
  88. #define GPIO_AF4_I2C1 ((uint8_t)0x04) /* I2C1 Alternate Function mapping */
  89. #define GPIO_AF4_I2C2 ((uint8_t)0x04) /* I2C2 Alternate Function mapping */
  90. /**
  91. * @brief AF 5 selection
  92. */
  93. #define GPIO_AF5_SPI1 ((uint8_t)0x05) /* SPI1/I2S1 Alternate Function mapping */
  94. #define GPIO_AF5_SPI2 ((uint8_t)0x05) /* SPI2/I2S2 Alternate Function mapping */
  95. /**
  96. * @brief AF 6 selection
  97. */
  98. #if defined (STM32L100xC) || defined (STM32L151xC) || defined (STM32L151xCA) || defined (STM32L151xD) || defined (STM32L151xE) ||\
  99. defined (STM32L152xC) || defined (STM32L152xCA) || defined (STM32L152xD) || defined (STM32L152xE) ||\
  100. defined (STM32L162xC) || defined (STM32L162xCA) || defined (STM32L162xD) || defined (STM32L162xE)
  101. #define GPIO_AF6_SPI3 ((uint8_t)0x06) /* SPI3/I2S3 Alternate Function mapping */
  102. #endif /* STM32L100xC || STM32L151xC || (...) || STM32L162xD || STM32L162xE */
  103. /**
  104. * @brief AF 7 selection
  105. */
  106. #define GPIO_AF7_USART1 ((uint8_t)0x07) /* USART1 Alternate Function mapping */
  107. #define GPIO_AF7_USART2 ((uint8_t)0x07) /* USART2 Alternate Function mapping */
  108. #define GPIO_AF7_USART3 ((uint8_t)0x07) /* USART3 Alternate Function mapping */
  109. /**
  110. * @brief AF 8 selection
  111. */
  112. #if defined (STM32L151xD) || defined (STM32L151xE) ||\
  113. defined (STM32L152xD) || defined (STM32L152xE) ||\
  114. defined (STM32L162xD) || defined (STM32L162xE)
  115. #define GPIO_AF8_UART4 ((uint8_t)0x08) /* UART4 Alternate Function mapping */
  116. #define GPIO_AF8_UART5 ((uint8_t)0x08) /* UART5 Alternate Function mapping */
  117. #endif /* STM32L151xD || STM32L151xE || STM32L152xD || STM32L 152xE || STM32L162xD || STM32L162xE */
  118. /**
  119. * @brief AF 9 selection
  120. */
  121. /**
  122. * @brief AF 10 selection
  123. */
  124. /**
  125. * @brief AF 11 selection
  126. */
  127. #if defined (STM32L100xB) || defined (STM32L100xBA) || defined (STM32L100xC) ||\
  128. defined (STM32L152xB) || defined (STM32L152xBA) || defined (STM32L152xC) || defined (STM32L152xCA) || defined (STM32L152xD) || defined (STM32L152xE) ||\
  129. defined (STM32L162xC) || defined (STM32L162xCA) || defined (STM32L162xD) || defined (STM32L162xE)
  130. #define GPIO_AF11_LCD ((uint8_t)0x0B) /* LCD Alternate Function mapping */
  131. #endif /* STM32L100xB || STM32L100xBA || STM32L100xC || (...) || STM32L162xCA || STM32L162xD || STM32L162xE */
  132. /**
  133. * @brief AF 12 selection
  134. */
  135. #if defined (STM32L151xD) || defined (STM32L152xD) || defined (STM32L162xD)
  136. #define GPIO_AF12_FSMC ((uint8_t)0x0C) /* FSMC Alternate Function mapping */
  137. #define GPIO_AF12_SDIO ((uint8_t)0x0C) /* SDIO Alternate Function mapping */
  138. #endif /* STM32L151xD || STM32L152xD || STM32L162xD */
  139. /**
  140. * @brief AF 13 selection
  141. */
  142. /**
  143. * @brief AF 14 selection
  144. */
  145. #define GPIO_AF14_TIM_IC1 ((uint8_t)0x0E) /* TIMER INPUT CAPTURE Alternate Function mapping */
  146. #define GPIO_AF14_TIM_IC2 ((uint8_t)0x0E) /* TIMER INPUT CAPTURE Alternate Function mapping */
  147. #define GPIO_AF14_TIM_IC3 ((uint8_t)0x0E) /* TIMER INPUT CAPTURE Alternate Function mapping */
  148. #define GPIO_AF14_TIM_IC4 ((uint8_t)0x0E) /* TIMER INPUT CAPTURE Alternate Function mapping */
  149. /**
  150. * @brief AF 15 selection
  151. */
  152. #define GPIO_AF15_EVENTOUT ((uint8_t)0x0F) /* EVENTOUT Alternate Function mapping */
  153. /**
  154. * @}
  155. */
  156. /**
  157. * @}
  158. */
  159. /** @defgroup GPIOEx_Private_Macros GPIOEx Private Macros
  160. * @{
  161. */
  162. #define IS_GPIO_AF(AF) ((AF) <= (uint8_t)0x0F)
  163. #if defined (STM32L151xCA) || defined (STM32L151xD) || defined (STM32L152xCA) || defined (STM32L152xD) || defined (STM32L162xCA) || defined (STM32L162xD) || defined (STM32L151xE) || defined (STM32L152xE) || defined (STM32L162xE)
  164. #define GET_GPIO_INDEX(__GPIOx__) (((__GPIOx__) == (GPIOA))? 0U :\
  165. ((__GPIOx__) == (GPIOB))? 1U :\
  166. ((__GPIOx__) == (GPIOC))? 2U :\
  167. ((__GPIOx__) == (GPIOD))? 3U :\
  168. ((__GPIOx__) == (GPIOE))? 4U :\
  169. ((__GPIOx__) == (GPIOF))? 5U :\
  170. ((__GPIOx__) == (GPIOG))? 6U :\
  171. ((__GPIOx__) == (GPIOH))? 7U : 8U)
  172. #endif
  173. #if defined (STM32L151xB) || defined (STM32L151xBA) || defined (STM32L151xC) || defined (STM32L152xB) || defined (STM32L152xBA) || defined (STM32L152xC) || defined (STM32L162xC)
  174. #define GET_GPIO_INDEX(__GPIOx__) (((__GPIOx__) == (GPIOA))? 0U :\
  175. ((__GPIOx__) == (GPIOB))? 1U :\
  176. ((__GPIOx__) == (GPIOC))? 2U :\
  177. ((__GPIOx__) == (GPIOD))? 3U :\
  178. ((__GPIOx__) == (GPIOE))? 4U :\
  179. ((__GPIOx__) == (GPIOH))? 7U : 8U)
  180. #endif
  181. #if defined (STM32L100xB) || defined (STM32L100xBA) || defined (STM32L100xC)
  182. #define GET_GPIO_INDEX(__GPIOx__) (((__GPIOx__) == (GPIOA))? 0U :\
  183. ((__GPIOx__) == (GPIOB))? 1U :\
  184. ((__GPIOx__) == (GPIOC))? 2U :\
  185. ((__GPIOx__) == (GPIOD))? 3U :\
  186. ((__GPIOx__) == (GPIOH))? 7U : 8U)
  187. #endif
  188. /**
  189. * @}
  190. */
  191. /* Exported macro ------------------------------------------------------------*/
  192. /* Exported functions --------------------------------------------------------*/
  193. /**
  194. * @}
  195. */
  196. /**
  197. * @}
  198. */
  199. #ifdef __cplusplus
  200. }
  201. #endif
  202. #endif /* __STM32L1xx_HAL_GPIO_EX_H */
  203. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/