Trait embedded_hal_async::spi::SpiBus
source · [−]pub trait SpiBus<Word: 'static + Copy = u8>: SpiBusRead<Word> + SpiBusWrite<Word> {
type TransferFuture<'a>: Future<Output = Result<(), Self::Error>>
where
Self: 'a;
type TransferInPlaceFuture<'a>: Future<Output = Result<(), Self::Error>>
where
Self: 'a;
fn transfer<'a>(
&'a mut self,
read: &'a mut [Word],
write: &'a [Word]
) -> Self::TransferFuture<'a>;
fn transfer_in_place<'a>(
&'a mut self,
words: &'a mut [Word]
) -> Self::TransferInPlaceFuture<'a>;
}
Expand description
Read-write SPI bus
SpiBus
represents exclusive ownership over the whole SPI bus, with SCK, MOSI and MISO pins.
See (the docs on embedded-hal)embedded_hal::spi::blocking for important information on SPI Bus vs Device traits.
Required Associated Types
Future returned by the transfer
method.
Required Methods
fn transfer<'a>(
&'a mut self,
read: &'a mut [Word],
write: &'a [Word]
) -> Self::TransferFuture<'a>
fn transfer<'a>(
&'a mut self,
read: &'a mut [Word],
write: &'a [Word]
) -> Self::TransferFuture<'a>
Write and read simultaneously. write
is written to the slave on MOSI and
words received on MISO are stored in read
.
It is allowed for read
and write
to have different lengths, even zero length.
The transfer runs for max(read.len(), write.len())
words. If read
is shorter,
incoming words after read
has been filled will be discarded. If write
is shorter,
the value of words sent in MOSI after all write
has been sent is implementation-defined,
typically 0x00
, 0xFF
, or configurable.
Implementations are allowed to return before the operation is complete. See (the docs on embedded-hal)embedded_hal::spi::blocking for details on flushing.
fn transfer_in_place<'a>(
&'a mut self,
words: &'a mut [Word]
) -> Self::TransferInPlaceFuture<'a>
fn transfer_in_place<'a>(
&'a mut self,
words: &'a mut [Word]
) -> Self::TransferInPlaceFuture<'a>
Write and read simultaneously. The contents of words
are
written to the slave, and the received words are stored into the same
words
buffer, overwriting it.
Implementations are allowed to return before the operation is complete. See (the docs on embedded-hal)embedded_hal::spi::blocking for details on flushing.