recv function

Updated: October 26, 2022

The recv function initiates a master receive. An optional event is sent when the transaction is complete (and the data buffer can be used). If this function fails, no transaction has been initiated.

The prototype for this function is:

i2c_status_t recv(
               void *hdl,
               void *buf,
               unsigned int len,
               unsigned int stop );

The arguments are:

hdl
The handle returned by the init function.
buf
A pointer to the buffer in which to put the received data.
len
The length, in bytes, of the buffer.
stop
If this is nonzero, the function sets the stop condition when the receive completes.

The function returns one of the following:

I2C_STATUS_DONE
The transaction completed (with or without an error).
I2C_STATUS_ERROR
An unknown error occurred.
I2C_STATUS_NACK
Slave no-acknowledgement.
I2C_STATUS_ARBL
Lost arbitration.
I2C_STATUS_BUSY
The transaction timed out.
I2C_STATUS_ABORT
The transaction was aborted.