STM32 I2C: Bring in PX4 fix for I2C in very high noise environments or with rogue perpipherals. Taken from the PX4 commit by Tridge

This commit is contained in:
Gregory Nutt
2014-05-10 10:34:05 -06:00
parent 308d0dbe06
commit fa7c79712e
2 changed files with 13 additions and 2 deletions
-1
View File
@@ -698,7 +698,6 @@ config STM32_STM32F207
default n
select STM32_HAVE_OTGFS
select STM32_HAVE_FSMC
select STM32_HAVE_CCM
select STM32_HAVE_USART3
select STM32_HAVE_USART4
select STM32_HAVE_USART5
+13 -1
View File
@@ -1617,7 +1617,14 @@ static int stm32_i2c_process(FAR struct i2c_dev_s *dev, FAR struct i2c_msg_s *ms
stm32_i2c_clrstart(priv);
/* Old transfers are done */
/* Old transfers are done
*
* Reset ptr and dcnt to ensure an unexpected data interrupt doesn't
* overwrite stale data.
*/
priv->dcnt = 0;
priv->ptr = NULL;
priv->msgv = msgs;
priv->msgc = count;
@@ -1754,6 +1761,11 @@ static int stm32_i2c_process(FAR struct i2c_dev_s *dev, FAR struct i2c_msg_s *ms
stm32_i2c_enablefsmc(ahbenr);
stm32_i2c_sem_post(dev);
/* Ensure that any ISR happening after we finish can't overwrite any user data */
priv->dcnt = 0;
priv->ptr = NULL;
return -errval;
}