Commit 99fb7112 authored by schneider's avatar schneider
Browse files

fix(sdk): Prevent endless loop on I2C error

The read operation needs to wait until the stop bit it sends on error is
handled. Otherwise a following write operation will loop.

Closes #226
parent dfcb2590
Pipeline #5178 passed with stages
in 2 minutes and 34 seconds
......@@ -404,6 +404,7 @@ int I2C_MasterRead(mxc_i2c_regs_t *i2c, uint8_t addr, uint8_t* data, int len, in
if (i2c->int_fl0 & I2C_ERROR) {
// Set the stop bit
i2c->master_ctrl |= MXC_F_I2C_MASTER_CTRL_STOP;
while (!(i2c->int_fl0 & (MXC_F_I2C_INT_FL0_STOP))) {}
return E_COMM_ERR;
}
......@@ -416,6 +417,7 @@ int I2C_MasterRead(mxc_i2c_regs_t *i2c, uint8_t addr, uint8_t* data, int len, in
if (i2c->int_fl0 & I2C_ERROR) {
// Set the stop bit
i2c->master_ctrl |= MXC_F_I2C_MASTER_CTRL_STOP;
while (!(i2c->int_fl0 & (MXC_F_I2C_INT_FL0_STOP))) {}
return E_COMM_ERR;
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment