mirror of
https://github.com/apache/nuttx.git
synced 2026-06-08 01:42:58 +08:00
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:
@@ -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
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user