C/C++ API Reference
Loading...
Searching...
No Matches
pw::spi::Initiator Class Referenceabstract

Overview

Abstract interface for configuring a SPI bus, and initiating data transfers using it.

A concrete implementation of this interface class must be defined in order to use pw_spi with a specific target.

Initiator configures the SPI bus to communicate with a defined set of common bus parameters that include:

  • clock polarity/phase
  • bits-per-word (between 3-32 bits)
  • bit ordering (LSB or MSB first)

These bus configuration parameters are aggregated in the pw::spi::Config structure, and passed to the pw::spi::Initiator via its Configure method.

Note
The terms "initiator" and "responder" are used to describe the two roles SPI devices can implement. These terms correspond to the "master" and "slave" roles described in legacy documentation related to the SPI protocol.
Inheritance diagram for pw::spi::Initiator:
pw::spi::MockInitiator

Public Member Functions

Status Configure (const Config &config)
 
Status WriteRead (ConstByteSpan write_buffer, ByteSpan read_buffer)
 

Member Function Documentation

◆ Configure()

Status pw::spi::Initiator::Configure ( const Config config)
inline

Configures the SPI bus to communicate with responders using a given set of properties, including the clock polarity, clock phase, bit-order, and bits-per-word.

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

◆ DoWriteRead()

virtual Status pw::spi::Initiator::DoWriteRead ( ConstByteSpan  write_buffer,
ByteSpan  read_buffer 
)
privatepure virtual

Implemented in pw::spi::MockInitiator.

◆ WriteRead()

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

Performs a synchronous read/write operation 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: