Avoid a possible issue where an interrupt can intervene at a critical point, possibly leading to excess bytes being transferred on the bus.

This commit is contained in:
px4dev
2012-09-14 00:22:07 -07:00
parent 04b5856764
commit adad44a3a9
+9
View File
@@ -1198,6 +1198,10 @@ static int stm32_i2c_isr(struct stm32_i2c_priv_s *priv)
{
stm32_i2c_traceevent(priv, I2CEVENT_RCVBYTE, priv->dcnt);
#ifdef CONFIG_I2C_POLLED
//irqstate_t state = irqsave();
#endif
/* Receive a byte */
*priv->ptr++ = stm32_i2c_getreg(priv, STM32_I2C_DR_OFFSET);
@@ -1209,6 +1213,11 @@ static int stm32_i2c_isr(struct stm32_i2c_priv_s *priv)
stm32_i2c_modifyreg(priv, STM32_I2C_CR1_OFFSET, I2C_CR1_ACK, 0);
}
priv->dcnt--;
#ifdef CONFIG_I2C_POLLED
//irqrestore(state);
#endif
}
}