I'm using PSoC 5LP I2C Master device. I have to read and write from a slave device which has sub-addresses. I'm able to write to the device, now I want to read back what I wrote to verify that the writes are done. My example code for write is given below. How would I do something similar for read.
uint8 temp = 0;
i2c_slv_addrs = slave_address >> 1; // I2C slave address, shift right by 1 bit, 7 bits addressing
slave_sub_reg = sub_address; // sub address
slave_sub_reg = data_to_write; // data to write
temp = I2C_MasterWriteBuf(i2c_slv_addrs, (uint8 *)slave_sub_reg, 2 , I2C_MODE_COMPLETE_XFER);
while (temp != I2C_MSTR_NO_ERROR);
// stay here until full xfer is done
while(I2C_MasterStatus() & I2C_MSTAT_XFER_INP);
temp = HDMI_I2C_MasterClearStatus();
// If there is an error while transferring data
if(temp & HDMI_I2C_MSTAT_ERR_XFER)
// Indicate the error
Please refer to I2C master examples in PSoC Creator.