Skip to main content

Module gpio

Module gpio 

Source
Expand description

General-purpose I/O.

A pin’s port, number and mode all live in its type.

Pins are handed out by GpioExt::split. Modes are changed with the into_* methods, each returning a new type.

ⓘ
let parts = dp.gpioa.split(&mut rcu);
let mut led = parts.pa5.into_output();
led.set_high().unwrap();
let tx = parts.pa9.into_alternate::<1>();

Two modes are special. PA13/PA14 start as Debugger, since after reset they really are wired to SWD; leaving that goes through the separate activate_into_*() family. Pin::lock freezes a configuration until the next chip reset, which the type reflects as Locked — with no way back, since the hardware has none either.

Structs§

Alternate
Mode: alternate function AF, routing the pin to a peripheral, driven as OTYPE (PushPull or OpenDrain).
Analog
Mode: analog, the input mode the ADC requires.
Debugger
Mode: serial-wire debug, the reset state of PA13/PA14.
ErasedPin
A pin whose identity has moved into runtime values, keeping its mode.
Input
Mode: digital input.
Locked
Mode: configuration frozen until the next chip reset, wrapping the mode it was locked in.
OpenDrain
Output type: driven low, released high — needs a pull-up to reach a high level.
Output
Mode: digital output, of type OTYPE (PushPull or OpenDrain).
PartsA
The pins of this port, in their reset modes.
PartsB
The pins of this port, in their reset modes.
PartsF
The pins of this port, in their reset modes.
Pin
A single pin: P is the port ('A', 'B', 'C' or 'F'), N the pin number.
PushPull
Output type: driven both high and low.

Enums§

Port
Which port an ErasedPin came from.
Pull
Internal pull resistor.
Speed
Output slew rate. Slower edges radiate less; faster ones are needed for high-speed peripherals.

Traits§

Active
Marks a mode whose pin may be reconfigured.
GpioExt
Extension trait splitting a GPIO port into its individual pins.
HasLock
Marks a pin on a port that has a LOCK register, gating Pin::lock.
ValidAf
Marks AF as a valid alternate function number for this pin.