From ef411578d5fbf187e357c64e20116d3c564f3849 Mon Sep 17 00:00:00 2001 From: David Sidrane Date: Tue, 12 Sep 2017 13:42:18 -1000 Subject: [PATCH] stm32:stm32 alt I2C ensure proper error handling. Injecting data errors would cause the driver to continually reenter the isr with BERR an RxNE. This fix allows the error to be cleared and propagated to the waiting task. --- arch/arm/src/stm32/stm32_i2c_alt.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/arch/arm/src/stm32/stm32_i2c_alt.c b/arch/arm/src/stm32/stm32_i2c_alt.c index 6aba636db6f..9c6ea4f8310 100644 --- a/arch/arm/src/stm32/stm32_i2c_alt.c +++ b/arch/arm/src/stm32/stm32_i2c_alt.c @@ -1840,6 +1840,20 @@ static int stm32_i2c_isr_process(struct stm32_i2c_priv_s *priv) * the ISR cycle to handle the sending/receiving of the messages. */ + /* First check for errors */ + + if ((status & I2C_SR1_ERRORMASK) != 0) + { + stm32_i2c_traceevent(priv, I2CEVENT_ERROR, status & I2C_SR1_ERRORMASK); + + /* Clear interrupt flags */ + + stm32_i2c_putreg(priv, STM32_I2C_SR1_OFFSET, 0); + + priv->dcnt = -1; + priv->msgc = 0; + } + if (priv->dcnt == -1 && priv->msgc == 0) { i2cinfo("Shutting down I2C ISR\n");