Module imxrt_hal::gpio

source ·
Expand description

General purpose I/O.

Create a Port over a RAL GPIO instance. Then, use the Port to allocate GPIO outputs and inputs.

Use Output to drive GPIO outputs. Use Input to read GPIO pin states, and trigger interrupts when GPIO states change.

Interior mutability

Methods on Output and Input take immutable references, &self. The hardware guarantees that these operations can occur without data races. Methods that require multiple operations on a register are implemented on the Port, and take the GPIO by reference.

Example

use imxrt_hal::gpio::Port;
use imxrt_ral::gpio::GPIO2;

let mut gpio2 = Port::new(unsafe { GPIO2::instance() });
let gpio_b0_04 = // Handle to GPIO_B0_04 IOMUXC pin, provided by BSP or higher-level HAL...

let output = gpio2.output(gpio_b0_04);
output.set();
output.clear();
output.toggle();

let input = gpio2.input(output.release());
assert!(input.is_set());

TODO

  • Fast GPIOs

Structs

Enums