pub struct InputPin { /* private fields */ }
Expand description
Provides the embedded_hal::digital
and embedded_hal_async::digital::Wait
traits for a gpiocdev::Request
containing a single input pin using the
async-io reactor.
Holding the InputPin
grants exclusive access to the pin.
Do NOT drop the InputPin
until you are completely done with it.
Dropping and re-requesting the line is far more expensive than getting the value.
Implementations§
Source§impl InputPin
impl InputPin
Sourcepub fn new<P>(chip: P, offset: u32) -> Result<Self, Error>
pub fn new<P>(chip: P, offset: u32) -> Result<Self, Error>
Creates a new input pin for the given offset
on the given chip
.
use embedded_hal::digital::InputPin;
use embedded_hal_async::digital::Wait;
let mut pin = gpiocdev_embedded_hal::async_io::InputPin::new("/dev/gpiochip0", 4)?;
if pin.is_high()? {
println!("Input is high.");
}
pin.wait_for_falling_edge().await?;
Trait Implementations§
Source§impl Wait for InputPin
impl Wait for InputPin
Source§async fn wait_for_high(&mut self) -> Result<(), Self::Error>
async fn wait_for_high(&mut self) -> Result<(), Self::Error>
Wait for the pin to go high.
§Note
The implementation is event driven, and only looks for events when waiting for the level to change. If the returned future resolves then subsequent calls are effectively a no-op. Wait on an edge or the pin to go low instead.
Source§async fn wait_for_low(&mut self) -> Result<(), Self::Error>
async fn wait_for_low(&mut self) -> Result<(), Self::Error>
Wait for the pin to go low.
§Note
The implementation is event driven, and only looks for events when waiting for the level to change. If the returned future resolves then subsequent calls are effectively a no-op. Wait on an edge or the pin to go high instead.