[−][src]Struct embedded_hal_sync_pins::pins::OpenDrainPin
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::{InputPin as HalInputPin, OutputPin}; use std::sync::{Arc, atomic::Ordering}; let state = Arc::new(AtomicPinState::new()); let mut pin = OpenDrainPin::new(state.clone()); pin.try_set_low().unwrap(); assert_eq!(Ok(false), pin.try_is_low()); assert_eq!(Ok(false), pin.try_is_high()); assert_eq!(PinState::Floating, state.load(Ordering::SeqCst)); pin.try_set_high().unwrap(); assert_eq!(Ok(false), pin.try_is_high()); assert_eq!(Ok(true), pin.try_is_low());
Implementations
impl OpenDrainPin
[src]
pub fn new(state: Arc<AtomicPinState>) -> Self
[src]
Trait Implementations
impl Clone for OpenDrainPin
[src]
pub fn clone(&self) -> OpenDrainPin
[src]
pub fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl Debug for OpenDrainPin
[src]
impl InputPin for OpenDrainPin
[src]
type Error = Infallible
Error type
pub fn try_is_high(&self) -> Result<bool, Self::Error>
[src]
pub fn try_is_low(&self) -> Result<bool, Self::Error>
[src]
impl OutputPin for OpenDrainPin
[src]
type Error = Infallible
Error type
pub fn try_set_high(&mut self) -> Result<(), Self::Error>
[src]
pub fn try_set_low(&mut self) -> Result<(), Self::Error>
[src]
pub fn try_set_state(&mut self, state: PinState) -> Result<(), Self::Error>
[src]
Auto Trait Implementations
impl RefUnwindSafe for OpenDrainPin
[src]
impl Send for OpenDrainPin
[src]
impl Sync for OpenDrainPin
[src]
impl Unpin for OpenDrainPin
[src]
impl UnwindSafe for OpenDrainPin
[src]
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,