You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by xi...@apache.org on 2023/10/23 14:45:05 UTC

[nuttx] 03/03: imxrt:lpi2c Timeouts can not be 0

This is an automated email from the ASF dual-hosted git repository.

xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git

commit 6101ebd565d8025da6a77650218f1d9d8068d212
Author: David Sidrane <Da...@NscDg.com>
AuthorDate: Mon Oct 23 04:22:16 2023 -0700

    imxrt:lpi2c Timeouts can not be 0
---
 arch/arm/src/imxrt/imxrt_lpi2c.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/arch/arm/src/imxrt/imxrt_lpi2c.c b/arch/arm/src/imxrt/imxrt_lpi2c.c
index d81333c9a6..a390a532ad 100644
--- a/arch/arm/src/imxrt/imxrt_lpi2c.c
+++ b/arch/arm/src/imxrt/imxrt_lpi2c.c
@@ -645,8 +645,9 @@ static inline void imxrt_lpi2c_modifyreg(struct imxrt_lpi2c_priv_s *priv,
 #ifdef CONFIG_IMXRT_LPI2C_DYNTIMEO
 static uint32_t imxrt_lpi2c_toticks(int msgc, struct i2c_msg_s *msgs)
 {
-  size_t bytecount = 0;
   int i;
+  size_t bytecount = 0;
+  uint32_t tick    = 0;
 
   /* Count the number of bytes left to process */
 
@@ -659,7 +660,13 @@ static uint32_t imxrt_lpi2c_toticks(int msgc, struct i2c_msg_s *msgs)
    * factor.
    */
 
-  return USEC2TICK(CONFIG_IMXRT_LPI2C_DYNTIMEO_USECPERBYTE * bytecount);
+  tick = USEC2TICK(CONFIG_IMXRT_LPI2C_DYNTIMEO_USECPERBYTE * bytecount);
+  if (tick == 0)
+    {
+      tick = 1;
+    }
+
+  return tick;
 }
 #endif