Module stm32_hal2::gpio
source · Expand description
This module provides functionality for General Purpose Input and Output (GPIO) pins, including all GPIOx register functions. It also configures GPIO interrupts using SYSCFG and EXTI registers as appropriate. It allows pin mode configuration, interrupts, and DMA.
The primary API uses a Pin
struct, with its methods. There are also standalone functions
available to set and read pin state, and clear interrupts, without access to a Pin
.
Structs§
- Represents a single GPIO pin. Allows configuration, and reading/setting state.
Enums§
- Values for
GPIOx_LCKR
. - The pulse edge used to trigger interrupts. Either rising, falling, or either.
- Values for
GPIOx_OSPEEDR
. This configures I/O output speed. See the user manual for your MCU for what speeds these are. Note that Fast speed (0b10) is not available on all STM32 families. - Values for
GPIOx_OTYPER
. - Values for
GPIOx_MODER
. Sets pin to input, output, and other functionality. - Values for
GPIOx_IDR
andGPIOx_ODR
. - GPIO port letter
- Values for
GPIOx_PUPDR
. Sets if the pin uses the internal pull-up or pull-down - Values for
GPIOx_BRR
.
Functions§
- Clear an EXTI interrupt, lines 0 - 15. Note that this function currently doesn’t support higher extis, but will work for all GPIO interrupts.
- Check if a pin’s input voltage is high. Reads from the
IDR
register. Does not require aPin
struct. - Check if a pin’s input voltage is low. Reads from the
IDR
register. Does not require aPin
struct. - Read a series of words from the IDR register.
- Set a pin’s output voltage to high. Sets the
BSRR
register. Atomic. Does not require aPin
struct. - Set a pin’s output voltage to low. Sets the
BSRR
register. Atomic. Does not require aPin
struct. - Set a pin state (ie set high or low output voltage level). See also
set_high()
andset_low()
. Sets theBSRR
register. Atomic. Does not require aPin
struct. - Write a series of words to the BSRR (atomic output) register. Note that these are direct writes to the full, 2-sided register - not a series of low/high values.