[−][src]Struct embedded_hal_spy::Spy
embedded hal spy implemnets call backs for used traits
Intended use is chaining over an existing embedded_hal implementation sniffing all the data. Useful when preparing for a refacforing and want to collect actual data for unit test case.
Blocking SPI API hal::blocking::spi::Transfer will return DataWord::First at start of transfer, all data sent in DataWord::Byte(u8) DataWord::Response to indicate where transmit ends and response begins all recived bytes in DataWord::Byte(u8) ending with DataWord::Last
Usage:
extern crate embedded_hal_spy; use embedded_hal_spy::DataWord; let mut spix = embedded_hal_spy::new(spi, |w|{ match w { DataWord::First => { print!("data = ["); }, DataWord::Last => {println!("],"); }, DataWord::Response => { print!("],\r\n ["); }, DataWord::Byte(num) => { print!("{:x},",num); }, _other => {}, } } );
Trait Implementations
impl<T, F> Transfer<u8> for Spy<T, F> where
T: Transfer<u8>,
F: Fn(DataWord),
[src]
T: Transfer<u8>,
F: Fn(DataWord),
type Error = T::Error
Error type
fn transfer<'w>(&mut self, words: &'w mut [u8]) -> Result<&'w [u8], Self::Error>
[src]
Sends Word
to the slave. Returns the Word
received from the slave
impl<T, F> Write<u8> for Spy<T, F> where
T: Write<u8>,
F: Fn(DataWord),
[src]
T: Write<u8>,
F: Fn(DataWord),
Blocking write
type Error = T::Error
Error type
fn write(&mut self, words: &[u8]) -> Result<(), Self::Error>
[src]
Sends words
to the slave, ignoring all the incoming words
impl<T, F> OutputPin for Spy<T, F> where
T: OutputPin,
F: Fn(DataWord),
[src]
T: OutputPin,
F: Fn(DataWord),
Digital OutputPin
type Error = T::Error
Error type
fn set_high(&mut self) -> Result<(), T::Error>
[src]
fn set_low(&mut self) -> Result<(), T::Error>
[src]
impl<T, F> StatefulOutputPin for Spy<T, F> where
T: StatefulOutputPin,
F: Fn(DataWord),
[src]
T: StatefulOutputPin,
F: Fn(DataWord),
fn is_set_high(&self) -> Result<bool, T::Error>
[src]
fn is_set_low(&self) -> Result<bool, T::Error>
[src]
impl<T, F> ToggleableOutputPin for Spy<T, F> where
T: ToggleableOutputPin,
F: Fn(DataWord),
[src]
T: ToggleableOutputPin,
F: Fn(DataWord),
impl<T, F> InputPin for Spy<T, F> where
T: InputPin,
F: Fn(DataWord),
[src]
T: InputPin,
F: Fn(DataWord),
Digital InputPin
type Error = T::Error
Error type
fn is_high(&self) -> Result<bool, Self::Error>
[src]
fn is_low(&self) -> Result<bool, Self::Error>
[src]
impl<T, F> FullDuplex<u8> for Spy<T, F> where
T: FullDuplex<u8>,
F: Fn(DataWord),
[src]
T: FullDuplex<u8>,
F: Fn(DataWord),
FullDuplex will return every data sent and read in DataWord::Byte(u8)
Auto Trait Implementations
impl<T, F> Unpin for Spy<T, F> where
F: Unpin,
T: Unpin,
F: Unpin,
T: Unpin,
impl<T, F> Send for Spy<T, F> where
F: Send,
T: Send,
F: Send,
T: Send,
impl<T, F> !Sync for Spy<T, F>
Blanket Implementations
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.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> From<T> for T
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<W, S> Transfer<W> for S where
S: Default<W>,
W: Clone,
[src]
S: Default<W>,
W: Clone,
type Error = <S as FullDuplex<W>>::Error
Error type
fn transfer(
&mut self,
words: &'w mut [W]
) -> Result<&'w [W], <S as FullDuplex<W>>::Error>
[src]
&mut self,
words: &'w mut [W]
) -> Result<&'w [W], <S as FullDuplex<W>>::Error>
impl<W, S> Write<W> for S where
S: Default<W>,
W: Clone,
[src]
S: Default<W>,
W: Clone,
type Error = <S as FullDuplex<W>>::Error
Error type
fn write(&mut self, words: &[W]) -> Result<(), <S as FullDuplex<W>>::Error>
[src]
impl<T> OutputPin for T where
T: OutputPin,
[src]
T: OutputPin,
type Error = ()
Error type
fn set_low(&mut self) -> Result<(), <T as OutputPin>::Error>
[src]
fn set_high(&mut self) -> Result<(), <T as OutputPin>::Error>
[src]
impl<T> StatefulOutputPin for T where
T: StatefulOutputPin + OutputPin,
[src]
T: StatefulOutputPin + OutputPin,
fn is_set_low(&self) -> Result<bool, <T as OutputPin>::Error>
[src]
fn is_set_high(&self) -> Result<bool, <T as OutputPin>::Error>
[src]
impl<P> ToggleableOutputPin for P where
P: Default,
[src]
P: Default,
type Error = <P as OutputPin>::Error
Error type
fn toggle(&mut self) -> Result<(), <P as ToggleableOutputPin>::Error>
[src]
Toggle pin output
impl<T> InputPin for T where
T: InputPin,
[src]
T: InputPin,