Skip to content

devcoons/stm32-drv-gpio

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GPIO DRIVER

STM32 Custom Framework Submodule for GPIO.

Supported hardware

  • NUCLEO-H745ZI-Q
  • NUCLEO-L552ZE-Q

Functions guide

  • 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 buffer
  • gpio_get_value : stores in the value 1 or 0.
  • gpio_set_value : to set the output.
  • gpio_toggle_value : to toggle the output.

How to use

  • 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.

Example

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

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages