Hello E2E Experts,
Good day.
I'm currently trying to port an arduino library that uses the Wire.h library for I2C communication. I'm currently using TI's i2c.h solution and have found the documentation here https://software-dl.ti.com/simplelink/esd/simplelink_cc13x0_sdk/2.40.00.20/exports/docs/tidrivers/doxygen/html/_i2_c_8h.html very helpful, but I have a question about reading and writing *to a specific register*. As an example, the library I'm porting might have a line like
write(0x01 /* the slave's register to write to */, &variable_to_write, sizeof(variable_to_write), 0xAB /* the address of the slave */ )
The Wire.h primitives are here https://github.com/garmin/LIDARLite_Arduino_Library/blob/master/src/LIDARLite_v3HP.cpp .
My main question is if I'm responsible for just writing the reg address (0x01), and then writing the data. To confirm my understanding, that would mean that the i2c.h example
I2C_Transaction i2cTransaction; uint8_t writeBuffer[3]; writeBuffer[0] = 0xAB; writeBuffer[1] = 0xCD; writeBuffer[2] = 0xEF; i2cTransaction.slaveAddress = 0x50; i2cTransaction.writeBuf = writeBuffer; i2cTransaction.writeCount = 3; i2cTransaction.readBuf = NULL; i2cTransaction.readCount = 0; status = I2C_transfer(i2cHandle, &i2cTransaction); if (status == false) { // Unsuccessful I2C transfer }
has the effect of writing 0xCDEF to register 0xAB of the slave device at 0x50, correct?
Thank you in advance.
Regards,
CSC