diff options
author | Gregory Nutt <gnutt@nuttx.org> | 2014-05-10 10:34:05 -0600 |
---|---|---|
committer | Gregory Nutt <gnutt@nuttx.org> | 2014-05-10 10:34:05 -0600 |
commit | 3e75c2da3aa372c71e2543f00c50d8d3abb6002e (patch) | |
tree | aee5277d2fc4eaa703ba42afbac23e274a4d09a5 | |
parent | 2992f82c56ff672531fd152c89e783c6fc2daec0 (diff) | |
download | nuttx-3e75c2da3aa372c71e2543f00c50d8d3abb6002e.tar.gz nuttx-3e75c2da3aa372c71e2543f00c50d8d3abb6002e.tar.bz2 nuttx-3e75c2da3aa372c71e2543f00c50d8d3abb6002e.zip |
STM32 I2C: Bring in PX4 fix for I2C in very high noise environments or with rogue perpipherals. Taken from the PX4 commit by Tridge
-rw-r--r-- | nuttx/ChangeLog | 6 | ||||
-rw-r--r-- | nuttx/arch/arm/src/stm32/Kconfig | 1 | ||||
-rw-r--r-- | nuttx/arch/arm/src/stm32/stm32_i2c.c | 14 |
3 files changed, 18 insertions, 3 deletions
diff --git a/nuttx/ChangeLog b/nuttx/ChangeLog index e635e8f02..1c76c708b 100644 --- a/nuttx/ChangeLog +++ b/nuttx/ChangeLog @@ -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).
\ No newline at end of file + 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). diff --git a/nuttx/arch/arm/src/stm32/Kconfig b/nuttx/arch/arm/src/stm32/Kconfig index b1e0419f4..8ea719c82 100644 --- a/nuttx/arch/arm/src/stm32/Kconfig +++ b/nuttx/arch/arm/src/stm32/Kconfig @@ -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 diff --git a/nuttx/arch/arm/src/stm32/stm32_i2c.c b/nuttx/arch/arm/src/stm32/stm32_i2c.c index 8c3c5487d..d745261a7 100644 --- a/nuttx/arch/arm/src/stm32/stm32_i2c.c +++ b/nuttx/arch/arm/src/stm32/stm32_i2c.c @@ -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; } |