Skip to content
Browse files

drivers/i2c/i2c_imx: Check for I2C bus busy before starting transaction

In some cases the minimum time between Stop and Start was not being
considered when starting a new transfer.
This patches adds a checking on the I2C Bus Busy flag before starting
a new transaction.

Signed-off-by: Diego Sueiro <>
  • Loading branch information...
diegosueiro authored and MaureenHelm committed Aug 4, 2018
1 parent a25c273 commit 4eee8a67f182e346f75035a35b42425dbe7b193a
Showing with 9 additions and 0 deletions.
  1. +9 −0 drivers/i2c/i2c_imx.c
@@ -179,12 +179,21 @@ static int i2c_imx_transfer(struct device *dev, struct i2c_msg *msgs,
struct i2c_imx_data *data = DEV_DATA(dev);
struct i2c_master_transfer *transfer = &data->transfer;
u8_t *buf, *buf_end;
u16_t timeout = UINT16_MAX;
int result = -EIO;

if (!num_msgs) {
return 0;

/* Wait until bus not busy */
while ((I2C_I2SR_REG(base) & i2cStatusBusBusy) && (--timeout)) {

if (timeout == 0) {
return result;

/* Make sure we're in a good state so slave recognises the Start */
I2C_SetWorkMode(base, i2cModeSlave);
transfer->currentMode = i2cModeSlave;

0 comments on commit 4eee8a6

Please sign in to comment.
You can’t perform that action at this time.