STM32L4xx_HAL_Driver  1.14.0

GPIO Read, Write, Toggle, Lock and EXTI management functions. More...

Functions

GPIO_PinState HAL_GPIO_ReadPin (GPIO_TypeDef *GPIOx, uint16_t GPIO_Pin)
 Read the specified input port pin. More...
 
void HAL_GPIO_WritePin (GPIO_TypeDef *GPIOx, uint16_t GPIO_Pin, GPIO_PinState PinState)
 Set or clear the selected data port bit. More...
 
void HAL_GPIO_TogglePin (GPIO_TypeDef *GPIOx, uint16_t GPIO_Pin)
 Toggle the specified GPIO pin. More...
 
HAL_StatusTypeDef HAL_GPIO_LockPin (GPIO_TypeDef *GPIOx, uint16_t GPIO_Pin)
 Lock GPIO Pins configuration registers. More...
 
void HAL_GPIO_EXTI_IRQHandler (uint16_t GPIO_Pin)
 Handle EXTI interrupt request. More...
 
void HAL_GPIO_EXTI_Callback (uint16_t GPIO_Pin)
 EXTI line detection callback. More...
 

Detailed Description

GPIO Read, Write, Toggle, Lock and EXTI management functions.

 ===============================================================================
                       ##### IO operation functions #####
 ===============================================================================

Function Documentation

◆ HAL_GPIO_EXTI_Callback()

__weak void HAL_GPIO_EXTI_Callback ( uint16_t  GPIO_Pin)

EXTI line detection callback.

Parameters
GPIO_PinSpecifies the port pin connected to corresponding EXTI line.
Return values
None

Definition at line 529 of file stm32l4xx_hal_gpio.c.

530 {
531  /* Prevent unused argument(s) compilation warning */
532  UNUSED(GPIO_Pin);
533 
534  /* NOTE: This function should not be modified, when the callback is needed,
535  the HAL_GPIO_EXTI_Callback could be implemented in the user file
536  */
537 }

◆ HAL_GPIO_EXTI_IRQHandler()

void HAL_GPIO_EXTI_IRQHandler ( uint16_t  GPIO_Pin)

Handle EXTI interrupt request.

Parameters
GPIO_PinSpecifies the port pin connected to corresponding EXTI line.
Return values
None

Definition at line 514 of file stm32l4xx_hal_gpio.c.

515 {
516  /* EXTI line interrupt detected */
517  if(__HAL_GPIO_EXTI_GET_IT(GPIO_Pin) != 0x00u)
518  {
519  __HAL_GPIO_EXTI_CLEAR_IT(GPIO_Pin);
520  HAL_GPIO_EXTI_Callback(GPIO_Pin);
521  }
522 }
void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin)
EXTI line detection callback.

◆ HAL_GPIO_LockPin()

HAL_StatusTypeDef HAL_GPIO_LockPin ( GPIO_TypeDef *  GPIOx,
uint16_t  GPIO_Pin 
)

Lock GPIO Pins configuration registers.

Note
The locked registers are GPIOx_MODER, GPIOx_OTYPER, GPIOx_OSPEEDR, GPIOx_PUPDR, GPIOx_AFRL and GPIOx_AFRH.
The configuration of the locked GPIO pins can no longer be modified until the next reset.
Parameters
GPIOxwhere x can be (A..H) to select the GPIO peripheral for STM32L4 family
GPIO_Pinspecifies the port bits to be locked. This parameter can be any combination of GPIO_Pin_x where x can be (0..15).
Return values
None

Definition at line 479 of file stm32l4xx_hal_gpio.c.

480 {
481  __IO uint32_t tmp = GPIO_LCKR_LCKK;
482 
483  /* Check the parameters */
484  assert_param(IS_GPIO_LOCK_INSTANCE(GPIOx));
485  assert_param(IS_GPIO_PIN(GPIO_Pin));
486 
487  /* Apply lock key write sequence */
488  tmp |= GPIO_Pin;
489  /* Set LCKx bit(s): LCKK='1' + LCK[15-0] */
490  GPIOx->LCKR = tmp;
491  /* Reset LCKx bit(s): LCKK='0' + LCK[15-0] */
492  GPIOx->LCKR = GPIO_Pin;
493  /* Set LCKx bit(s): LCKK='1' + LCK[15-0] */
494  GPIOx->LCKR = tmp;
495  /* Read LCKK register. This read is mandatory to complete key lock sequence */
496  tmp = GPIOx->LCKR;
497 
498  /* Read again in order to confirm lock is active */
499  if ((GPIOx->LCKR & GPIO_LCKR_LCKK) != 0x00u)
500  {
501  return HAL_OK;
502  }
503  else
504  {
505  return HAL_ERROR;
506  }
507 }
return HAL_OK
assert_param(IS_RTC_WAKEUP_CLOCK(WakeUpClock))

◆ HAL_GPIO_ReadPin()

GPIO_PinState HAL_GPIO_ReadPin ( GPIO_TypeDef *  GPIOx,
uint16_t  GPIO_Pin 
)

Read the specified input port pin.

Parameters
GPIOxwhere x can be (A..H) to select the GPIO peripheral for STM32L4 family
GPIO_Pinspecifies the port bit to read. This parameter can be any combination of GPIO_Pin_x where x can be (0..15).
Return values
Theinput port pin value.

Definition at line 397 of file stm32l4xx_hal_gpio.c.

398 {
399  GPIO_PinState bitstatus;
400 
401  /* Check the parameters */
402  assert_param(IS_GPIO_PIN(GPIO_Pin));
403 
404  if ((GPIOx->IDR & GPIO_Pin) != 0x00u)
405  {
406  bitstatus = GPIO_PIN_SET;
407  }
408  else
409  {
410  bitstatus = GPIO_PIN_RESET;
411  }
412  return bitstatus;
413 }
GPIO_PinState
GPIO Bit SET and Bit RESET enumeration.
assert_param(IS_RTC_WAKEUP_CLOCK(WakeUpClock))

◆ HAL_GPIO_TogglePin()

void HAL_GPIO_TogglePin ( GPIO_TypeDef *  GPIOx,
uint16_t  GPIO_Pin 
)

Toggle the specified GPIO pin.

Parameters
GPIOxwhere x can be (A..H) to select the GPIO peripheral for STM32L4 family
GPIO_Pinspecifies the pin to be toggled.
Return values
None

Definition at line 453 of file stm32l4xx_hal_gpio.c.

454 {
455  /* Check the parameters */
456  assert_param(IS_GPIO_PIN(GPIO_Pin));
457 
458  if ((GPIOx->ODR & GPIO_Pin) != 0x00u)
459  {
460  GPIOx->BRR = (uint32_t)GPIO_Pin;
461  }
462  else
463  {
464  GPIOx->BSRR = (uint32_t)GPIO_Pin;
465  }
466 }
assert_param(IS_RTC_WAKEUP_CLOCK(WakeUpClock))

◆ HAL_GPIO_WritePin()

void HAL_GPIO_WritePin ( GPIO_TypeDef *  GPIOx,
uint16_t  GPIO_Pin,
GPIO_PinState  PinState 
)

Set or clear the selected data port bit.

Note
This function uses GPIOx_BSRR and GPIOx_BRR registers to allow atomic read/modify accesses. In this way, there is no risk of an IRQ occurring between the read and the modify access.
Parameters
GPIOxwhere x can be (A..H) to select the GPIO peripheral for STM32L4 family
GPIO_Pinspecifies the port bit to be written. This parameter can be any combination of GPIO_Pin_x where x can be (0..15).
PinStatespecifies the value to be written to the selected bit. This parameter can be one of the GPIO_PinState enum values:
  • GPIO_PIN_RESET: to clear the port pin
  • GPIO_PIN_SET: to set the port pin
Return values
None

Definition at line 431 of file stm32l4xx_hal_gpio.c.

432 {
433  /* Check the parameters */
434  assert_param(IS_GPIO_PIN(GPIO_Pin));
435  assert_param(IS_GPIO_PIN_ACTION(PinState));
436 
437  if(PinState != GPIO_PIN_RESET)
438  {
439  GPIOx->BSRR = (uint32_t)GPIO_Pin;
440  }
441  else
442  {
443  GPIOx->BRR = (uint32_t)GPIO_Pin;
444  }
445 }
assert_param(IS_RTC_WAKEUP_CLOCK(WakeUpClock))