pub struct OutputPin(/* private fields */);
Expand description
Provides embedded_hal::digital
traits for a gpiocdev::Request
containing a single output pin.
Holding the OutputPin
grants exclusive access to the pin.
Do NOT drop the OutputPin
until you are completely done with it.
While you hold the OutputPin
the line is guaranteed to remain as set,
but when dropped it may be altered, either by other users or by the kernel
itself.
Dropping and re-requesting the line is also far more expensive than setting
the value.
Implementations§
Source§impl OutputPin
impl OutputPin
Sourcepub fn new<P>(chip: P, offset: u32, state: PinState) -> Result<Self, Error>
pub fn new<P>(chip: P, offset: u32, state: PinState) -> Result<Self, Error>
Creates a new output pin for the given offset
on the given chip
.
use embedded_hal::digital::{OutputPin, PinState};
let mut pin = gpiocdev_embedded_hal::OutputPin::new("/dev/gpiochip0", 17, PinState::Low)?;
// later...
pin.set_high()?;
Sourcepub fn into_input_pin(self) -> Result<InputPin, Error>
pub fn into_input_pin(self) -> Result<InputPin, Error>
Set this pin to input mode.
Sourcepub fn from_found_line(fl: FoundLine, state: PinState) -> Result<Self, Error>
pub fn from_found_line(fl: FoundLine, state: PinState) -> Result<Self, Error>
Create an OutputPin
from a gpiocdev::FoundLine
.
§Examples
use embedded_hal::digital::{OutputPin, PinState};
let led0 = gpiocdev::find_named_line("LED0").unwrap();
let mut pin = gpiocdev_embedded_hal::OutputPin::from_found_line(led0, PinState::High)?;
// ...
pin.set_low()?;
Trait Implementations§
Source§impl StatefulOutputPin for OutputPin
impl StatefulOutputPin for OutputPin
Source§impl TryFrom<Request> for OutputPin
impl TryFrom<Request> for OutputPin
Source§fn try_from(req: Request) -> Result<Self, Self::Error>
fn try_from(req: Request) -> Result<Self, Self::Error>
Convert any single output line gpiocdev::Request
into an OutputPin
.
This allows for advanced configurations such as setting bias or drive
or using the active_low flag to flip the line polarity.
OutputPin::new<P>()
should be used for less complex configurations.