inport from local
Dependents: Hobbyking_Cheetah_0511
targets/TARGET_STM/TARGET_STM32F4/device/stm32f4xx_ll_gpio.c@0:85b3fd62ea1a, 2020-03-16 (annotated)
- Committer:
- NYX
- Date:
- Mon Mar 16 06:35:48 2020 +0000
- Revision:
- 0:85b3fd62ea1a
reinport to mbed;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
NYX | 0:85b3fd62ea1a | 1 | /** |
NYX | 0:85b3fd62ea1a | 2 | ****************************************************************************** |
NYX | 0:85b3fd62ea1a | 3 | * @file stm32f4xx_ll_gpio.c |
NYX | 0:85b3fd62ea1a | 4 | * @author MCD Application Team |
NYX | 0:85b3fd62ea1a | 5 | * @version V1.7.1 |
NYX | 0:85b3fd62ea1a | 6 | * @date 14-April-2017 |
NYX | 0:85b3fd62ea1a | 7 | * @brief GPIO LL module driver. |
NYX | 0:85b3fd62ea1a | 8 | ****************************************************************************** |
NYX | 0:85b3fd62ea1a | 9 | * @attention |
NYX | 0:85b3fd62ea1a | 10 | * |
NYX | 0:85b3fd62ea1a | 11 | * <h2><center>© COPYRIGHT(c) 2017 STMicroelectronics</center></h2> |
NYX | 0:85b3fd62ea1a | 12 | * |
NYX | 0:85b3fd62ea1a | 13 | * Redistribution and use in source and binary forms, with or without modification, |
NYX | 0:85b3fd62ea1a | 14 | * are permitted provided that the following conditions are met: |
NYX | 0:85b3fd62ea1a | 15 | * 1. Redistributions of source code must retain the above copyright notice, |
NYX | 0:85b3fd62ea1a | 16 | * this list of conditions and the following disclaimer. |
NYX | 0:85b3fd62ea1a | 17 | * 2. Redistributions in binary form must reproduce the above copyright notice, |
NYX | 0:85b3fd62ea1a | 18 | * this list of conditions and the following disclaimer in the documentation |
NYX | 0:85b3fd62ea1a | 19 | * and/or other materials provided with the distribution. |
NYX | 0:85b3fd62ea1a | 20 | * 3. Neither the name of STMicroelectronics nor the names of its contributors |
NYX | 0:85b3fd62ea1a | 21 | * may be used to endorse or promote products derived from this software |
NYX | 0:85b3fd62ea1a | 22 | * without specific prior written permission. |
NYX | 0:85b3fd62ea1a | 23 | * |
NYX | 0:85b3fd62ea1a | 24 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
NYX | 0:85b3fd62ea1a | 25 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
NYX | 0:85b3fd62ea1a | 26 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
NYX | 0:85b3fd62ea1a | 27 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE |
NYX | 0:85b3fd62ea1a | 28 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
NYX | 0:85b3fd62ea1a | 29 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
NYX | 0:85b3fd62ea1a | 30 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
NYX | 0:85b3fd62ea1a | 31 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
NYX | 0:85b3fd62ea1a | 32 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
NYX | 0:85b3fd62ea1a | 33 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
NYX | 0:85b3fd62ea1a | 34 | * |
NYX | 0:85b3fd62ea1a | 35 | ****************************************************************************** |
NYX | 0:85b3fd62ea1a | 36 | */ |
NYX | 0:85b3fd62ea1a | 37 | #if defined(USE_FULL_LL_DRIVER) |
NYX | 0:85b3fd62ea1a | 38 | |
NYX | 0:85b3fd62ea1a | 39 | /* Includes ------------------------------------------------------------------*/ |
NYX | 0:85b3fd62ea1a | 40 | #include "stm32f4xx_ll_gpio.h" |
NYX | 0:85b3fd62ea1a | 41 | #include "stm32f4xx_ll_bus.h" |
NYX | 0:85b3fd62ea1a | 42 | #ifdef USE_FULL_ASSERT |
NYX | 0:85b3fd62ea1a | 43 | #include "stm32_assert.h" |
NYX | 0:85b3fd62ea1a | 44 | #else |
NYX | 0:85b3fd62ea1a | 45 | #define assert_param(expr) ((void)0U) |
NYX | 0:85b3fd62ea1a | 46 | #endif |
NYX | 0:85b3fd62ea1a | 47 | |
NYX | 0:85b3fd62ea1a | 48 | /** @addtogroup STM32F4xx_LL_Driver |
NYX | 0:85b3fd62ea1a | 49 | * @{ |
NYX | 0:85b3fd62ea1a | 50 | */ |
NYX | 0:85b3fd62ea1a | 51 | |
NYX | 0:85b3fd62ea1a | 52 | #if defined (GPIOA) || defined (GPIOB) || defined (GPIOC) || defined (GPIOD) || defined (GPIOE) || defined (GPIOF) || defined (GPIOG) || defined (GPIOH) || defined (GPIOI) || defined (GPIOJ) || defined (GPIOK) |
NYX | 0:85b3fd62ea1a | 53 | |
NYX | 0:85b3fd62ea1a | 54 | /** @addtogroup GPIO_LL |
NYX | 0:85b3fd62ea1a | 55 | * @{ |
NYX | 0:85b3fd62ea1a | 56 | */ |
NYX | 0:85b3fd62ea1a | 57 | |
NYX | 0:85b3fd62ea1a | 58 | /* Private types -------------------------------------------------------------*/ |
NYX | 0:85b3fd62ea1a | 59 | /* Private variables ---------------------------------------------------------*/ |
NYX | 0:85b3fd62ea1a | 60 | /* Private constants ---------------------------------------------------------*/ |
NYX | 0:85b3fd62ea1a | 61 | /* Private macros ------------------------------------------------------------*/ |
NYX | 0:85b3fd62ea1a | 62 | /** @addtogroup GPIO_LL_Private_Macros |
NYX | 0:85b3fd62ea1a | 63 | * @{ |
NYX | 0:85b3fd62ea1a | 64 | */ |
NYX | 0:85b3fd62ea1a | 65 | #define IS_LL_GPIO_PIN(__VALUE__) (((0x00000000U) < (__VALUE__)) && ((__VALUE__) <= (LL_GPIO_PIN_ALL))) |
NYX | 0:85b3fd62ea1a | 66 | |
NYX | 0:85b3fd62ea1a | 67 | #define IS_LL_GPIO_MODE(__VALUE__) (((__VALUE__) == LL_GPIO_MODE_INPUT) ||\ |
NYX | 0:85b3fd62ea1a | 68 | ((__VALUE__) == LL_GPIO_MODE_OUTPUT) ||\ |
NYX | 0:85b3fd62ea1a | 69 | ((__VALUE__) == LL_GPIO_MODE_ALTERNATE) ||\ |
NYX | 0:85b3fd62ea1a | 70 | ((__VALUE__) == LL_GPIO_MODE_ANALOG)) |
NYX | 0:85b3fd62ea1a | 71 | |
NYX | 0:85b3fd62ea1a | 72 | #define IS_LL_GPIO_OUTPUT_TYPE(__VALUE__) (((__VALUE__) == LL_GPIO_OUTPUT_PUSHPULL) ||\ |
NYX | 0:85b3fd62ea1a | 73 | ((__VALUE__) == LL_GPIO_OUTPUT_OPENDRAIN)) |
NYX | 0:85b3fd62ea1a | 74 | |
NYX | 0:85b3fd62ea1a | 75 | #define IS_LL_GPIO_SPEED(__VALUE__) (((__VALUE__) == LL_GPIO_SPEED_FREQ_LOW) ||\ |
NYX | 0:85b3fd62ea1a | 76 | ((__VALUE__) == LL_GPIO_SPEED_FREQ_MEDIUM) ||\ |
NYX | 0:85b3fd62ea1a | 77 | ((__VALUE__) == LL_GPIO_SPEED_FREQ_HIGH) ||\ |
NYX | 0:85b3fd62ea1a | 78 | ((__VALUE__) == LL_GPIO_SPEED_FREQ_VERY_HIGH)) |
NYX | 0:85b3fd62ea1a | 79 | |
NYX | 0:85b3fd62ea1a | 80 | #define IS_LL_GPIO_PULL(__VALUE__) (((__VALUE__) == LL_GPIO_PULL_NO) ||\ |
NYX | 0:85b3fd62ea1a | 81 | ((__VALUE__) == LL_GPIO_PULL_UP) ||\ |
NYX | 0:85b3fd62ea1a | 82 | ((__VALUE__) == LL_GPIO_PULL_DOWN)) |
NYX | 0:85b3fd62ea1a | 83 | |
NYX | 0:85b3fd62ea1a | 84 | #define IS_LL_GPIO_ALTERNATE(__VALUE__) (((__VALUE__) == LL_GPIO_AF_0 ) ||\ |
NYX | 0:85b3fd62ea1a | 85 | ((__VALUE__) == LL_GPIO_AF_1 ) ||\ |
NYX | 0:85b3fd62ea1a | 86 | ((__VALUE__) == LL_GPIO_AF_2 ) ||\ |
NYX | 0:85b3fd62ea1a | 87 | ((__VALUE__) == LL_GPIO_AF_3 ) ||\ |
NYX | 0:85b3fd62ea1a | 88 | ((__VALUE__) == LL_GPIO_AF_4 ) ||\ |
NYX | 0:85b3fd62ea1a | 89 | ((__VALUE__) == LL_GPIO_AF_5 ) ||\ |
NYX | 0:85b3fd62ea1a | 90 | ((__VALUE__) == LL_GPIO_AF_6 ) ||\ |
NYX | 0:85b3fd62ea1a | 91 | ((__VALUE__) == LL_GPIO_AF_7 ) ||\ |
NYX | 0:85b3fd62ea1a | 92 | ((__VALUE__) == LL_GPIO_AF_8 ) ||\ |
NYX | 0:85b3fd62ea1a | 93 | ((__VALUE__) == LL_GPIO_AF_9 ) ||\ |
NYX | 0:85b3fd62ea1a | 94 | ((__VALUE__) == LL_GPIO_AF_10 ) ||\ |
NYX | 0:85b3fd62ea1a | 95 | ((__VALUE__) == LL_GPIO_AF_11 ) ||\ |
NYX | 0:85b3fd62ea1a | 96 | ((__VALUE__) == LL_GPIO_AF_12 ) ||\ |
NYX | 0:85b3fd62ea1a | 97 | ((__VALUE__) == LL_GPIO_AF_13 ) ||\ |
NYX | 0:85b3fd62ea1a | 98 | ((__VALUE__) == LL_GPIO_AF_14 ) ||\ |
NYX | 0:85b3fd62ea1a | 99 | ((__VALUE__) == LL_GPIO_AF_15 )) |
NYX | 0:85b3fd62ea1a | 100 | /** |
NYX | 0:85b3fd62ea1a | 101 | * @} |
NYX | 0:85b3fd62ea1a | 102 | */ |
NYX | 0:85b3fd62ea1a | 103 | |
NYX | 0:85b3fd62ea1a | 104 | /* Private function prototypes -----------------------------------------------*/ |
NYX | 0:85b3fd62ea1a | 105 | |
NYX | 0:85b3fd62ea1a | 106 | /* Exported functions --------------------------------------------------------*/ |
NYX | 0:85b3fd62ea1a | 107 | /** @addtogroup GPIO_LL_Exported_Functions |
NYX | 0:85b3fd62ea1a | 108 | * @{ |
NYX | 0:85b3fd62ea1a | 109 | */ |
NYX | 0:85b3fd62ea1a | 110 | |
NYX | 0:85b3fd62ea1a | 111 | /** @addtogroup GPIO_LL_EF_Init |
NYX | 0:85b3fd62ea1a | 112 | * @{ |
NYX | 0:85b3fd62ea1a | 113 | */ |
NYX | 0:85b3fd62ea1a | 114 | |
NYX | 0:85b3fd62ea1a | 115 | /** |
NYX | 0:85b3fd62ea1a | 116 | * @brief De-initialize GPIO registers (Registers restored to their default values). |
NYX | 0:85b3fd62ea1a | 117 | * @param GPIOx GPIO Port |
NYX | 0:85b3fd62ea1a | 118 | * @retval An ErrorStatus enumeration value: |
NYX | 0:85b3fd62ea1a | 119 | * - SUCCESS: GPIO registers are de-initialized |
NYX | 0:85b3fd62ea1a | 120 | * - ERROR: Wrong GPIO Port |
NYX | 0:85b3fd62ea1a | 121 | */ |
NYX | 0:85b3fd62ea1a | 122 | ErrorStatus LL_GPIO_DeInit(GPIO_TypeDef *GPIOx) |
NYX | 0:85b3fd62ea1a | 123 | { |
NYX | 0:85b3fd62ea1a | 124 | ErrorStatus status = SUCCESS; |
NYX | 0:85b3fd62ea1a | 125 | |
NYX | 0:85b3fd62ea1a | 126 | /* Check the parameters */ |
NYX | 0:85b3fd62ea1a | 127 | assert_param(IS_GPIO_ALL_INSTANCE(GPIOx)); |
NYX | 0:85b3fd62ea1a | 128 | |
NYX | 0:85b3fd62ea1a | 129 | /* Force and Release reset on clock of GPIOx Port */ |
NYX | 0:85b3fd62ea1a | 130 | if (GPIOx == GPIOA) |
NYX | 0:85b3fd62ea1a | 131 | { |
NYX | 0:85b3fd62ea1a | 132 | LL_AHB1_GRP1_ForceReset(LL_AHB1_GRP1_PERIPH_GPIOA); |
NYX | 0:85b3fd62ea1a | 133 | LL_AHB1_GRP1_ReleaseReset(LL_AHB1_GRP1_PERIPH_GPIOA); |
NYX | 0:85b3fd62ea1a | 134 | } |
NYX | 0:85b3fd62ea1a | 135 | else if (GPIOx == GPIOB) |
NYX | 0:85b3fd62ea1a | 136 | { |
NYX | 0:85b3fd62ea1a | 137 | LL_AHB1_GRP1_ForceReset(LL_AHB1_GRP1_PERIPH_GPIOB); |
NYX | 0:85b3fd62ea1a | 138 | LL_AHB1_GRP1_ReleaseReset(LL_AHB1_GRP1_PERIPH_GPIOB); |
NYX | 0:85b3fd62ea1a | 139 | } |
NYX | 0:85b3fd62ea1a | 140 | else if (GPIOx == GPIOC) |
NYX | 0:85b3fd62ea1a | 141 | { |
NYX | 0:85b3fd62ea1a | 142 | LL_AHB1_GRP1_ForceReset(LL_AHB1_GRP1_PERIPH_GPIOC); |
NYX | 0:85b3fd62ea1a | 143 | LL_AHB1_GRP1_ReleaseReset(LL_AHB1_GRP1_PERIPH_GPIOC); |
NYX | 0:85b3fd62ea1a | 144 | } |
NYX | 0:85b3fd62ea1a | 145 | #if defined(GPIOD) |
NYX | 0:85b3fd62ea1a | 146 | else if (GPIOx == GPIOD) |
NYX | 0:85b3fd62ea1a | 147 | { |
NYX | 0:85b3fd62ea1a | 148 | LL_AHB1_GRP1_ForceReset(LL_AHB1_GRP1_PERIPH_GPIOD); |
NYX | 0:85b3fd62ea1a | 149 | LL_AHB1_GRP1_ReleaseReset(LL_AHB1_GRP1_PERIPH_GPIOD); |
NYX | 0:85b3fd62ea1a | 150 | } |
NYX | 0:85b3fd62ea1a | 151 | #endif /* GPIOD */ |
NYX | 0:85b3fd62ea1a | 152 | #if defined(GPIOE) |
NYX | 0:85b3fd62ea1a | 153 | else if (GPIOx == GPIOE) |
NYX | 0:85b3fd62ea1a | 154 | { |
NYX | 0:85b3fd62ea1a | 155 | LL_AHB1_GRP1_ForceReset(LL_AHB1_GRP1_PERIPH_GPIOE); |
NYX | 0:85b3fd62ea1a | 156 | LL_AHB1_GRP1_ReleaseReset(LL_AHB1_GRP1_PERIPH_GPIOE); |
NYX | 0:85b3fd62ea1a | 157 | } |
NYX | 0:85b3fd62ea1a | 158 | #endif /* GPIOE */ |
NYX | 0:85b3fd62ea1a | 159 | #if defined(GPIOF) |
NYX | 0:85b3fd62ea1a | 160 | else if (GPIOx == GPIOF) |
NYX | 0:85b3fd62ea1a | 161 | { |
NYX | 0:85b3fd62ea1a | 162 | LL_AHB1_GRP1_ForceReset(LL_AHB1_GRP1_PERIPH_GPIOF); |
NYX | 0:85b3fd62ea1a | 163 | LL_AHB1_GRP1_ReleaseReset(LL_AHB1_GRP1_PERIPH_GPIOF); |
NYX | 0:85b3fd62ea1a | 164 | } |
NYX | 0:85b3fd62ea1a | 165 | #endif /* GPIOF */ |
NYX | 0:85b3fd62ea1a | 166 | #if defined(GPIOG) |
NYX | 0:85b3fd62ea1a | 167 | else if (GPIOx == GPIOG) |
NYX | 0:85b3fd62ea1a | 168 | { |
NYX | 0:85b3fd62ea1a | 169 | LL_AHB1_GRP1_ForceReset(LL_AHB1_GRP1_PERIPH_GPIOG); |
NYX | 0:85b3fd62ea1a | 170 | LL_AHB1_GRP1_ReleaseReset(LL_AHB1_GRP1_PERIPH_GPIOG); |
NYX | 0:85b3fd62ea1a | 171 | } |
NYX | 0:85b3fd62ea1a | 172 | #endif /* GPIOG */ |
NYX | 0:85b3fd62ea1a | 173 | #if defined(GPIOH) |
NYX | 0:85b3fd62ea1a | 174 | else if (GPIOx == GPIOH) |
NYX | 0:85b3fd62ea1a | 175 | { |
NYX | 0:85b3fd62ea1a | 176 | LL_AHB1_GRP1_ForceReset(LL_AHB1_GRP1_PERIPH_GPIOH); |
NYX | 0:85b3fd62ea1a | 177 | LL_AHB1_GRP1_ReleaseReset(LL_AHB1_GRP1_PERIPH_GPIOH); |
NYX | 0:85b3fd62ea1a | 178 | } |
NYX | 0:85b3fd62ea1a | 179 | #endif /* GPIOH */ |
NYX | 0:85b3fd62ea1a | 180 | #if defined(GPIOI) |
NYX | 0:85b3fd62ea1a | 181 | else if (GPIOx == GPIOI) |
NYX | 0:85b3fd62ea1a | 182 | { |
NYX | 0:85b3fd62ea1a | 183 | LL_AHB1_GRP1_ForceReset(LL_AHB1_GRP1_PERIPH_GPIOI); |
NYX | 0:85b3fd62ea1a | 184 | LL_AHB1_GRP1_ReleaseReset(LL_AHB1_GRP1_PERIPH_GPIOI); |
NYX | 0:85b3fd62ea1a | 185 | } |
NYX | 0:85b3fd62ea1a | 186 | #endif /* GPIOI */ |
NYX | 0:85b3fd62ea1a | 187 | #if defined(GPIOJ) |
NYX | 0:85b3fd62ea1a | 188 | else if (GPIOx == GPIOJ) |
NYX | 0:85b3fd62ea1a | 189 | { |
NYX | 0:85b3fd62ea1a | 190 | LL_AHB1_GRP1_ForceReset(LL_AHB1_GRP1_PERIPH_GPIOJ); |
NYX | 0:85b3fd62ea1a | 191 | LL_AHB1_GRP1_ReleaseReset(LL_AHB1_GRP1_PERIPH_GPIOJ); |
NYX | 0:85b3fd62ea1a | 192 | } |
NYX | 0:85b3fd62ea1a | 193 | #endif /* GPIOJ */ |
NYX | 0:85b3fd62ea1a | 194 | #if defined(GPIOK) |
NYX | 0:85b3fd62ea1a | 195 | else if (GPIOx == GPIOK) |
NYX | 0:85b3fd62ea1a | 196 | { |
NYX | 0:85b3fd62ea1a | 197 | LL_AHB1_GRP1_ForceReset(LL_AHB1_GRP1_PERIPH_GPIOK); |
NYX | 0:85b3fd62ea1a | 198 | LL_AHB1_GRP1_ReleaseReset(LL_AHB1_GRP1_PERIPH_GPIOK); |
NYX | 0:85b3fd62ea1a | 199 | } |
NYX | 0:85b3fd62ea1a | 200 | #endif /* GPIOK */ |
NYX | 0:85b3fd62ea1a | 201 | else |
NYX | 0:85b3fd62ea1a | 202 | { |
NYX | 0:85b3fd62ea1a | 203 | status = ERROR; |
NYX | 0:85b3fd62ea1a | 204 | } |
NYX | 0:85b3fd62ea1a | 205 | |
NYX | 0:85b3fd62ea1a | 206 | return (status); |
NYX | 0:85b3fd62ea1a | 207 | } |
NYX | 0:85b3fd62ea1a | 208 | |
NYX | 0:85b3fd62ea1a | 209 | /** |
NYX | 0:85b3fd62ea1a | 210 | * @brief Initialize GPIO registers according to the specified parameters in GPIO_InitStruct. |
NYX | 0:85b3fd62ea1a | 211 | * @param GPIOx GPIO Port |
NYX | 0:85b3fd62ea1a | 212 | * @param GPIO_InitStruct: pointer to a @ref LL_GPIO_InitTypeDef structure |
NYX | 0:85b3fd62ea1a | 213 | * that contains the configuration information for the specified GPIO peripheral. |
NYX | 0:85b3fd62ea1a | 214 | * @retval An ErrorStatus enumeration value: |
NYX | 0:85b3fd62ea1a | 215 | * - SUCCESS: GPIO registers are initialized according to GPIO_InitStruct content |
NYX | 0:85b3fd62ea1a | 216 | * - ERROR: Not applicable |
NYX | 0:85b3fd62ea1a | 217 | */ |
NYX | 0:85b3fd62ea1a | 218 | ErrorStatus LL_GPIO_Init(GPIO_TypeDef *GPIOx, LL_GPIO_InitTypeDef *GPIO_InitStruct) |
NYX | 0:85b3fd62ea1a | 219 | { |
NYX | 0:85b3fd62ea1a | 220 | uint32_t pinpos = 0x00000000U; |
NYX | 0:85b3fd62ea1a | 221 | uint32_t currentpin = 0x00000000U; |
NYX | 0:85b3fd62ea1a | 222 | |
NYX | 0:85b3fd62ea1a | 223 | /* Check the parameters */ |
NYX | 0:85b3fd62ea1a | 224 | assert_param(IS_GPIO_ALL_INSTANCE(GPIOx)); |
NYX | 0:85b3fd62ea1a | 225 | assert_param(IS_LL_GPIO_PIN(GPIO_InitStruct->Pin)); |
NYX | 0:85b3fd62ea1a | 226 | assert_param(IS_LL_GPIO_MODE(GPIO_InitStruct->Mode)); |
NYX | 0:85b3fd62ea1a | 227 | assert_param(IS_LL_GPIO_PULL(GPIO_InitStruct->Pull)); |
NYX | 0:85b3fd62ea1a | 228 | |
NYX | 0:85b3fd62ea1a | 229 | /* ------------------------- Configure the port pins ---------------- */ |
NYX | 0:85b3fd62ea1a | 230 | /* Initialize pinpos on first pin set */ |
NYX | 0:85b3fd62ea1a | 231 | pinpos = POSITION_VAL(GPIO_InitStruct->Pin); |
NYX | 0:85b3fd62ea1a | 232 | |
NYX | 0:85b3fd62ea1a | 233 | /* Configure the port pins */ |
NYX | 0:85b3fd62ea1a | 234 | while (((GPIO_InitStruct->Pin) >> pinpos) != 0x00000000U) |
NYX | 0:85b3fd62ea1a | 235 | { |
NYX | 0:85b3fd62ea1a | 236 | /* Get current io position */ |
NYX | 0:85b3fd62ea1a | 237 | currentpin = (GPIO_InitStruct->Pin) & (0x00000001U << pinpos); |
NYX | 0:85b3fd62ea1a | 238 | |
NYX | 0:85b3fd62ea1a | 239 | if (currentpin) |
NYX | 0:85b3fd62ea1a | 240 | { |
NYX | 0:85b3fd62ea1a | 241 | /* Pin Mode configuration */ |
NYX | 0:85b3fd62ea1a | 242 | LL_GPIO_SetPinMode(GPIOx, currentpin, GPIO_InitStruct->Mode); |
NYX | 0:85b3fd62ea1a | 243 | |
NYX | 0:85b3fd62ea1a | 244 | if ((GPIO_InitStruct->Mode == LL_GPIO_MODE_OUTPUT) || (GPIO_InitStruct->Mode == LL_GPIO_MODE_ALTERNATE)) |
NYX | 0:85b3fd62ea1a | 245 | { |
NYX | 0:85b3fd62ea1a | 246 | /* Check Speed mode parameters */ |
NYX | 0:85b3fd62ea1a | 247 | assert_param(IS_LL_GPIO_SPEED(GPIO_InitStruct->Speed)); |
NYX | 0:85b3fd62ea1a | 248 | |
NYX | 0:85b3fd62ea1a | 249 | /* Speed mode configuration */ |
NYX | 0:85b3fd62ea1a | 250 | LL_GPIO_SetPinSpeed(GPIOx, currentpin, GPIO_InitStruct->Speed); |
NYX | 0:85b3fd62ea1a | 251 | } |
NYX | 0:85b3fd62ea1a | 252 | |
NYX | 0:85b3fd62ea1a | 253 | /* Pull-up Pull down resistor configuration*/ |
NYX | 0:85b3fd62ea1a | 254 | LL_GPIO_SetPinPull(GPIOx, currentpin, GPIO_InitStruct->Pull); |
NYX | 0:85b3fd62ea1a | 255 | |
NYX | 0:85b3fd62ea1a | 256 | if (GPIO_InitStruct->Mode == LL_GPIO_MODE_ALTERNATE) |
NYX | 0:85b3fd62ea1a | 257 | { |
NYX | 0:85b3fd62ea1a | 258 | /* Check Alternate parameter */ |
NYX | 0:85b3fd62ea1a | 259 | assert_param(IS_LL_GPIO_ALTERNATE(GPIO_InitStruct->Alternate)); |
NYX | 0:85b3fd62ea1a | 260 | |
NYX | 0:85b3fd62ea1a | 261 | /* Speed mode configuration */ |
NYX | 0:85b3fd62ea1a | 262 | if (POSITION_VAL(currentpin) < 0x00000008U) |
NYX | 0:85b3fd62ea1a | 263 | { |
NYX | 0:85b3fd62ea1a | 264 | LL_GPIO_SetAFPin_0_7(GPIOx, currentpin, GPIO_InitStruct->Alternate); |
NYX | 0:85b3fd62ea1a | 265 | } |
NYX | 0:85b3fd62ea1a | 266 | else |
NYX | 0:85b3fd62ea1a | 267 | { |
NYX | 0:85b3fd62ea1a | 268 | LL_GPIO_SetAFPin_8_15(GPIOx, currentpin, GPIO_InitStruct->Alternate); |
NYX | 0:85b3fd62ea1a | 269 | } |
NYX | 0:85b3fd62ea1a | 270 | } |
NYX | 0:85b3fd62ea1a | 271 | } |
NYX | 0:85b3fd62ea1a | 272 | pinpos++; |
NYX | 0:85b3fd62ea1a | 273 | } |
NYX | 0:85b3fd62ea1a | 274 | |
NYX | 0:85b3fd62ea1a | 275 | if ((GPIO_InitStruct->Mode == LL_GPIO_MODE_OUTPUT) || (GPIO_InitStruct->Mode == LL_GPIO_MODE_ALTERNATE)) |
NYX | 0:85b3fd62ea1a | 276 | { |
NYX | 0:85b3fd62ea1a | 277 | /* Check Output mode parameters */ |
NYX | 0:85b3fd62ea1a | 278 | assert_param(IS_LL_GPIO_OUTPUT_TYPE(GPIO_InitStruct->OutputType)); |
NYX | 0:85b3fd62ea1a | 279 | |
NYX | 0:85b3fd62ea1a | 280 | /* Output mode configuration*/ |
NYX | 0:85b3fd62ea1a | 281 | LL_GPIO_SetPinOutputType(GPIOx, GPIO_InitStruct->Pin, GPIO_InitStruct->OutputType); |
NYX | 0:85b3fd62ea1a | 282 | |
NYX | 0:85b3fd62ea1a | 283 | } |
NYX | 0:85b3fd62ea1a | 284 | return (SUCCESS); |
NYX | 0:85b3fd62ea1a | 285 | } |
NYX | 0:85b3fd62ea1a | 286 | |
NYX | 0:85b3fd62ea1a | 287 | /** |
NYX | 0:85b3fd62ea1a | 288 | * @brief Set each @ref LL_GPIO_InitTypeDef field to default value. |
NYX | 0:85b3fd62ea1a | 289 | * @param GPIO_InitStruct: pointer to a @ref LL_GPIO_InitTypeDef structure |
NYX | 0:85b3fd62ea1a | 290 | * whose fields will be set to default values. |
NYX | 0:85b3fd62ea1a | 291 | * @retval None |
NYX | 0:85b3fd62ea1a | 292 | */ |
NYX | 0:85b3fd62ea1a | 293 | |
NYX | 0:85b3fd62ea1a | 294 | void LL_GPIO_StructInit(LL_GPIO_InitTypeDef *GPIO_InitStruct) |
NYX | 0:85b3fd62ea1a | 295 | { |
NYX | 0:85b3fd62ea1a | 296 | /* Reset GPIO init structure parameters values */ |
NYX | 0:85b3fd62ea1a | 297 | GPIO_InitStruct->Pin = LL_GPIO_PIN_ALL; |
NYX | 0:85b3fd62ea1a | 298 | GPIO_InitStruct->Mode = LL_GPIO_MODE_ANALOG; |
NYX | 0:85b3fd62ea1a | 299 | GPIO_InitStruct->Speed = LL_GPIO_SPEED_FREQ_LOW; |
NYX | 0:85b3fd62ea1a | 300 | GPIO_InitStruct->OutputType = LL_GPIO_OUTPUT_PUSHPULL; |
NYX | 0:85b3fd62ea1a | 301 | GPIO_InitStruct->Pull = LL_GPIO_PULL_NO; |
NYX | 0:85b3fd62ea1a | 302 | GPIO_InitStruct->Alternate = LL_GPIO_AF_0; |
NYX | 0:85b3fd62ea1a | 303 | } |
NYX | 0:85b3fd62ea1a | 304 | |
NYX | 0:85b3fd62ea1a | 305 | /** |
NYX | 0:85b3fd62ea1a | 306 | * @} |
NYX | 0:85b3fd62ea1a | 307 | */ |
NYX | 0:85b3fd62ea1a | 308 | |
NYX | 0:85b3fd62ea1a | 309 | /** |
NYX | 0:85b3fd62ea1a | 310 | * @} |
NYX | 0:85b3fd62ea1a | 311 | */ |
NYX | 0:85b3fd62ea1a | 312 | |
NYX | 0:85b3fd62ea1a | 313 | /** |
NYX | 0:85b3fd62ea1a | 314 | * @} |
NYX | 0:85b3fd62ea1a | 315 | */ |
NYX | 0:85b3fd62ea1a | 316 | |
NYX | 0:85b3fd62ea1a | 317 | #endif /* defined (GPIOA) || defined (GPIOB) || defined (GPIOC) || defined (GPIOD) || defined (GPIOE) || defined (GPIOF) || defined (GPIOG) || defined (GPIOH) || defined (GPIOI) || defined (GPIOJ) || defined (GPIOK) */ |
NYX | 0:85b3fd62ea1a | 318 | |
NYX | 0:85b3fd62ea1a | 319 | /** |
NYX | 0:85b3fd62ea1a | 320 | * @} |
NYX | 0:85b3fd62ea1a | 321 | */ |
NYX | 0:85b3fd62ea1a | 322 | |
NYX | 0:85b3fd62ea1a | 323 | #endif /* USE_FULL_LL_DRIVER */ |
NYX | 0:85b3fd62ea1a | 324 | |
NYX | 0:85b3fd62ea1a | 325 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |