GPS Device
Loading...
Searching...
No Matches
stm32f401re_gpio.h File Reference

STM32F401RE GPIO driver public API. More...

#include "common.h"
#include "stm32f401re.h"
Include dependency graph for stm32f401re_gpio.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  GPIO_CFG_ts
 Configuration structure for initializing a GPIO pin. More...

Macros

#define GPIO_NAME_LEN   5
 Length of the null-terminated GPIO port name string (e.g. "GPIOA").

Enumerations

enum  GPIO_PIN_te {
  GPIO_PIN_0 , GPIO_PIN_1 , GPIO_PIN_2 , GPIO_PIN_3 ,
  GPIO_PIN_4 , GPIO_PIN_5 , GPIO_PIN_6 , GPIO_PIN_7 ,
  GPIO_PIN_8 , GPIO_PIN_9 , GPIO_PIN_10 , GPIO_PIN_11 ,
  GPIO_PIN_12 , GPIO_PIN_13 , GPIO_PIN_14 , GPIO_PIN_15
}
 GPIO pin number within a port (0–15). More...
enum  GPIO_MODE_te {
  GPIO_MODE_INPUT , GPIO_MODE_OUTPUT , GPIO_MODE_ALTERNATE_FUNCTION , GPIO_MODE_ANALOG ,
  GPIO_MODE_INTERRUPT
}
 GPIO pin operating mode. More...
enum  GPIO_OUTPUT_TYPE_te { GPIO_OUTPUT_TYPE_PUSHPULL , GPIO_OUTPUT_TYPE_OPENDRAIN }
 GPIO output driver type. More...
enum  GPIO_OUTPUT_SPEED_te { GPIO_OUTPUT_SPEED_LOW , GPIO_OUTPUT_SPEED_MEDIUM , GPIO_OUTPUT_SPEED_HIGH , GPIO_OUTPUT_SPEED_VERYHIGH }
 GPIO output slew rate / speed. More...
enum  GPIO_PULL_MODE_te { GPIO_PULL_MODE_NOPUPD , GPIO_PULL_MODE_PU , GPIO_PULL_MODE_PD }
 GPIO internal pull-up / pull-down resistor configuration. More...
enum  GPIO_ALTERNATE_FUNCTION_te {
  GPIO_ALTERNATE_FUNCTION_AF0 , GPIO_ALTERNATE_FUNCTION_AF1 , GPIO_ALTERNATE_FUNCTION_AF2 , GPIO_ALTERNATE_FUNCTION_AF3 ,
  GPIO_ALTERNATE_FUNCTION_AF4 , GPIO_ALTERNATE_FUNCTION_AF5 , GPIO_ALTERNATE_FUNCTION_AF6 , GPIO_ALTERNATE_FUNCTION_AF7 ,
  GPIO_ALTERNATE_FUNCTION_AF8 , GPIO_ALTERNATE_FUNCTION_AF9 , GPIO_ALTERNATE_FUNCTION_AF10 , GPIO_ALTERNATE_FUNCTION_AF11 ,
  GPIO_ALTERNATE_FUNCTION_AF12 , GPIO_ALTERNATE_FUNCTION_AF13 , GPIO_ALTERNATE_FUNCTION_AF14 , GPIO_ALTERNATE_FUNCTION_AF15
}
 GPIO alternate function mapping (AF0–AF15). More...
enum  GPIO_INTERRUPT_TRIGGER_te { GPIO_INTERRUPT_TRIGGER_RE , GPIO_INTERRUPT_TRIGGER_FE , GPIO_INTERRUPT_TRIGGER_RFE }
 EXTI edge trigger selection for interrupt mode. More...

Functions

void gpio_init (GPIO_CFG_ts *gpio_cfg)
 Initializes a GPIO pin according to the given configuration.
void gpio_deinit (GPIO_REGDEF_ts const *gpio_port)
 Deinitializes a GPIO port by resetting its registers to reset values.
void gpio_write (GPIO_REGDEF_ts *gpio_port, uint8_t gpio_pin, PIN_STATUS_te pin_status)
 Drives a GPIO output pin high or low.
PIN_STATUS_te gpio_read (GPIO_REGDEF_ts const *gpio_port, uint8_t gpio_pin)
 Reads the current logic level of a GPIO input pin.
void gpio_clear_interrupt (EXTI_LINES_te exti_line)
 Clears the EXTI pending flag for the given interrupt line.
void gpio_get_name (GPIO_REGDEF_ts const *gpio_port, char *name)
 Returns the name string of a GPIO port (e.g. "GPIOA").

Detailed Description

STM32F401RE GPIO driver public API.

Author
github.com/Baksi675

This module provides a software interface to the STM32F401RE GPIO peripheral, supporting the following pin modes:

  • Input / Output — standard digital I/O with configurable output type, speed, and pull-up/pull-down resistors
  • Alternate Function — routes a pin to an on-chip peripheral (USART, I2C, SPI, etc.)
  • Analog — disables the digital input buffer for ADC use
  • Interrupt — configures the EXTI line and NVIC for edge-triggered interrupts

The peripheral clock is enabled automatically during gpio_init and disabled during gpio_deinit.

Version
0.1
Date
2026-01-23

Definition in file stm32f401re_gpio.h.