Expand description
SPI device node control contract (/devices/spi/spi<bus>.<cs>).
Configuration and multi-segment transfers use the control commands below,
all with kind byte b's'. Every input and output struct is #[repr(C)],
starts with a version field that must equal SPI_ABI_VERSION, and is
validated before use.
Bounds (the transaction path never allocates):
SPI_TRANSFERmoves at mostSPI_MAX_TRANSFER_BYTESbytes full duplex.SPI_TRANSACTIONruns at mostSPI_MAX_SEGMENTSsegments whose lengths sum to at mostSPI_MAX_TRANSACTION_BYTES. Segment data is laid out back to back in both the input and outputdataarrays, so segmentnstarts at the sum of the lengths of segments0..n.
Structs§
- SPI_
GET_ CONFIGURATION - SPI_
SET_ CONFIGURATION - SPI_
TRANSACTION - SPI_
TRANSFER - SpiConfiguration
Abi - Device settings. Mode is 0..=3, bit order is 0 (MSB first) or 1 (LSB first).
- SpiSegment
Abi - One segment of
SPI_TRANSACTION.kindis one of theSPI_SEGMENT_*values andcs_changeis 0 or 1. - SpiTransaction
Input Abi - Input of
SPI_TRANSACTION. Only the firstsegment_countsegments are read.reservedmust be zero. - SpiTransaction
Output Abi - Output of
SPI_TRANSACTION.lengthis the total data length. Bytes of write-only segments are zero. - SpiTransfer
Input Abi - Input of
SPI_TRANSFER:lengthbytes oftxare sent while the same number of bytes is received intoSpiTransferOutputAbi::rx. - SpiTransfer
Output Abi - Output of
SPI_TRANSFER.
Constants§
- SPI_
ABI_ VERSION - ABI version carried by every command input and output struct.
- SPI_
MAX_ SEGMENTS - Maximum segments in one
SPI_TRANSACTION. - SPI_
MAX_ TRANSACTION_ BYTES - Maximum sum of segment lengths in one
SPI_TRANSACTION. - SPI_
MAX_ TRANSFER_ BYTES - Maximum bytes moved by one
SPI_TRANSFER. - SPI_
SEGMENT_ READ SpiSegmentAbi::kindvalue for a read segment (zeros on MOSI).- SPI_
SEGMENT_ TRANSFER SpiSegmentAbi::kindvalue for a full-duplex segment.- SPI_
SEGMENT_ WRITE SpiSegmentAbi::kindvalue for a write-only segment.