Synopsis
CTL_STATUS_t ctl_i2c_write_read(CTL_I2C_BUS_t *self,
                                unsigned address,
                                const void *tx,
                                size_t txlen,
                                void *rx,
                                size_t rxlen);
Description

ctl_i2c_write_read locks the I2C bus self using ctl_i2c_lock_bus and proceeds to write the object pointed to by tx with size txlen bytes to device with 8-bit slave address address.

ctl_i2c_write_read then issues a repeated start to the same slave address and reads len bytes from the slave and writes them to the object pointed to by rx which must be at least rxlen bytes in size.

ctl_i2c_write_read waits unconditionally for the write and read to complete, unlocks the bus using ctl_i2c_unlock_bus, and returns a standard status code.

For exact I2C transaction details, see CTL_I2C_REQUEST_t.

Thread Safety

This function is thread-safe if a mutex is associated with the I2C bus self.

See Also

CTL_I2C_REQUEST_t.