diff options
-rw-r--r-- | chip/stm32/i2c-stm32f0.c | 9 | ||||
-rw-r--r-- | chip/stm32/i2c-stm32l.c | 8 |
2 files changed, 9 insertions, 8 deletions
diff --git a/chip/stm32/i2c-stm32f0.c b/chip/stm32/i2c-stm32f0.c index 47393fc209..01e3269263 100644 --- a/chip/stm32/i2c-stm32f0.c +++ b/chip/stm32/i2c-stm32f0.c @@ -50,14 +50,15 @@ static int wait_isr(int port, int mask) while (get_time().val < timeout) { int isr = STM32_I2C_ISR(port); + /* Check for errors */ + if (isr & (STM32_I2C_ISR_ARLO | STM32_I2C_ISR_BERR | + STM32_I2C_ISR_NACK)) + return EC_ERROR_UNKNOWN; + /* Check for desired mask */ if ((isr & mask) == mask) return EC_SUCCESS; - /* Check for errors */ - if (isr & (STM32_I2C_ISR_ARLO | STM32_I2C_ISR_BERR)) - return EC_ERROR_UNKNOWN; - /* I2C is slow, so let other things run while we wait */ usleep(100); } diff --git a/chip/stm32/i2c-stm32l.c b/chip/stm32/i2c-stm32l.c index e274207cb8..8b37eb3ef9 100644 --- a/chip/stm32/i2c-stm32l.c +++ b/chip/stm32/i2c-stm32l.c @@ -73,10 +73,6 @@ static int wait_sr1(int port, int mask) while (get_time().val < timeout) { int sr1 = STM32_I2C_SR1(port); - /* Check for desired mask */ - if ((sr1 & mask) == mask) - return EC_SUCCESS; - /* Check for errors */ if (sr1 & (STM32_I2C_SR1_ARLO | STM32_I2C_SR1_BERR | STM32_I2C_SR1_AF)) { @@ -84,6 +80,10 @@ static int wait_sr1(int port, int mask) return EC_ERROR_UNKNOWN; } + /* Check for desired mask */ + if ((sr1 & mask) == mask) + return EC_SUCCESS; + /* I2C is slow, so let other things run while we wait */ usleep(100); } |