I m a little confused with this driver. I have previously used I2C to read and write to registers but I m stuck trying to do this with fsl_i2c.c. I have run the sample code from the dev kit, SDK_2.2.1_LPCXpresso54114. This included the code i2c_polling_transfer and i2c_interrupt_transfer. This worked successfully and I was able to send and receive the example byte array through I2C. However I m trying to use these functions with a peripheral to write to a specific register. I m a bit mixed up as to whats defined as a register address and a register value.
For example, if I want to read from the register value of a device at an address such as 0x20. Would I do the following,
#define I2C_MASTER_SLAVE_ADDR_7BIT 0x20
#define I2C_DATA_LENGTH 1U
#define EXAMPLE_I2C_MASTER_BASE (I2C6_BASE)
#define EXAMPLE_I2C_SLAVE_BASE (I2C6_BASE)
#define EXAMPLE_I2C_MASTER ((I2C_Type *)EXAMPLE_I2C_MASTER_BASE)
#define EXAMPLE_I2C_SLAVE ((I2C_Type *)EXAMPLE_I2C_SLAVE_BASE)
g_master_buff[0] = 0x00;
masterXfer.direction = kI2C_Write;
masterXfer.subaddress = 0;
masterXfer.subaddressSize = 0;
masterXfer.data = g_master_buff;
masterXfer.dataSize = I2C_DATA_LENGTH;
masterXfer.flags = kI2C_TransferDefaultFlag;
Hi Ronan O'Driscoll ,
I‘d highly recommend you to use the I2C_MasterTransferBlocking() to write or read the external I2C device, such as EEPROM memory device.
Hope it helps.