Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

The FreeRTOS demo application illustrates the corresponding APIs through controlling of the LEDs and Push-Buttons available on the carrier board.

1. Understanding FreeRTOS GPIO Interfaces

1.1. FreeRTOS GPIO Implementation

The FreeRTOS BSP makes use of the STM32CubeH7 software component to provide a device driver for the STM32H7 GPIO. The driver is configured (enabled / disabled) at the BSP build time, using the HAL_GPIO_MODULE_ENABLED configuration option, defined in the stm32h7xx_hal_conf.h file.

1.2. FreeRTOS GPIO C-Binding API

The GPIO driver implements the following C-binding API:

Function

Description

Comments

void HAL_GPIO_Init(GPIO_TypeDef * GPIOx, GPIO_InitTypeDef * GPIO_Init)

Initialise GPIO pins in a specified GPIO port

GPIOx is a pointer to the GPIO port registers; CPIO_Init is a pointer to a data structure describing configuration of a specific pin of the given GPIO port (see below)

void HAL_GPIO_DeInit(GPIO_TypeDef * GPIOx, uint32_t GPIO_Pin)

Reset a GPIO pin to default settings

GPIO_Pin is GPIO_PIN_x, х is one of values from 0 to 15

GPIO_PinState HAL_GPIO_ReadPin (GPIO_TypeDef * GPIOx, uint16_t GPIO_Pin)

Read state of a GPIO pin

GPIO_Pin is GPIO_PIN_x, х is one of values from 0 to 15; returns one of {GPIO_PIN_RESET = 0, GPIO_PIN_SET}

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

Set or clear a GPIO pin

GPIO_Pin is GPIO_PIN_x, х is one of values from 0 to 15; PinState is either GPIO_PIN_RESET or GPIO_PIN_SET

void HAL_GPIO_TogglePin(GPIO_TypeDef * GPIOx, uint16_t GPIO_Pins)

Toggle specified GPIO pins

The GPIO_InitTypeDef data structure used in the HAL_GPIO_Init interface has the following definition:

Code Block
typedef struct {
    uint32_t Pin;    /* GPIO pins to be configured */
    uint32_t Mode;   /* Operating mode for the selected pins */
    uint32_t Pull;   /* Pull-up or Pull-Down activation for the selected pins */
    uint32_t Speed;  /* Speed for the selected pins */
    uint32_t Alternate;/* Peripheral to be connected to the selected pin */
} GPIO_InitTypeDef;

1.3. FreeRTOS LED and Push-Button Tasks

The FreeRTOS demos application provides two threads illustrating use of the GPIO API from a FreeRTOS application. Specifically:

...