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

Overview

Provides an abstract interface used to receive and transmit data on the responder side of a SPI bus. It is the common interface for implementing a SPI responder. It provides a way to respond to SPI transactions coming from a SPI initiator in a non-target specific way. A concrete implementation of the Responder class should be provided for the target hardware. Applications can then use it to implement their specific protocols.

Public Member Functions

void SetCompletionHandler (Function< void(ByteSpan, Status)> callback)
 
Status WriteReadAsync (ConstByteSpan tx_data, ByteSpan rx_data)
 
void Cancel ()
 

Member Function Documentation

◆ Cancel()

void pw::spi::Responder::Cancel ( )
inline

Cancel the outstanding WriteReadAsync call. The completion handler will be called with a Status of CANCELLED after this is called.

◆ SetCompletionHandler()

void pw::spi::Responder::SetCompletionHandler ( Function< void(ByteSpan, Status)>  callback)
inline

Sets callback to be called when SPI transaction completes. callback can be called in an interrupt context. callback should not be changed during execution of a completion.

A value of CANCELLED for the Status parameter indicates Cancel() was called. Partially transferred data may be passed in that case as well. Other Status values are implementer-defined.

◆ WriteReadAsync()

Status pw::spi::Responder::WriteReadAsync ( ConstByteSpan  tx_data,
ByteSpan  rx_data 
)
inline

tx_data is queued for TX when called, but only transmitted when the initiator starts the next transaction. It's up to the implementer to define how stuffing bytes are handled. rx_data is populated as the initiator transfers data. A slice of rx_data is passed as a span to the completion callback.

Only one outstanding request should be active. UNAVAILABLE will be returned if a transaction is already established.

The completion handler will always be invoked, even in the case of an Cancel(). In that case a Status value of CANCELLED will be passed.


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