xfer function

Updated: October 26, 2022

The xfer function initiates a transmit, receive, or exchange transaction. The prototype for this function is:

void *xfer( void *hdl,
            uint32_t device,
            uint8_t *buf,
            int *len );

The arguments are:

hdl
The handle of the low-level module that the init function returned.
device
The device ID.
buf
A pointer to the data buffer for this transaction.
len
A pointer to length, in bytes, of the data for this transaction.

The function must return a pointer to the receive/exchange buffer, and store, in the location that len points to, the byte length of the data that has been transmitted, received, or exchanged by the low-level module. The high-level code checks the length to determine whether the transaction was successful.

Note: The buffer is not DMA-safe, so if the low-level module needs to use DMA, it must allocate its own DMA-safe buffer and copy the data over, if necessary.