Module embedded_hal_mock::spi [−][src]
SPI mock implementations.
This mock 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.
Usage
extern crate embedded_hal; extern crate embedded_hal_mock; use embedded_hal::blocking::spi::{Transfer, Write}; use embedded_hal_mock::spi::{Mock as SpiMock, Transaction as SpiTransaction}; let mut spi = SpiMock::new(); // Configure expectations spi.expect(vec![ SpiTransaction::write(vec![1u8, 2u8]), SpiTransaction::transfer(vec![3u8, 4u8], vec![5u8, 6u8]), ]); // Writing spi.write(&vec![1u8, 2u8]).unwrap(); // Transferring let mut buf = vec![3u8, 4u8]; spi.transfer(&mut buf).unwrap(); assert_eq!(buf, vec![5u8, 6u8]); // Finalise expectations spi.done();
Structs
Mock |
Mock SPI implementation |
Transaction |
SPI transaction type |
Enums
Mode |
SPI Transaction mode |