Crate gpiocdev_embedded_hal
source ·Expand description
A library providing embedded_hal::digital
traits for
gpiocdev::Request
and therefore for any Linux platform supporting the
GPIO character device.
The requests contain only a single pin which must be configured as an input or output.
Asynchronous wrappers providing embedded_hal_async::digital::Wait
traits are available for various async reactors.
The library can also be used to provide a simplified interface to
gpiocdev
for simple use cases.
§Example Usage
Reading an input pin:
use embedded_hal::digital::InputPin;
let mut pin = gpiocdev_embedded_hal::InputPin::new("/dev/gpiochip0", 4)?;
if pin.is_high()? {
println!("Input is high.");
}
Setting an output pin:
use embedded_hal::digital::{OutputPin, PinState};
// level is set as part of the request
let mut led0 = gpiocdev_embedded_hal::OutputPin::from_name("LED0", PinState::High)?;
// change the level later
led0.set_low()?;
Waiting for edges on an input pin:
use embedded_hal::digital::InputPin;
use embedded_hal_async::digital::Wait;
let mut pin = gpiocdev_embedded_hal::tokio::InputPin::new("/dev/gpiochip0", 4)?;
pin.wait_for_any_edge().await?;
if pin.is_high()? {
println!("Input is high.");
}
Modules§
- Asynchronous wrappers for the async-io reactor.
- Asynchronous wrappers for the Tokio reactor.
Structs§
- Provides
embedded_hal::digital
traits for agpiocdev::Request
containing a single input pin. - Provides
embedded_hal::digital
traits for agpiocdev::Request
containing a single output pin.
Enums§
- Errors returned by
gpiocdev_embedded_hal
types.