Struct embedded_hal_sync_pins::pins::PushPullPin
source · pub struct PushPullPin { /* private fields */ }Expand description
A mutable output pin 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.
It also implements embedded_hal::InputPin, so it is possible
to also read the internal state.
Examples
use embedded_hal_sync_pins::pins::{AtomicPinState, PushPullPin, PinState};
use embedded_hal::digital::{InputPin as HalInputPin, OutputPin};
use std::sync::Arc;
let state = Arc::new(AtomicPinState::new());
let mut pin = PushPullPin::new(state.clone());
pin.set_low().unwrap();
assert_eq!(Ok(true), pin.is_low());
pin.set_high().unwrap();
assert_eq!(Ok(true), pin.is_high());Implementations§
source§impl PushPullPin
impl PushPullPin
pub fn new(state: Arc<AtomicPinState>) -> Self
Trait Implementations§
source§impl Clone for PushPullPin
impl Clone for PushPullPin
source§fn clone(&self) -> PushPullPin
fn clone(&self) -> PushPullPin
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moresource§impl Debug for PushPullPin
impl Debug for PushPullPin
source§impl ErrorType for PushPullPin
impl ErrorType for PushPullPin
§type Error = Infallible
type Error = Infallible
Error type