Cortex-M4 specific GPIO HAL interface. More...
#include "utils/gpio_types.h"

Go to the source code of this file.
Functions | |
| void | hal_gpio_setmode (hal_gpio_pin pin, hal_gpio_mode mode, hal_gpio_pullup_pulldown pupd) |
| Set the mode of 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 state to a GPIO pin. | |
| hal_gpio_state | hal_gpio_digitalread (hal_gpio_pin pin) |
| Read the digital state from a GPIO pin. | |
| void | hal_gpio_enable_rcc (hal_gpio_pin pin) |
| Enable the RCC clock for a specific GPIO pin's port. | |
| void | hal_gpio_set_alternate_function (hal_gpio_pin pin, hal_gpio_alternate_function_t alt_fn) |
| Set the alternate function for a GPIO pin. | |
| void | hal_gpio_set_output_type (hal_gpio_pin pin, hal_gpio_output_type otyper) |
| Set the output type for a GPIO pin. | |
| void | hal_gpio_set_output_speed (hal_gpio_pin pin, hal_gpio_output_speed speed) |
| Set the output speed for a GPIO pin. | |
Cortex-M4 specific GPIO HAL interface.
This header defines the function prototypes for configuring and controlling GPIO pins on Cortex-M4 microcontrollers. Functions include setting pin modes, reading and writing digital states, enabling clocks, and configuring alternate functions, output type, and speed.
| hal_gpio_state hal_gpio_digitalread | ( | hal_gpio_pin | pin | ) |
Read the digital state from a GPIO pin.
| pin | The GPIO pin to read. |
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 state to a GPIO pin.
| pin | The GPIO pin to write. |
| state | The digital state to set (HIGH/LOW). |
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 specific GPIO pin's port.
| pin | The GPIO pin whose port clock is to be enabled. |
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 | The GPIO pin to query. |
| 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 ) |
Set the alternate function for a GPIO pin.
| pin | The GPIO pin to configure. |
| alt_fn | The alternate function to assign to the 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 ) |
Set the output speed for a GPIO pin.
| pin | The GPIO pin to configure. |
| speed | The output speed (low, medium, high, very high). |
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 ) |
Set the output type for a GPIO pin.
| pin | The GPIO pin to configure. |
| otyper | The output type (push-pull or open-drain). |
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 ) |
Set the mode of a GPIO pin.
| pin | The GPIO pin to configure. |
| mode | The desired mode (input, output, alternate function, analog). |
| pupd | Pull-up/pull-down configuration for the 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