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 () |
|
inline |
Cancel the outstanding WriteReadAsync
call. The completion handler will be called with a Status
of CANCELLED
after this is called.
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.
|
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.