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