diff --git a/nuttx-patches/i2c_hotfix.patch b/nuttx-patches/i2c_hotfix.patch index c7eef298f331..dcd68c0c9f02 100644 --- a/nuttx-patches/i2c_hotfix.patch +++ b/nuttx-patches/i2c_hotfix.patch @@ -1,5 +1,5 @@ diff --git NuttX/nuttx/arch/arm/src/stm32/stm32_i2c.c NuttX/nuttx/arch/arm/src/stm32/stm32_i2c.c -index 631ba66..654d18a 100644 +index 631ba66..669e0db 100644 --- NuttX/nuttx/arch/arm/src/stm32/stm32_i2c.c +++ NuttX/nuttx/arch/arm/src/stm32/stm32_i2c.c @@ -7,7 +7,7 @@ @@ -31,8 +31,30 @@ index 631ba66..654d18a 100644 } /* Loop until the transfer is complete. */ +@@ -729,6 +729,10 @@ static inline void stm32_i2c_sem_waitstop(FAR struct stm32_i2c_priv_s *priv) + start = clock_systimer(); + do + { ++ /* Calculate the elapsed time */ ++ ++ elapsed = clock_systimer() - start; ++ + /* Check for STOP condition */ + + cr1 = stm32_i2c_getreg(priv, STM32_I2C_CR1_OFFSET); +@@ -744,10 +748,6 @@ static inline void stm32_i2c_sem_waitstop(FAR struct stm32_i2c_priv_s *priv) + { + return; + } +- +- /* Calculate the elapsed time */ +- +- elapsed = clock_systimer() - start; + } + + /* Loop until the stop is complete or a timeout occurs. */ diff --git NuttX/nuttx/arch/arm/src/stm32/stm32_i2c_alt.c NuttX/nuttx/arch/arm/src/stm32/stm32_i2c_alt.c -index 545a647..61cea4e 100644 +index 545a647..981edb6 100644 --- NuttX/nuttx/arch/arm/src/stm32/stm32_i2c_alt.c +++ NuttX/nuttx/arch/arm/src/stm32/stm32_i2c_alt.c @@ -7,7 +7,7 @@ @@ -64,8 +86,29 @@ index 545a647..61cea4e 100644 } /* Loop until the transfer is complete. */ +@@ -737,6 +737,10 @@ static inline void stm32_i2c_sem_waitstop(FAR struct stm32_i2c_priv_s *priv) + start = clock_systimer(); + do + { ++ /* Calculate the elapsed time */ ++ ++ elapsed = clock_systimer() - start; ++ + /* Check for STOP condition */ + + cr1 = stm32_i2c_getreg(priv, STM32_I2C_CR1_OFFSET); +@@ -753,9 +757,6 @@ static inline void stm32_i2c_sem_waitstop(FAR struct stm32_i2c_priv_s *priv) + return; + } + +- /* Calculate the elapsed time */ +- +- elapsed = clock_systimer() - start; + } + + /* Loop until the stop is complete or a timeout occurs. */ diff --git NuttX/nuttx/arch/arm/src/stm32/stm32f30xxx_i2c.c NuttX/nuttx/arch/arm/src/stm32/stm32f30xxx_i2c.c -index 312e0b4..193ccb8 100644 +index 312e0b4..b2da861 100644 --- NuttX/nuttx/arch/arm/src/stm32/stm32f30xxx_i2c.c +++ NuttX/nuttx/arch/arm/src/stm32/stm32f30xxx_i2c.c @@ -7,7 +7,7 @@ @@ -97,8 +140,29 @@ index 312e0b4..193ccb8 100644 } /* Loop until the transfer is complete. */ +@@ -844,6 +844,10 @@ static inline void stm32_i2c_sem_waitstop(FAR struct stm32_i2c_priv_s *priv) + start = clock_systimer(); + do + { ++ /* Calculate the elapsed time */ ++ ++ elapsed = clock_systimer() - start; ++ + /* Check for STOP condition */ + + cr = stm32_i2c_getreg32(priv, STM32_I2C_CR2_OFFSET); +@@ -860,9 +864,6 @@ static inline void stm32_i2c_sem_waitstop(FAR struct stm32_i2c_priv_s *priv) + return; + } + +- /* Calculate the elapsed time */ +- +- elapsed = clock_systimer() - start; + } + + /* Loop until the stop is complete or a timeout occurs. */ diff --git NuttX/nuttx/arch/arm/src/stm32/stm32f40xxx_i2c.c NuttX/nuttx/arch/arm/src/stm32/stm32f40xxx_i2c.c -index 2bb715c..974fab8 100644 +index 2bb715c..e91058a 100644 --- NuttX/nuttx/arch/arm/src/stm32/stm32f40xxx_i2c.c +++ NuttX/nuttx/arch/arm/src/stm32/stm32f40xxx_i2c.c @@ -7,7 +7,7 @@ @@ -130,10 +194,40 @@ index 2bb715c..974fab8 100644 } /* Loop until the transfer is complete. */ +@@ -731,6 +731,10 @@ static inline void stm32_i2c_sem_waitstop(FAR struct stm32_i2c_priv_s *priv) + start = clock_systimer(); + do + { ++ /* Calculate the elapsed time */ ++ ++ elapsed = clock_systimer() - start; ++ + /* Check for STOP condition */ + + cr1 = stm32_i2c_getreg(priv, STM32_I2C_CR1_OFFSET); +@@ -747,9 +751,6 @@ static inline void stm32_i2c_sem_waitstop(FAR struct stm32_i2c_priv_s *priv) + return; + } + +- /* Calculate the elapsed time */ +- +- elapsed = clock_systimer() - start; + } + + /* Loop until the stop is complete or a timeout occurs. */ diff --git NuttX/nuttx/arch/arm/src/stm32f7/stm32_i2c.c NuttX/nuttx/arch/arm/src/stm32f7/stm32_i2c.c -index d089db9..1b5951d 100644 +index d089db9..fd73457 100644 --- NuttX/nuttx/arch/arm/src/stm32f7/stm32_i2c.c +++ NuttX/nuttx/arch/arm/src/stm32f7/stm32_i2c.c +@@ -7,7 +7,7 @@ + * + * With extensions and modifications for the F1, F2, and F4 by: + * +- * Copyright (C) 2016 Gregory Nutt. All rights reserved. ++ * Copyright (C) 2016-2017 Gregory Nutt. All rights reserved. + * Authors: Gregroy Nutt + * John Wharington + * David Sidrane @@ -897,15 +897,15 @@ static inline int stm32_i2c_sem_waitdone(FAR struct stm32_i2c_priv_s *priv) do @@ -154,8 +248,29 @@ index d089db9..1b5951d 100644 } /* Loop until the transfer is complete. */ +@@ -1034,6 +1034,10 @@ static inline void stm32_i2c_sem_waitstop(FAR struct stm32_i2c_priv_s *priv) + start = clock_systimer(); + do + { ++ /* Calculate the elapsed time */ ++ ++ elapsed = clock_systimer() - start; ++ + /* Check for STOP condition */ + + cr = stm32_i2c_getreg32(priv, STM32_I2C_CR2_OFFSET); +@@ -1050,9 +1054,6 @@ static inline void stm32_i2c_sem_waitstop(FAR struct stm32_i2c_priv_s *priv) + return; + } + +- /* Calculate the elapsed time */ +- +- elapsed = clock_systimer() - start; + } + + /* Loop until the stop is complete or a timeout occurs. */ diff --git NuttX/nuttx/arch/arm/src/stm32l4/stm32l4_i2c.c NuttX/nuttx/arch/arm/src/stm32l4/stm32l4_i2c.c -index eed199f..d5027bf 100644 +index eed199f..be46524 100644 --- NuttX/nuttx/arch/arm/src/stm32l4/stm32l4_i2c.c +++ NuttX/nuttx/arch/arm/src/stm32l4/stm32l4_i2c.c @@ -4,7 +4,7 @@ @@ -187,3 +302,24 @@ index eed199f..d5027bf 100644 } /* Loop until the transfer is complete. */ +@@ -788,6 +788,10 @@ static inline void stm32l4_i2c_sem_waitstop(FAR struct stm32l4_i2c_priv_s *priv) + start = clock_systimer(); + do + { ++ /* Calculate the elapsed time */ ++ ++ elapsed = clock_systimer() - start; ++ + /* Check for STOP condition */ + + cr = stm32l4_i2c_getreg32(priv, STM32L4_I2C_CR2_OFFSET); +@@ -804,9 +808,6 @@ static inline void stm32l4_i2c_sem_waitstop(FAR struct stm32l4_i2c_priv_s *priv) + return; + } + +- /* Calculate the elapsed time */ +- +- elapsed = clock_systimer() - start; + } + + /* Loop until the stop is complete or a timeout occurs. */