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.slaveAddress = I2C_MASTER_SLAVE_ADDR_7BIT;
masterXfer.direction = kI2C_Write;
masterXfer.subaddress = 0;
masterXfer.subaddressSize = 0;
masterXfer.data = g_master_buff;
masterXfer.dataSize = I2C_DATA_LENGTH;
masterXfer.flags = kI2C_TransferDefaultFlag;
reVal = I2C_MasterTransferBlocking(EXAMPLE_I2C_MASTER, &masterXfer);
I just want to read from a device register but I don't know how to define my master buffer, eg g_master_buff[0] = 0x00;.
Can I just run the function,
I2C_MasterReadBlocking(EXAMPLE_I2C_MASTER_BASE, g_test_receive, I2C_DATA_LENGTH, 0);
Or do you just need to use a I2C_MasterWriteBlocking() function and the slave callback function will automatically send back the register values?
Thank you.