Module capsules_core::gpio

source ·
Expand description

Provides userspace applications with access to GPIO pins.

GPIOs are presented through a driver interface with synchronous commands and a callback for interrupts.

This capsule takes an array of pins to expose as generic GPIOs. Note that this capsule is used for general purpose GPIOs. Pins that are attached to LEDs or buttons are generally wired directly to those capsules, not through this capsule as an intermediary.

§Usage


let gpio_pins = static_init!(
    [Option<&'static sam4l::gpio::GPIOPin>; 4],
    [Option<&sam4l::gpio::PB[14]>,
     Option<&sam4l::gpio::PB[15]>,
     Option<&sam4l::gpio::PB[11]>,
     Option<&sam4l::gpio::PB[12]>]);
let gpio = static_init!(
    capsules::gpio::GPIO<'static, sam4l::gpio::GPIOPin>,
    capsules::gpio::GPIO::new(gpio_pins));
for maybe_pin in gpio_pins.iter() {
    if let Some(pin) = maybe_pin {
        pin.set_client(gpio);
    }
}

§Syscall Interface

  • Stability: 2 - Stable

§Commands

All GPIO operations are synchronous.

Commands control and query GPIO information, namely how many GPIOs are present, the GPIO direction and state, and whether they should interrupt.

§Subscribes

The GPIO interface provides only one callback, which is used for pins that have had interrupts enabled.

Structs§

Constants§