1 /** 2 ****************************************************************************** 3 * @file stm32l1xx_hal_gpio_ex.h 4 * @author MCD Application Team 5 * @brief Header file of GPIO HAL Extension module. 6 ****************************************************************************** 7 * @attention 8 * 9 * Copyright (c) 2017 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 19 /* Define to prevent recursive inclusion -------------------------------------*/ 20 #ifndef __STM32L1xx_HAL_GPIO_EX_H 21 #define __STM32L1xx_HAL_GPIO_EX_H 22 23 #ifdef __cplusplus 24 extern "C" { 25 #endif 26 27 /* Includes ------------------------------------------------------------------*/ 28 #include "stm32l1xx_hal_def.h" 29 30 /** @addtogroup STM32L1xx_HAL_Driver 31 * @{ 32 */ 33 34 /** @defgroup GPIOEx GPIOEx 35 * @{ 36 */ 37 38 /* Exported types ------------------------------------------------------------*/ 39 /* Exported constants --------------------------------------------------------*/ 40 /** @defgroup GPIOEx_Exported_Constants GPIOEx Exported Constants 41 * @{ 42 */ 43 44 /** @defgroup GPIOEx_Alternate_function_selection GPIOEx Alternate function selection 45 * @{ 46 */ 47 48 /* AF 0 selection */ 49 #define GPIO_AF0_MCO ((uint8_t)0x00) /*!< MCO Alternate Function mapping */ 50 #define GPIO_AF0_TAMPER ((uint8_t)0x00) /*!< TAMPER Alternate Function mapping */ 51 #define GPIO_AF0_SWJ ((uint8_t)0x00) /*!< SWJ (SWD and JTAG) Alternate Function mapping */ 52 #define GPIO_AF0_TRACE ((uint8_t)0x00) /*!< TRACE Alternate Function mapping */ 53 #define GPIO_AF0_RTC_50Hz ((uint8_t)0x00) /*!< RTC_OUT Alternate Function mapping */ 54 55 /* AF 1 selection */ 56 #define GPIO_AF1_TIM2 ((uint8_t)0x01) /*!< TIM2 Alternate Function mapping */ 57 58 /* AF 2 selection */ 59 #define GPIO_AF2_TIM3 ((uint8_t)0x02) /*!< TIM3 Alternate Function mapping */ 60 #define GPIO_AF2_TIM4 ((uint8_t)0x02) /*!< TIM4 Alternate Function mapping */ 61 #if defined (STM32L151xCA) || defined (STM32L151xD) || defined (STM32L152xCA) || defined (STM32L152xD) || defined (STM32L162xCA) || defined (STM32L162xD) || defined (STM32L151xE) || defined (STM32L151xDX) || defined (STM32L152xE) || defined (STM32L152xDX) || defined (STM32L162xE) || defined (STM32L162xDX) || defined (STM32L162xC) || defined (STM32L152xC) || defined (STM32L151xC) 62 #define GPIO_AF2_TIM5 ((uint8_t)0x02) /*!< TIM5 Alternate Function mapping */ 63 64 #endif /* STM32L151xCA || STM32L151xD || STM32L152xCA || STM32L152xD || STM32L162xCA || STM32L162xD ...STM32L151xC */ 65 66 /* AF 3 selection */ 67 #define GPIO_AF3_TIM9 ((uint8_t)0x03) /*!< TIM9 Alternate Function mapping */ 68 #define GPIO_AF3_TIM10 ((uint8_t)0x03) /*!< TIM10 Alternate Function mapping */ 69 #define GPIO_AF3_TIM11 ((uint8_t)0x03) /*!< TIM11 Alternate Function mapping */ 70 71 72 /* AF 4 selection */ 73 #define GPIO_AF4_I2C1 ((uint8_t)0x04) /*!< I2C1 Alternate Function mapping */ 74 #define GPIO_AF4_I2C2 ((uint8_t)0x04) /*!< I2C2 Alternate Function mapping */ 75 76 /* AF 5 selection */ 77 #define GPIO_AF5_SPI1 ((uint8_t)0x05) /*!< SPI1/I2S1 Alternate Function mapping */ 78 #define GPIO_AF5_SPI2 ((uint8_t)0x05) /*!< SPI2/I2S2 Alternate Function mapping */ 79 80 /* AF 6 selection */ 81 #if defined (STM32L100xC) || defined (STM32L151xC) || defined (STM32L151xCA) || defined (STM32L151xD) || defined (STM32L151xE) || defined (STM32L151xDX) ||\ 82 defined (STM32L152xC) || defined (STM32L152xCA) || defined (STM32L152xD) || defined (STM32L152xE) || defined (STM32L152xDX) ||\ 83 defined (STM32L162xC) || defined (STM32L162xCA) || defined (STM32L162xD) || defined (STM32L162xE) || defined (STM32L162xDX) 84 85 #define GPIO_AF6_SPI3 ((uint8_t)0x06) /*!< SPI3/I2S3 Alternate Function mapping */ 86 87 #endif /* STM32L100xC || STM32L151xC || (...) || STM32L162xD || STM32L162xE || STM32L162xDX */ 88 89 90 /* AF 7 selection */ 91 #define GPIO_AF7_USART1 ((uint8_t)0x07) /*!< USART1 Alternate Function mapping */ 92 #define GPIO_AF7_USART2 ((uint8_t)0x07) /*!< USART2 Alternate Function mapping */ 93 #define GPIO_AF7_USART3 ((uint8_t)0x07) /*!< USART3 Alternate Function mapping */ 94 95 /* AF 8 selection */ 96 #if defined (STM32L151xD) || defined (STM32L151xE) || defined (STM32L151xDX) ||\ 97 defined (STM32L152xD) || defined (STM32L152xE) || defined (STM32L152xDX) ||\ 98 defined (STM32L162xD) || defined (STM32L162xE) || defined (STM32L162xDX) 99 100 #define GPIO_AF8_UART4 ((uint8_t)0x08) /*!< UART4 Alternate Function mapping */ 101 #define GPIO_AF8_UART5 ((uint8_t)0x08) /*!< UART5 Alternate Function mapping */ 102 103 #endif /* STM32L151xD || STM32L151xE || STM32L151xDX || STM32L152xD || STM32L 152xE || STM32L162xD || STM32L162xE || STM32L162xDX */ 104 105 106 /* AF 9 selection */ 107 108 /* AF 10 selection */ 109 110 /* AF 11 selection */ 111 #if defined (STM32L100xB) || defined (STM32L100xBA) || defined (STM32L100xC) ||\ 112 defined (STM32L152xB) || defined (STM32L152xBA) || defined (STM32L152xC) || defined (STM32L152xCA) || defined (STM32L152xD) || defined (STM32L152xE) || defined (STM32L152xDX) ||\ 113 defined (STM32L162xC) || defined (STM32L162xCA) || defined (STM32L162xD) || defined (STM32L162xE) || defined (STM32L162xDX) 114 115 #define GPIO_AF11_LCD ((uint8_t)0x0B) /*!< LCD Alternate Function mapping */ 116 117 #endif /* STM32L100xB || STM32L100xBA || STM32L100xC || (...) || STM32L162xCA || STM32L162xD || STM32L162xE || STM32L162xDX */ 118 119 /* AF 12 selection */ 120 #if defined (STM32L151xD) || defined (STM32L152xD) || defined (STM32L162xD) 121 122 #define GPIO_AF12_FSMC ((uint8_t)0x0C) /*!< FSMC Alternate Function mapping */ 123 #define GPIO_AF12_SDIO ((uint8_t)0x0C) /*!< SDIO Alternate Function mapping */ 124 125 #endif /* STM32L151xD || STM32L152xD || STM32L162xD */ 126 /* AF 13 selection */ 127 128 /* AF 14 selection */ 129 #define GPIO_AF14_TIM_IC1 ((uint8_t)0x0E) /*!< TIMER INPUT CAPTURE Alternate Function mapping */ 130 #define GPIO_AF14_TIM_IC2 ((uint8_t)0x0E) /*!< TIMER INPUT CAPTURE Alternate Function mapping */ 131 #define GPIO_AF14_TIM_IC3 ((uint8_t)0x0E) /*!< TIMER INPUT CAPTURE Alternate Function mapping */ 132 #define GPIO_AF14_TIM_IC4 ((uint8_t)0x0E) /*!< TIMER INPUT CAPTURE Alternate Function mapping */ 133 134 /* AF 15 selection */ 135 #define GPIO_AF15_EVENTOUT ((uint8_t)0x0F) /*!< EVENTOUT Alternate Function mapping */ 136 137 /** 138 * @} 139 */ 140 141 /** 142 * @} 143 */ 144 145 /** @defgroup GPIOEx_Private_Macros GPIOEx Private Macros 146 * @{ 147 */ 148 149 150 #define IS_GPIO_AF(AF) ((AF) <= (uint8_t)0x0F) 151 152 153 #if defined (STM32L151xCA) || defined (STM32L151xD) || defined (STM32L152xCA) || defined (STM32L152xD) || defined (STM32L162xCA) || defined (STM32L162xD) || defined (STM32L151xE) || defined (STM32L151xDX) || defined (STM32L152xE) || defined (STM32L152xDX) || defined (STM32L162xE) || defined (STM32L162xDX) 154 #define GPIO_GET_INDEX(__GPIOx__) (((__GPIOx__) == (GPIOA))? 0U :\ 155 ((__GPIOx__) == (GPIOB))? 1U :\ 156 ((__GPIOx__) == (GPIOC))? 2U :\ 157 ((__GPIOx__) == (GPIOD))? 3U :\ 158 ((__GPIOx__) == (GPIOE))? 4U :\ 159 ((__GPIOx__) == (GPIOH))? 5U :\ 160 ((__GPIOx__) == (GPIOF))? 6U : 7U) 161 #endif 162 163 #if defined (STM32L151xB) || defined (STM32L151xBA) || defined (STM32L151xC) || defined (STM32L152xB) || defined (STM32L152xBA) || defined (STM32L152xC) || defined (STM32L162xC) 164 #define GPIO_GET_INDEX(__GPIOx__) (((__GPIOx__) == (GPIOA))? 0U :\ 165 ((__GPIOx__) == (GPIOB))? 1U :\ 166 ((__GPIOx__) == (GPIOC))? 2U :\ 167 ((__GPIOx__) == (GPIOD))? 3U :\ 168 ((__GPIOx__) == (GPIOE))? 4U : 5U) 169 #endif 170 171 #if defined (STM32L100xB) || defined (STM32L100xBA) || defined (STM32L100xC) 172 #define GPIO_GET_INDEX(__GPIOx__) (((__GPIOx__) == (GPIOA))? 0U :\ 173 ((__GPIOx__) == (GPIOB))? 1U :\ 174 ((__GPIOx__) == (GPIOC))? 2U :\ 175 ((__GPIOx__) == (GPIOD))? 3U : 5U) 176 #endif 177 178 179 180 /** 181 * @} 182 */ 183 184 185 186 /* Exported macro ------------------------------------------------------------*/ 187 /* Exported functions --------------------------------------------------------*/ 188 189 190 /** 191 * @} 192 */ 193 194 /** 195 * @} 196 */ 197 198 #ifdef __cplusplus 199 } 200 #endif 201 202 #endif /* __STM32L1xx_HAL_GPIO_EX_H */ 203 204