bf0_hal_gpio.h

Header file of GPIO HAL module.

Author

Sifli software development team

Attention

Defines

GPIO_MODE_INPUT

Input Floating Mode

GPIO_MODE_OUTPUT

Output Push Pull Mode

GPIO_MODE_OUTPUT_OD

Output Open Drain Mode

GPIO_MODE_IT_RISING

External Interrupt Mode with Rising edge trigger detection

GPIO_MODE_IT_FALLING

External Interrupt Mode with Falling edge trigger detection

GPIO_MODE_IT_RISING_FALLING

External Interrupt Mode with Rising/Falling edge trigger detection

GPIO_MODE_IT_HIGH_LEVEL

External Interrupt Mode with high level detection

GPIO_MODE_IT_LOW_LEVEL

External Interrupt Mode with low level detection

GPIO_NOPULL

No Pull-up or Pull-down activation

GPIO_PULLUP

Pull-up activation

GPIO_PULLDOWN

Pull-down activation

GPIO1_PIN_NUM
GPIO2_PIN_NUM
IS_GPIO_PIN_ACTION(ACTION)
IS_GPIO_MODE(__MODE__)
IS_GPIO_PULL(__PULL__)

Enums

enum GPIO_PinState

GPIO Bit SET and Bit RESET enumeration.

Values:

enumerator GPIO_PIN_RESET
enumerator GPIO_PIN_SET

Functions

void HAL_GPIO_Init(GPIO_TypeDef *hgpio, GPIO_InitTypeDef *GPIO_Init)

Initialize the GPIO peripheral according to the specified parameters in the GPIO_Init.

参数:
  • hgpio – GPIO handle This parameter can be one of the following values:

  • GPIO_Init – pointer to a GPIO_InitTypeDef structure that contains the configuration information for the specified GPIO peripheral.

返回值:

None

void HAL_GPIO_DeInit(GPIO_TypeDef *hgpio, uint32_t GPIO_Pin)

De-initialize the GPIOx peripheral registers to their default reset values.

参数:
  • hgpio – GPIO handle

  • GPIO_Pin – specifies the pin index to be written, starting from 0.

返回值:

None

GPIO_PinState HAL_GPIO_ReadPin(GPIO_TypeDef *hgpio, uint16_t GPIO_Pin)

Read the specified input port pin.

参数:
  • hgpio – GPIO handle

  • GPIO_Pin – specifies the pin index to be read, starting from 0.

返回值:

The – input port pin value.

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

Set or clear the selected data port bit.

参数:
  • hgpio – GPIO handle

  • GPIO_Pin – specifies the pin index to be written, starting from 0.

  • PinState – specifies 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

返回值:

None

void HAL_GPIO_TogglePin(GPIO_TypeDef *hgpio, uint16_t GPIO_Pin)

Toggle the specified GPIO pin.

参数:
  • hgpio – GPIO handle

  • GPIO_Pin – specifies the pin index to be toggoled, starting from 0.

返回值:

None

void HAL_GPIO_EXTI_IRQHandler(GPIO_TypeDef *hgpio, uint16_t GPIO_Pin)

Handle EXTI interrupt request.

参数:
  • hgpio – GPIO handle

  • GPIO_Pin – Specifies the port pin connected to corresponding EXTI line, starting from 0.

返回值:

None

void HAL_GPIO_EXTI_Callback(GPIO_TypeDef *hgpio, uint16_t GPIO_Pin)

EXTI line detection callback.

参数:
  • hgpio – GPIO handle

  • GPIO_Pin – Specifies the port pin connected to corresponding EXTI line, starting from 0.

返回值:

None

uint32_t HAL_GPIO_GetMode(GPIO_TypeDef *hgpio, uint16_t GPIO_Pin)

Get the GPIO mode.

参数:
  • hgpio – GPIO handle

  • GPIO_Pin – Specifies the port pin connected to corresponding EXTI line, starting from 0.

返回值:

mode – in GPIO mode, return UINT32_MAX if invalid

void HAL_GPIO_IRQHandler(GPIO_TypeDef *hgpio)

Handle all GPIO interrupt request which belong current group.

参数:
  • hgpio – GPIO handle

返回值:

None

HAL_StatusTypeDef HAL_GPIO_Save(GPIO_TypeDef *hgpio, GPIOxRestore_TypeDef *p_buf, uint32_t buf_cnt)

Save gpio instance’s all configuration to buffer.

参数:
  • hgpio – - GPIO handle

  • p_buf – - Buffer for saving GPIO configuration

  • buf_cnt – - Buffer numbers

返回:

Hal status error

HAL_StatusTypeDef HAL_GPIO_Restore(GPIO_TypeDef *hgpio, GPIOxRestore_TypeDef *p_buf, uint32_t buf_cnt)

Restore gpio instance’s all configuration from buffer.

参数:
  • hgpio – - GPIO handle

  • p_buf – - Buffer for restore GPIO configuration

  • buf_cnt – - Buffer numbers

返回:

Hal status error

HAL_StatusTypeDef HAL_GPIO_ClearInterrupt(GPIO_TypeDef *hgpio)

Clear all interrupt.

参数:
  • hgpio – GPIO handle

返回:

Hal status error

HAL_StatusTypeDef HAL_GPIO_ClearPinInterrupt(GPIO_TypeDef *hgpio, uint16_t GPIO_Pin)

Clear specified pin interrupt.

参数:
  • hgpio – GPIO handle

  • GPIO_Pin – specifies the pin index to be clear, starting from 0.

返回:

HAL_OK if IRQ been clear

struct GPIO_TypeDef

Public Members

uint32_t DIR
uint32_t DOR
uint32_t DOSR
uint32_t DOCR
uint32_t DOER
uint32_t DOESR
uint32_t DOECR
uint32_t IER
uint32_t IESR
uint32_t IECR
uint32_t ITR
uint32_t ITSR
uint32_t ITCR
uint32_t IPHR
uint32_t IPHSR
uint32_t IPHCR
uint32_t IPLR
uint32_t IPLSR
uint32_t IPLCR
uint32_t ISR
uint32_t IER_EXT
uint32_t IESR_EXT
uint32_t IECR_EXT
uint32_t ISR_EXT
uint32_t OEMR
uint32_t OEMSR
uint32_t OEMCR
uint32_t RSVD2[5]
struct GPIO_InitTypeDef
#include <bf0_hal_gpio.h>

GPIO Init structure definition.

Public Members

uint32_t Pin

Specifies the GPIO pins to be configured. pin id of GPIO1 or GPIO2, starting from 0

uint32_t Mode

Specifies the operating mode for the selected pins. This parameter can be a value of GPIO mode

uint32_t Pull

TODO: not used. Specifies the Pull-up or Pull-Down activation for the selected pins. This parameter can be a value of GPIO pull

struct GPIOxRestore_TypeDef
#include <bf0_hal_gpio.h>

GPIO save&restore buffer type definition.

Public Members

uint32_t DOR
uint32_t DOER
uint32_t IER
uint32_t ITR
uint32_t IPHR
uint32_t IPLR
uint32_t IER_EXT