Struct embedded_hal_sync_pins::pins::AtomicPinState
source · pub struct AtomicPinState { /* private fields */ }Expand description
A digital pin state which can be safely shared between threads.
This type is based on AtomicUsize, so the same limitations and platform
support apply.
Implementations§
source§impl AtomicPinState
impl AtomicPinState
sourcepub fn new_with_state(state: PinState) -> Self
pub fn new_with_state(state: PinState) -> Self
Creates a new atomic pin state with a given state.
Examples
use embedded_hal_sync_pins::pins::{PinState, AtomicPinState};
let high = AtomicPinState::new_with_state(PinState::High);
let low = AtomicPinState::new_with_state(PinState::Low);sourcepub fn load(&self, order: Ordering) -> PinState
pub fn load(&self, order: Ordering) -> PinState
Loads a state from the atomic pin state.
load takes an Ordering argument which describes the memory
ordering of this operation. For more information see AtomicUsize::load.
sourcepub fn store(&self, state: PinState, order: Ordering)
pub fn store(&self, state: PinState, order: Ordering)
Stores a state into the atomic pin state.
store takes an Ordering argument which describes the memory
ordering of this operation. For more information see AtomicUsize::store.
sourcepub fn fetch_update<F>(&self, set_order: Ordering, fetch_order: Ordering, f: F)where
F: FnMut(PinState) -> Option<PinState>,
pub fn fetch_update<F>(&self, set_order: Ordering, fetch_order: Ordering, f: F)where
F: FnMut(PinState) -> Option<PinState>,
Updates the state of this atomic pin state based on a stored value.
toggle takes an Ordering argument which describes the memory
ordering of this operation. For more information see AtomicUsize::store.