Hello Mike Litster:
I tried to reproduce your issue with a FRDM-K22F by continuously calling I2C_DRV_MasterReceiveDataBlocking() to receive data from the on-board accelerometer, but I did not get any arbitration lost.
However I then forced an arbitration lost in the bus by pulling the SDA line low externally and your description of the resulting situation is correct. I think this is an oversight in the I2C driver in KSDK v1.x.
Please try the next workaround to solve your issue:
1) From the I2C_DRV_MasterIRQHandler() set the i2cIdle flag as true when arbitration lost is detected, like next:
if (wasArbLost)
{
I2C_HAL_ClearArbitrationLost(base);
master->status = kStatus_I2C_AribtrationLost;
/* Disable I2C interrupt in the peripheral.*/
I2C_HAL_SetIntCmd(base, false);
if (master->isBlocking)
{
OSA_SemaPost(&master->irqSync);
}
master->i2cIdle = true;
return;
}
Then rebuild the KSDK platform library.
2) To reset the BUSY bit disable and enable the I2C module from your code like next:
i2c_result = I2C_DRV_MasterReceiveDataBlocking(BOARD_ACCEL_I2C_INSTANCE, &accDev.slave, &accel_cmd, 1, &accelData, 12, 200);
if(i2c_result == kStatus_I2C_AribtrationLost)
{
I2C_HAL_Disable(I2C0);
I2C_HAL_Enable(I2C0);
}
This should reset the BUSY bit to 0.
I hope this helps in your case.
Best Regards!
Jorge Gonzalez
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------