pub unsafe extern "C" fn otPlatSpiSlavePrepareTransaction(
aOutputBuf: *mut u8,
aOutputBufLen: u16,
aInputBuf: *mut u8,
aInputBufLen: u16,
aRequestTransactionFlag: bool,
) -> otError
Expand description
Prepare data for the next SPI transaction. Data pointers MUST remain valid until the transaction complete callback
is called by the SPI slave driver, or until after the next call to otPlatSpiSlavePrepareTransaction()
.
May be called more than once before the SPI master initiates the transaction. Each successful call to this function will cause the previous values from earlier calls to be discarded.
Not calling this function after a completed transaction is the same as if this function was previously called with
both buffer lengths set to zero and aRequestTransactionFlag
set to false
.
Once aOutputBufLen
bytes of aOutputBuf
has been clocked out, the MISO pin shall be set high until the master
finishes the SPI transaction. This is the functional equivalent of padding the end of aOutputBuf
with 0xFF
bytes
out to the length of the transaction.
Once aInputBufLen
bytes of aInputBuf have been clocked in from MOSI, all subsequent values from the MOSI pin are
ignored until the SPI master finishes the transaction.
Note that even if aInputBufLen
or aOutputBufLen
(or both) are exhausted before the SPI master finishes a
transaction, the ongoing size of the transaction must still be kept track of to be passed to the transaction
complete callback. For example, if aInputBufLen
is equal to 10 and aOutputBufLen
equal to 20 and the SPI master
clocks out 30 bytes, the value 30 is passed to the transaction complete callback.
If a NULL
pointer is passed in as aOutputBuf
or aInputBuf
it means that that buffer pointer should not change
from its previous/current value. In this case, the corresponding length argument should be ignored. For example,
otPlatSpiSlavePrepareTransaction(NULL, 0, aInputBuf, aInputLen, false)
changes the input buffer pointer and its
length but keeps the output buffer pointer same as before.
Any call to this function while a transaction is in progress will cause all of the arguments to be ignored and the
return value to be OT_ERROR_BUSY
.
@param[in] aOutputBuf Data to be written to MISO pin @param[in] aOutputBufLen Size of the output buffer, in bytes @param[in] aInputBuf Data to be read from MOSI pin @param[in] aInputBufLen Size of the input buffer, in bytes @param[in] aRequestTransactionFlag Set to true if host interrupt should be set
@retval OT_ERROR_NONE Transaction was successfully prepared. @retval OT_ERROR_BUSY A transaction is currently in progress. @retval OT_ERROR_INVALID_STATE otPlatSpiSlaveEnable() hasn’t been called.