Crate sysfs_gpio

source ·
Expand description

GPIO access under Linux using the GPIO sysfs interface

The methods exposed by this library are centered around the Pin struct and map pretty directly the API exposed by the kernel in syfs https://www.kernel.org/doc/Documentation/gpio/sysfs.txt.

Examples

Typical usage for systems where one wants to ensure that the pins in use are unexported upon completion looks like the following:

use sysfs_gpio::{Direction, Pin};
use std::thread::sleep;
use std::time::Duration;

fn main() {
    let my_led = Pin::new(127); // number depends on chip, etc.
    my_led.with_exported(|| {
        my_led.set_direction(Direction::Out).unwrap();
        loop {
            my_led.set_value(0).unwrap();
            sleep(Duration::from_millis(200));
            my_led.set_value(1).unwrap();
            sleep(Duration::from_millis(200));
        }
    }).unwrap();
}

Macros

Structs

Enums

Type Aliases