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 806aee8247
commit 75d3d33169
3 changed files with 18 additions and 3 deletions

View File

@ -7322,4 +7322,8 @@
* binfmt/libpcode, pcode.c, include/nuttx/poff.h, and binfmt/pcode.h:
Now uses apps/interpreters/prun and is basically functional. More work
is needed because (1) it is too coupled with apps/ and (2) will not work
with CONFIG_NUTTX_KERNEL (2014-5-9).
with CONFIG_NUTTX_KERNEL (2014-5-9).
* arch/arm/src/stm32/stm32_i2c.c: Bring in PX4 fix for I2C in very high
noise environments or with rogue perpipherals. Taken from the PX4 commit
099b2017ccfa0fc7696f168db2a0c2e13fe5edbc by Tridge here:
https://github.com/PX4/NuttX (2014-5-10).

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

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;
}