C/C++ API Reference
Loading...
Searching...
No Matches
pw::spi::Device::Transaction Class Referencefinal

Overview

RAII object providing exclusive access to the SPI device. Enables thread-safe Read, Write, and WriteRead operations, as well as composite operations consisting of multiple, uninterrupted transfers, with configurable chip select behavior.

Public Member Functions

 Transaction (Transaction &&other)
 Transaction objects are moveable but not copyable.
 
Transactionoperator= (Transaction &&other)
 
 Transaction (const Transaction &)=delete
 
Transactionoperator= (const Transaction &)=delete
 
Status Read (ByteSpan read_buffer)
 
Status Write (ConstByteSpan write_buffer)
 
Status WriteRead (ConstByteSpan write_buffer, ByteSpan read_buffer)
 

Member Function Documentation

◆ Read()

Status pw::spi::Device::Transaction::Read ( ByteSpan  read_buffer)
inline

Synchronously reads data from the SPI responder until the provided read_buffer is full.

Returns
OkStatus() on success, and implementation-specific values on failure.

◆ Write()

Status pw::spi::Device::Transaction::Write ( ConstByteSpan  write_buffer)
inline

Synchronously writes the contents of write_buffer to the SPI responder.

Returns
OkStatus() on success, and implementation-specific values on failure.

◆ WriteRead()

Status pw::spi::Device::Transaction::WriteRead ( ConstByteSpan  write_buffer,
ByteSpan  read_buffer 
)
inline

Performs a synchronous read/write transfer on the SPI bus. Data from the write_buffer object is written to the bus, while the read_buffer is populated with incoming data on the bus. The operation will ensure that all requested data is written to and read from the bus. In the event the read buffer is smaller than the write buffer (or zero-size), any additional input bytes are discarded. In the event the write buffer is smaller than the read buffer (or zero-size), the output is padded with 0-bits for the remainder of the transfer.

Returns
OkStatus() on success, and implementation-specific values on failure.

The documentation for this class was generated from the following file: