Type Alias embedded_hal_mock::eh1::spi::Mock

source ·
pub type Mock<W> = Generic<Transaction<W>>;
Available on crate feature eh1 only.
Expand description

Mock SPI implementation

This supports the specification and checking of expectations to allow automated testing of SPI based drivers. Mismatches between expected and real SPI transactions will cause runtime assertions to assist with locating faults.

See the usage section in the module level docs for an example.

Aliased Type§

struct Mock<W> { /* private fields */ }

Trait Implementations§

source§

impl<W> ErrorType for Mock<W>
where W: Copy + Debug + PartialEq,

§

type Error = ErrorKind

Error type.
source§

impl<W> FullDuplex<W> for Mock<W>
where W: Copy + Debug + PartialEq,

source§

fn write(&mut self, buffer: W) -> Result<(), Self::Error>

spi::FullDuplex implementation for Mock

This will call the nonblocking read/write primitives.

source§

fn read(&mut self) -> Result<W, Self::Error>

spi::FullDuplex implementation for Mock

This will call the nonblocking read/write primitives.

source§

impl<W> SpiBus<W> for Mock<W>
where W: Copy + 'static + Debug + PartialEq,

source§

fn read(&mut self, buffer: &mut [W]) -> Result<(), Self::Error>

spi::Read implementation for Mock

This will cause an assertion if the read call does not match the next expectation

source§

fn write(&mut self, buffer: &[W]) -> Result<(), Self::Error>

spi::Write implementation for Mock

This will cause an assertion if the write call does not match the next expectation

source§

fn transfer_in_place(&mut self, buffer: &mut [W]) -> Result<(), Self::Error>

spi::TransferInplace implementation for Mock

This writes the provided response to the buffer and will cause an assertion if the written data does not match the next expectation

source§

fn transfer(&mut self, read: &mut [W], write: &[W]) -> Result<(), Self::Error>

Write and read simultaneously. write is written to the slave on MOSI and words received on MISO are stored in read. Read more
source§

fn flush(&mut self) -> Result<(), Self::Error>

Wait until all operations have completed and the bus is idle. Read more
source§

impl<W> SpiBus<W> for Mock<W>
where W: Copy + 'static + Debug + PartialEq,

Available on crate feature embedded-hal-async only.
source§

async fn transfer_in_place( &mut self, words: &mut [W] ) -> Result<(), Self::Error>

spi::TransferInplace implementation for Mock

This writes the provided response to the buffer and will cause an assertion if the written data does not match the next expectation

source§

async fn read(&mut self, words: &mut [W]) -> Result<(), Self::Error>

Read words from the slave. Read more
source§

async fn write(&mut self, words: &[W]) -> Result<(), Self::Error>

Write words to the slave, ignoring all the incoming words. Read more
source§

async fn transfer( &mut self, read: &mut [W], write: &[W] ) -> Result<(), Self::Error>

Write and read simultaneously. write is written to the slave on MOSI and words received on MISO are stored in read. Read more
source§

async fn flush(&mut self) -> Result<(), Self::Error>

Wait until all operations have completed and the bus is idle. Read more
source§

impl<W> SpiDevice<W> for Mock<W>
where W: Copy + 'static + Debug + PartialEq,

source§

fn transaction( &mut self, operations: &mut [Operation<'_, W>] ) -> Result<(), Self::Error>

spi::SpiDevice implementation for Mock

This writes the provided response to the buffer and will cause an assertion if the written data does not match the next expectation

source§

fn read(&mut self, buf: &mut [Word]) -> Result<(), Self::Error>

Do a read within a transaction. Read more
source§

fn write(&mut self, buf: &[Word]) -> Result<(), Self::Error>

Do a write within a transaction. Read more
source§

fn transfer( &mut self, read: &mut [Word], write: &[Word] ) -> Result<(), Self::Error>

Do a transfer within a transaction. Read more
source§

fn transfer_in_place(&mut self, buf: &mut [Word]) -> Result<(), Self::Error>

Do an in-place transfer within a transaction. Read more
source§

impl<W> SpiDevice<W> for Mock<W>
where W: Copy + 'static + Debug + PartialEq,

Available on crate feature embedded-hal-async only.
source§

async fn transaction( &mut self, operations: &mut [Operation<'_, W>] ) -> Result<(), Self::Error>

Perform a transaction against the device. Read more
source§

async fn read(&mut self, buf: &mut [Word]) -> Result<(), Self::Error>

Do a read within a transaction. Read more
source§

async fn write(&mut self, buf: &[Word]) -> Result<(), Self::Error>

Do a write within a transaction. Read more
source§

async fn transfer( &mut self, read: &mut [Word], write: &[Word] ) -> Result<(), Self::Error>

Do a transfer within a transaction. Read more
source§

async fn transfer_in_place( &mut self, buf: &mut [Word] ) -> Result<(), Self::Error>

Do an in-place transfer within a transaction. Read more