Skip to main content

Module spi

Module spi 

Source
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):

Structs§

SPI_GET_CONFIGURATION
SPI_SET_CONFIGURATION
SPI_TRANSACTION
SPI_TRANSFER
SpiConfigurationAbi
Device settings. Mode is 0..=3, bit order is 0 (MSB first) or 1 (LSB first).
SpiSegmentAbi
One segment of SPI_TRANSACTION. kind is one of the SPI_SEGMENT_* values and cs_change is 0 or 1.
SpiTransactionInputAbi
Input of SPI_TRANSACTION. Only the first segment_count segments are read. reserved must be zero.
SpiTransactionOutputAbi
Output of SPI_TRANSACTION. length is the total data length. Bytes of write-only segments are zero.
SpiTransferInputAbi
Input of SPI_TRANSFER: length bytes of tx are sent while the same number of bytes is received into SpiTransferOutputAbi::rx.
SpiTransferOutputAbi
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::kind value for a read segment (zeros on MOSI).
SPI_SEGMENT_TRANSFER
SpiSegmentAbi::kind value for a full-duplex segment.
SPI_SEGMENT_WRITE
SpiSegmentAbi::kind value for a write-only segment.