Struct embedded_hal_sync_pins::pins::OpenDrainPin [−][src]
pub struct OpenDrainPin { /* fields omitted */ }Expand description
A mutable output pin in open drain configuration that can be safely shared between threads.
This pin implements embedded_hal::OutputPin and can be used
to share an AtomicPinState with an embedded_hal implementation. In open drain
configuration this pin is in a floating state (not connected) if it is set to low and
logical low (“pull to GND”) if it is set to high.
It also implements embedded_hal::InputPin, so it is possible
to also read the internal state, which will be either Floating
or Low.
Examples
use embedded_hal_sync_pins::pins::{AtomicPinState, OpenDrainPin, PinState};
use embedded_hal::digital::blocking::{InputPin as HalInputPin, OutputPin};
use std::sync::{Arc, atomic::Ordering};
let state = Arc::new(AtomicPinState::new());
let mut pin = OpenDrainPin::new(state.clone());
pin.set_low().unwrap();
assert_eq!(Ok(false), pin.is_low());
assert_eq!(Ok(false), pin.is_high());
assert_eq!(PinState::Floating, state.load(Ordering::SeqCst));
pin.set_high().unwrap();
assert_eq!(Ok(false), pin.is_high());
assert_eq!(Ok(true), pin.is_low());Implementations
Trait Implementations
type Error = Infallible
type Error = Infallible
Error type
Auto Trait Implementations
impl RefUnwindSafe for OpenDrainPin
impl Send for OpenDrainPin
impl Sync for OpenDrainPin
impl Unpin for OpenDrainPin
impl UnwindSafe for OpenDrainPin
Blanket Implementations
Mutably borrows from an owned value. Read more
