pub trait SpiDeviceRead<Word: Copy + 'static = u8>: ErrorType {
    // Required method
    fn read_transaction(
        &mut self,
        operations: &mut [&mut [Word]]
    ) -> Result<(), Self::Error>;

    // Provided method
    fn read(&mut self, buf: &mut [Word]) -> Result<(), Self::Error> { ... }
}
Expand description

SPI read-only device trait

SpiDeviceRead represents ownership over a single SPI device on a (possibly shared) bus, selected with a CS (Chip Select) pin.

See the module-level documentation for important usage information.

Required Methods§

source

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

Perform a read transaction against the device.

  • Locks the bus
  • Asserts the CS (Chip Select) pin.
  • Performs all the operations.
  • Flushes the bus.
  • Deasserts the CS pin.
  • Unlocks the bus.

The locking mechanism is implementation-defined. The only requirement is it must prevent two transactions from executing concurrently against the same bus. Examples of implementations are: critical sections, blocking mutexes, returning an error or panicking if the bus is already busy.

On bus errors the implementation should try to deassert CS. If an error occurs while deasserting CS the bus error should take priority as the return value.

Provided Methods§

source

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

Do a read within a transaction.

This is a convenience method equivalent to device.read_transaction(&mut [buf]).

See also: SpiDeviceRead::read_transaction, SpiBusRead::read

Implementations on Foreign Types§

source§

impl<Word: Copy + 'static, T: SpiDeviceRead<Word>> SpiDeviceRead<Word> for &mut T

source§

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

source§

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

Implementors§