Other Parts Discussed in Thread: LAUNCHXL-CC26X2R1
Tool/software: TI-RTOS
Hi I was using I2C with TIRTOS on my launchpad and everything was fine. I could read and write with it. For that I had the default I2C maping which is IOID_4 for clock and IOID_5 for data.
However, for my board, I mapped IOID_0 as data and IOID_3 as clock. Everything else is the same in the code but with this configuration, I can only open the I2C once and if I close it next time I open it when I use I2C_transfer() it returns false indicating an error.
If I swap IOID_0 and IOID_3 it -> IOID_0 as clock and IOID_3 as data I get no error, everything works fine.
Any thoughts on how to fix this?
Here is the code. I call Init once and every time I want to write or read something I call i2c_comm
void i2c_init(void) { /* Call driver init function */ I2C_init(); /* Create I2C for usage */ I2C_Params_init(&i2cParams); }
// Param: 1 - Buffer to be sent, 2 - Buffer to store data collected, 3 - number of bytes to be sent 4 - number of bytes to be received, 5 - i2c slave address.
bool i2c_comm(uint8_t *tx_buffer, uint8_t *rx_buffer, size_t tx_count, size_t rx_count, uint8_t i2c_address) { i2c = I2C_open(Board_I2C, &i2cParams); if (i2c == NULL) { status = I2C_ERROR; } i2cParams.bitRate = I2C_400kHz; i2cTransaction.slaveAddress = i2c_address; i2cTransaction.writeBuf = tx_buffer; i2cTransaction.writeCount = tx_count; i2cTransaction.readBuf = rx_buffer; i2cTransaction.readCount = rx_count; if (I2C_transfer(i2c, &i2cTransaction)) { status = I2C_OK; } else { status = I2C_ERROR; } I2C_close(i2c); return status; }