The DCMD_I2C_SENDRECV command executes a send followed by a receive. This sequence is typically used to read a slave device's register value. When multiple applications access the same slave device, it is necessary to execute this sequence atomically to prevent register reads from being interrupted. Although this functionality is also provided by DCMD_I2C_LOCK and DCMD_I2C_UNLOCK, the implementation of this functionality is much simpler.
The i2c_sendrecv_t structure is defined as:
typedef struct { i2c_addr_t slave; /* slave address */ uint32_t send_len; /* length of send data in bytes */ uint32_t recv_len; /* length of receive data in bytes */ uint32_t stop; /* set stop when complete? */ } i2c_sendrecv_t;
If an error occurs, the command returns: