I use i2c in callback mode with no-rtos.
I2C_init(); I2C_Params_init(&i2cParams); #if i2c_mode i2cParams.transferCallbackFxn = i2cCallback; i2cParams.transferMode = I2C_MODE_CALLBACK; #else i2cParams.transferMode = I2C_MODE_BLOCKING; #endif i2cParams.bitRate = I2C_400kHz; i2cAcc = I2C_open(CONFIG_I2C_ACC, &i2cParams); if (i2cAcc == NULL) { while (1); } i2cTransaction.writeBuf = i2cTxBuffer; i2cTransaction.readBuf = i2cRxBuffer;
here is read code
void readAccDataMultiByte() { i2cTxBuffer[0] = OUT_X_L; //i2cTxBuffer[1] = readSlaveAddr; i2cTransaction.writeCount = 1; i2cTransaction.readCount = 6; I2C_transfer(i2cAcc, &i2cTransaction); }
callback code
void i2cCallback(I2C_Handle handle, I2C_Transaction *msg, bool status) { if (status == false) { if (msg->status == I2C_STATUS_ADDR_NACK) { // slave address not acknowledged } else if (msg->status == I2C_STATUS_CANCEL) { // transaction canceled by I2C_cancel() } } else { /*successful*/ flagI2cCallback = 1; } }
but the 6 bytes data i get the same value.
I notice RTOS/LAUNCHXL-CC2640R2: I2C_transfer function is not working in timer callback function - Bluetooth forum - Bluetooth®︎ - TI E2E support forums the usage looks like the same ,but the solution is not relative.