spi_bus
SPI bus abstraction.
Wraps a [PhysicalTransfer] impl and exposes the [Bus] trait as a list
of [Op]s run in order. MAX_TRANSFER is the controller’s data buffer; a
write-only or read-only op longer than that is clocked in buffer-sized
pieces, and an exchange is handed to the physical driver whole (it chunks
through the FIFO or uses DMA). No length is ever silently cut short.
Ownership
Section titled “Ownership”The physical driver is held by value (SpiBus<P>), not behind a
&'static dyn — so one Once<SpiBus<Esp32Spi>> holds the whole stack
rather than a driver static plus a bus static that borrows it. A caller
that already has a &'static driver can still pass it: &T is itself a
[PhysicalTransfer] (the blanket impl in hal::bus), so SpiBus<&Esp32Spi>
works unchanged.
Locking (#116)
Section titled “Locking (#116)”[Bus::transfer] holds an [api::mutex] lock for the whole op list, so
a multi-op transaction cannot be split by another task once a board hands
the same &'static SpiBus to more than one of them. The lock is the
kernel’s priority-inheritance mutex, a syscall that the kernel refuses
from interrupt context — so transfer must not be called from an ISR. An
interrupt that has to touch the peripheral should own the physical driver
directly (exchange is &self) and coordinate with the task side through a
CsCell, not through this wrapper.
Structs
Section titled “Structs”SpiBus
Section titled “SpiBus”struct SpiBus<P> { /* private fields */ }SPI bus abstraction owning its physical driver P.
Implements: Bus