Expand description

A library for accessing GPIO lines on Linux platforms using the GPIO character device.

Lines are requested and manipulated using the request module.

The lines available on specific chips can be discovered using the chip module.

The lines available on the system can be discovered by name using the find_named_line and find_named_lines functions, or using the iterator returned by lines.

Example Usage

Request an input line and output line, and read from the input and change the output to that value:

use gpiocdev::request::Request;
use gpiocdev::line::{Bias, Value};

let req = Request::builder()
    .on_chip("/dev/gpiochip0")
    .with_line(3)
    .as_input()
    .with_bias(Bias::PullUp)
    .with_line(4)
    .as_output(Value::Inactive)
    .request()?;
let value = req.value(3)?;
req.set_value(4, value)?;

Monitor a line for debounced edges:

use gpiocdev::request::Request;
use gpiocdev::line::EdgeDetection;
use std::time::Duration;

let req = Request::builder()
    .on_chip("/dev/gpiochip0")
    .with_line(5)
    .with_edge_detection(EdgeDetection::BothEdges)
    .with_debounce_period(Duration::from_millis(5))
    .request()?;
for edge in req.edge_events() {
    println!("{:?}", edge);
}

Modules

Wrappers for various async reactors.
Types and functions specific to chips.
Types specific to lines.
Types and functions related to requesting lines.

Structs

The info for a line discovered in the system.
An iterator for all lines in the system available to the caller.
A moment in time in UTC.

Enums

The uAPI ABI versions available to interact with the kernel.
Errors returned by gpiocdev functions.

Functions

Detect the most recent uAPI ABI supported by the platform.
Find the chip hosting a named line, and the line offset on that chip.
Find a collection of named lines.
An iterator over all the GPIO lines visible to the caller.
Check if the platform and library support a specific ABI version.

Type Definitions

The result for gpiocdev functions.