STM32L4xx_HAL_Driver  1.14.0
Initialization and de-initialization functions

Functions

ErrorStatus LL_GPIO_DeInit (GPIO_TypeDef *GPIOx)
 De-initialize GPIO registers (Registers restored to their default values). More...
 
ErrorStatus LL_GPIO_Init (GPIO_TypeDef *GPIOx, LL_GPIO_InitTypeDef *GPIO_InitStruct)
 Initialize GPIO registers according to the specified parameters in GPIO_InitStruct. More...
 
void LL_GPIO_StructInit (LL_GPIO_InitTypeDef *GPIO_InitStruct)
 Set each LL_GPIO_InitTypeDef field to default value. More...
 

Detailed Description

Function Documentation

◆ LL_GPIO_DeInit()

ErrorStatus LL_GPIO_DeInit ( GPIO_TypeDef *  GPIOx)

De-initialize GPIO registers (Registers restored to their default values).

Parameters
GPIOxGPIO Port
Return values
AnErrorStatus enumeration value:
  • SUCCESS: GPIO registers are de-initialized
  • ERROR: Wrong GPIO Port

Definition at line 109 of file stm32l4xx_ll_gpio.c.

110 {
111  ErrorStatus status = SUCCESS;
112 
113  /* Check the parameters */
114  assert_param(IS_GPIO_ALL_INSTANCE(GPIOx));
115 
116  /* Force and Release reset on clock of GPIOx Port */
117  if (GPIOx == GPIOA)
118  {
119  LL_AHB2_GRP1_ForceReset(LL_AHB2_GRP1_PERIPH_GPIOA);
120  LL_AHB2_GRP1_ReleaseReset(LL_AHB2_GRP1_PERIPH_GPIOA);
121  }
122  else if (GPIOx == GPIOB)
123  {
124  LL_AHB2_GRP1_ForceReset(LL_AHB2_GRP1_PERIPH_GPIOB);
125  LL_AHB2_GRP1_ReleaseReset(LL_AHB2_GRP1_PERIPH_GPIOB);
126  }
127  else if (GPIOx == GPIOC)
128  {
129  LL_AHB2_GRP1_ForceReset(LL_AHB2_GRP1_PERIPH_GPIOC);
130  LL_AHB2_GRP1_ReleaseReset(LL_AHB2_GRP1_PERIPH_GPIOC);
131  }
132 #if defined(GPIOD)
133  else if (GPIOx == GPIOD)
134  {
135  LL_AHB2_GRP1_ForceReset(LL_AHB2_GRP1_PERIPH_GPIOD);
136  LL_AHB2_GRP1_ReleaseReset(LL_AHB2_GRP1_PERIPH_GPIOD);
137  }
138 #endif /* GPIOD */
139 #if defined(GPIOE)
140  else if (GPIOx == GPIOE)
141  {
142  LL_AHB2_GRP1_ForceReset(LL_AHB2_GRP1_PERIPH_GPIOE);
143  LL_AHB2_GRP1_ReleaseReset(LL_AHB2_GRP1_PERIPH_GPIOE);
144  }
145 #endif /* GPIOE */
146 #if defined(GPIOF)
147  else if (GPIOx == GPIOF)
148  {
149  LL_AHB2_GRP1_ForceReset(LL_AHB2_GRP1_PERIPH_GPIOF);
150  LL_AHB2_GRP1_ReleaseReset(LL_AHB2_GRP1_PERIPH_GPIOF);
151  }
152 #endif /* GPIOF */
153 #if defined(GPIOG)
154  else if (GPIOx == GPIOG)
155  {
156  LL_AHB2_GRP1_ForceReset(LL_AHB2_GRP1_PERIPH_GPIOG);
157  LL_AHB2_GRP1_ReleaseReset(LL_AHB2_GRP1_PERIPH_GPIOG);
158  }
159 #endif /* GPIOG */
160 #if defined(GPIOH)
161  else if (GPIOx == GPIOH)
162  {
163  LL_AHB2_GRP1_ForceReset(LL_AHB2_GRP1_PERIPH_GPIOH);
164  LL_AHB2_GRP1_ReleaseReset(LL_AHB2_GRP1_PERIPH_GPIOH);
165  }
166 #endif /* GPIOH */
167 #if defined(GPIOI)
168  else if (GPIOx == GPIOI)
169  {
170  LL_AHB2_GRP1_ForceReset(LL_AHB2_GRP1_PERIPH_GPIOI);
171  LL_AHB2_GRP1_ReleaseReset(LL_AHB2_GRP1_PERIPH_GPIOI);
172  }
173 #endif /* GPIOI */
174  else
175  {
176  status = ERROR;
177  }
178 
179  return (status);
180 }
__STATIC_INLINE void LL_AHB2_GRP1_ForceReset(uint32_t Periphs)
Force AHB2 peripherals reset. AHB2RSTR GPIOARST LL_AHB2_GRP1_ForceReset AHB2RSTR GPIOBRST LL_AHB2_G...
__STATIC_INLINE void LL_AHB2_GRP1_ReleaseReset(uint32_t Periphs)
Release AHB2 peripherals reset. AHB2RSTR GPIOARST LL_AHB2_GRP1_ReleaseReset AHB2RSTR GPIOBRST LL_AH...
assert_param(IS_RTC_WAKEUP_CLOCK(WakeUpClock))

◆ LL_GPIO_Init()

ErrorStatus LL_GPIO_Init ( GPIO_TypeDef *  GPIOx,
LL_GPIO_InitTypeDef GPIO_InitStruct 
)

Initialize GPIO registers according to the specified parameters in GPIO_InitStruct.

Parameters
GPIOxGPIO Port
GPIO_InitStructpointer to a LL_GPIO_InitTypeDef structure that contains the configuration information for the specified GPIO peripheral.
Return values
AnErrorStatus enumeration value:
  • SUCCESS: GPIO registers are initialized according to GPIO_InitStruct content
  • ERROR: Not applicable

Definition at line 191 of file stm32l4xx_ll_gpio.c.

192 {
193  uint32_t pinpos;
194  uint32_t currentpin;
195 
196  /* Check the parameters */
197  assert_param(IS_GPIO_ALL_INSTANCE(GPIOx));
198  assert_param(IS_LL_GPIO_PIN(GPIO_InitStruct->Pin));
199  assert_param(IS_LL_GPIO_MODE(GPIO_InitStruct->Mode));
200  assert_param(IS_LL_GPIO_PULL(GPIO_InitStruct->Pull));
201 
202  /* ------------------------- Configure the port pins ---------------- */
203  /* Initialize pinpos on first pin set */
204  pinpos = POSITION_VAL(GPIO_InitStruct->Pin);
205 
206  /* Configure the port pins */
207  while (((GPIO_InitStruct->Pin) >> pinpos) != 0x00u)
208  {
209  /* Get current io position */
210  currentpin = (GPIO_InitStruct->Pin) & (0x00000001uL << pinpos);
211 
212  if (currentpin != 0x00u)
213  {
214  /* Pin Mode configuration */
215  LL_GPIO_SetPinMode(GPIOx, currentpin, GPIO_InitStruct->Mode);
216 
217  if ((GPIO_InitStruct->Mode == LL_GPIO_MODE_OUTPUT) || (GPIO_InitStruct->Mode == LL_GPIO_MODE_ALTERNATE))
218  {
219  /* Check Speed mode parameters */
220  assert_param(IS_LL_GPIO_SPEED(GPIO_InitStruct->Speed));
221 
222  /* Speed mode configuration */
223  LL_GPIO_SetPinSpeed(GPIOx, currentpin, GPIO_InitStruct->Speed);
224  }
225 
226  /* Pull-up Pull down resistor configuration*/
227  LL_GPIO_SetPinPull(GPIOx, currentpin, GPIO_InitStruct->Pull);
228 
229  if (GPIO_InitStruct->Mode == LL_GPIO_MODE_ALTERNATE)
230  {
231  /* Check Alternate parameter */
232  assert_param(IS_LL_GPIO_ALTERNATE(GPIO_InitStruct->Alternate));
233 
234  /* Speed mode configuration */
235  if (currentpin < LL_GPIO_PIN_8)
236  {
237  LL_GPIO_SetAFPin_0_7(GPIOx, currentpin, GPIO_InitStruct->Alternate);
238  }
239  else
240  {
241  LL_GPIO_SetAFPin_8_15(GPIOx, currentpin, GPIO_InitStruct->Alternate);
242  }
243  }
244  }
245  pinpos++;
246  }
247 
248  if ((GPIO_InitStruct->Mode == LL_GPIO_MODE_OUTPUT) || (GPIO_InitStruct->Mode == LL_GPIO_MODE_ALTERNATE))
249  {
250  /* Check Output mode parameters */
251  assert_param(IS_LL_GPIO_OUTPUT_TYPE(GPIO_InitStruct->OutputType));
252 
253  /* Output mode configuration*/
254  LL_GPIO_SetPinOutputType(GPIOx, GPIO_InitStruct->Pin, GPIO_InitStruct->OutputType);
255 
256  }
257  return (SUCCESS);
258 }
__STATIC_INLINE void LL_GPIO_SetPinOutputType(GPIO_TypeDef *GPIOx, uint32_t PinMask, uint32_t OutputType)
Configure gpio output type for several pins on dedicated port.
__STATIC_INLINE void LL_GPIO_SetAFPin_0_7(GPIO_TypeDef *GPIOx, uint32_t Pin, uint32_t Alternate)
Configure gpio alternate function of a dedicated pin from 0 to 7 for a dedicated port.
__STATIC_INLINE void LL_GPIO_SetPinSpeed(GPIO_TypeDef *GPIOx, uint32_t Pin, uint32_t Speed)
Configure gpio speed for a dedicated pin on dedicated port.
__STATIC_INLINE void LL_GPIO_SetPinPull(GPIO_TypeDef *GPIOx, uint32_t Pin, uint32_t Pull)
Configure gpio pull-up or pull-down for a dedicated pin on a dedicated port.
__STATIC_INLINE void LL_GPIO_SetAFPin_8_15(GPIO_TypeDef *GPIOx, uint32_t Pin, uint32_t Alternate)
Configure gpio alternate function of a dedicated pin from 8 to 15 for a dedicated port...
__STATIC_INLINE void LL_GPIO_SetPinMode(GPIO_TypeDef *GPIOx, uint32_t Pin, uint32_t Mode)
Configure gpio mode for a dedicated pin on dedicated port.
assert_param(IS_RTC_WAKEUP_CLOCK(WakeUpClock))

◆ LL_GPIO_StructInit()

void LL_GPIO_StructInit ( LL_GPIO_InitTypeDef GPIO_InitStruct)

Set each LL_GPIO_InitTypeDef field to default value.

Parameters
GPIO_InitStructpointer to a LL_GPIO_InitTypeDef structure whose fields will be set to default values.
Return values
None

Definition at line 267 of file stm32l4xx_ll_gpio.c.

268 {
269  /* Reset GPIO init structure parameters values */
270  GPIO_InitStruct->Pin = LL_GPIO_PIN_ALL;
271  GPIO_InitStruct->Mode = LL_GPIO_MODE_ANALOG;
272  GPIO_InitStruct->Speed = LL_GPIO_SPEED_FREQ_LOW;
273  GPIO_InitStruct->OutputType = LL_GPIO_OUTPUT_PUSHPULL;
274  GPIO_InitStruct->Pull = LL_GPIO_PULL_NO;
275  GPIO_InitStruct->Alternate = LL_GPIO_AF_0;
276 }