HAL GPIO driver implementation for STM32F4 series. More...
#include "core/cortex-m4/gpio.h"#include "core/cortex-m4/gpio_reg.h"#include "core/cortex-m4/rcc_reg.h"
Functions | |
| void | hal_gpio_setmode (hal_gpio_pin pin, hal_gpio_mode mode, hal_gpio_pullup_pulldown pupd) |
| Configure the mode and pull-up/pull-down for a GPIO pin. | |
| hal_gpio_mode | hal_gpio_getmode (hal_gpio_pin pin) |
| Get the current mode of a GPIO pin. | |
| void | hal_gpio_digitalwrite (hal_gpio_pin pin, hal_gpio_state state) |
| Write a digital value to a GPIO pin. | |
| hal_gpio_state | hal_gpio_digitalread (hal_gpio_pin pin) |
| Read the digital value from a GPIO pin. | |
| void | hal_gpio_enable_rcc (hal_gpio_pin pin) |
| Enable the RCC clock for a GPIO port. | |
| void | hal_gpio_set_alternate_function (hal_gpio_pin pin, hal_gpio_alternate_function_t alt_fn) |
| Configure alternate function for a GPIO pin. | |
| void | hal_gpio_set_output_type (hal_gpio_pin pin, hal_gpio_output_type otyper) |
| Configure GPIO output type. | |
| void | hal_gpio_set_output_speed (hal_gpio_pin pin, hal_gpio_output_speed speed) |
| Configure GPIO output speed. | |
HAL GPIO driver implementation for STM32F4 series.
This file contains the implementation of GPIO hardware abstraction layer functions for STM32F4 microcontrollers. It provides complete GPIO pin configuration and control capabilities including:
All functions handle the required RCC clock enabling automatically.
| hal_gpio_state hal_gpio_digitalread | ( | hal_gpio_pin | pin | ) |
Read the digital value from a GPIO pin.
Read the digital state from a GPIO pin.
| pin | Pin identifier to read |
Reads the IDR register for the specified pin and returns the current input state.
< GPIOA base address
| void hal_gpio_digitalwrite | ( | hal_gpio_pin | pin, |
| hal_gpio_state | state ) |
Write a digital value to a GPIO pin.
Write a digital state to a GPIO pin.
| pin | Pin identifier to control |
| state | Desired output state (HIGH or LOW) |
Uses the BSRR register for atomic set/reset operations to avoid read-modify-write sequences.
< GPIOA base address
< GPIOA base address
| void hal_gpio_enable_rcc | ( | hal_gpio_pin | pin | ) |
Enable the RCC clock for a GPIO port.
Enable the RCC clock for a specific GPIO pin's port.
| pin | Pin identifier whose port clock should be enabled |
Enables the AHB1 peripheral clock for the GPIO port containing the specified pin. This is automatically called by other GPIO functions when needed.
| hal_gpio_mode hal_gpio_getmode | ( | hal_gpio_pin | pin | ) |
Get the current mode of a GPIO pin.
| pin | Pin identifier to query |
Reads the MODER register for the specified pin and returns the current mode configuration.
< GPIOA base address
| void hal_gpio_set_alternate_function | ( | hal_gpio_pin | pin, |
| hal_gpio_alternate_function_t | alt_fn ) |
Configure alternate function for a GPIO pin.
Set the alternate function for a GPIO pin.
| pin | Pin identifier to configure |
| alt_fn | Alternate function number/type to assign |
Configures the specified pin for alternate function mode and sets the appropriate alternate function selection in AFRL/AFRH. Automatically enables the GPIO port clock if needed.
< GPIOA base address
< GPIOA base address
< GPIOA base address
< GPIOA base address
| void hal_gpio_set_output_speed | ( | hal_gpio_pin | pin, |
| hal_gpio_output_speed | speed ) |
Configure GPIO output speed.
Set the output speed for a GPIO pin.
| pin | Pin identifier to configure |
| speed | Desired output speed (low/medium/high/very high) |
Sets the output speed in the OSPEEDR register for the specified pin. Does not change the pin mode - must be configured separately.
< GPIOA base address
< GPIOA base address
| void hal_gpio_set_output_type | ( | hal_gpio_pin | pin, |
| hal_gpio_output_type | otyper ) |
Configure GPIO output type.
Set the output type for a GPIO pin.
| pin | Pin identifier to configure |
| otyper | Output type (push-pull or open-drain) |
Sets the output type in the OTYPER register for the specified pin. Does not change the pin mode - must be configured separately.
< GPIOA base address
< GPIOA base address
| void hal_gpio_setmode | ( | hal_gpio_pin | pin, |
| hal_gpio_mode | mode, | ||
| hal_gpio_pullup_pulldown | pupd ) |
Configure the mode and pull-up/pull-down for a GPIO pin.
Set the mode of a GPIO pin.
| pin | Pin identifier (e.g., PA5, PC13) |
| mode | Desired pin mode (input/output/alternate/analog) |
| pupd | Pull-up/pull-down configuration |
This function:
< GPIOA base address
< GPIOA base address
< GPIOA base address
< GPIOA base address