STM32 Custom Framework Submodule for GPIO.
- NUCLEO-H745ZI-Q
- NUCLEO-L552ZE-Q
gpio_initialize
: to initialize the peripheral.gpio_deinitialize
: to de-initialize the peripheral.gpio_add_value
: to store the value read by peripheral into a circular buffergpio_get_value
: stores in thevalue
1 or 0.gpio_set_value
: to set the output.gpio_toggle_value
: to toggle the output.
- In your code include
drv_gpio.h
. - In the
.ioc
file, set the pins you want to use in GPIO mode. - For each pin, create a
gpio_t
instance. The following members of the structure must be defined:.GPIO_Pin
: number of the enabled pin (ex. GPIO_PIN_5)..GPIOx
: port of the enabled pin (ex. GPIOB)..PinState
: initial state of the pin. (SET,RESET)..mode
: pin mode (INPUT, OUTPUT, ANALOG)..mx_init
: init function generated by the IDE.
This example shows how to use this driver to set LEDs. The board used is a NUCLEO-L552ZE-Q.
gpio_t led_1 =
{
.GPIO_Pin= GPIO_PIN_5,
.GPIOx = GPIOB,
.PinState= RESET,
.mode = OUTPUT,
.mx_init = MX_GPIO_Init
};
gpio_t led_3 =
{
.GPIO_Pin= GPIO_PIN_12,
.GPIOx = GPIOA,
.PinState= RESET,
.mode = OUTPUT,
.mx_init = MX_GPIO_Init
};
gpio_initialize(&led_1);
gpio_initialize(&led_3);
gpio_toggle_value(&led_1); //toggles the pin1: the result here is a blinking LED
gpio_set_value(&led_3, 1); //sets the pin: the led turns on
gpio_reset_value(&led_3,0); //resets the pin: the led turns off
For more complex example, like low/high pulses, the user must enable the DRV_GPIO_TIM
in the config file