Module tm4c123x_hal::gpio

source ·
Expand description

General Purpose Input / Output

This module makes heavy use of types to try and ensure you can’t have a pin in a mode you didn’t expect.

Most pins start in the Tristate state. You can call methods to convert them to inputs, outputs or put them into Alternate Function mode (e.g. to use with a UART).

Some of the modes require extra information, and for that we use the so- called ’Turbo Fishsyntax, which looks likemethod::`.

If the operation is non-atomic, then you need to pass a mut-reference to the port’s control structure. This ensures you can’t change two pins in two threads at the same time. If the operation is fully atomic (using the chip’s bit-banding feature) then this argument is not required.

Here’s an example:

let p = Peripherals::take().unwrap();
let mut sc = p.SYSCTL.constrain();
let mut portb = p.GPIO_PORTB.split(&sc.power_control);
let timer_output_pin = portb.pb0.into_af_push_pull::<gpio::AF7>(&mut portb.control);
let uart_tx_pin = portb.pb1.into_af_open_drain::<gpio::AF1, gpio::PullUp>(&mut portb.control);
let blue_led = portb.pb2.into_push_pull_output();
let button = portb.pb3.into_pull_up_input();

Modules

GPIO
GPIO
GPIO
GPIO
GPIO
GPIO

Structs

Alternate function 1 (type state)
Alternate function 2 (type state)
Alternate function 3 (type state)
Alternate function 4 (type state)
Alternate function 5 (type state)
Alternate function 6 (type state)
Alternate function 7 (type state)
Alternate function 8 (type state)
Alternate function 9 (type state)
Alternate function 14 (type state)
AlternateFunction mode (type state for a GPIO pin)
Sub-mode of Input: Floating input (type state)
Input mode (type state)
Pin is locked through the GPIOCR register
Sub-mode of Output/AlternateFunction: Open drain output (type state for Output)
Output mode (type state)
Sub-mode of Input: Pulled down input (type state)
Sub-mode of Input: Pulled up input (type state)
Sub-mode of Output/AlternateFunction: Push pull output (type state for Output)
Tri-state

Enums

Sets when a GPIO pin triggers an interrupt.

Traits

All the different Alternate Functions you can choose implement this
Extension trait to split a GPIO peripheral in independent pins and registers
All input modes implement this
All unlocked pin modes implement this
OpenDrain modes implement this
All output modes implement this