You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by GitBox <gi...@apache.org> on 2021/09/16 12:39:31 UTC

[GitHub] [incubator-nuttx] gustavonihei commented on a change in pull request #4558: [ESP32][ESP32-C3] Reduce the 10 second semaphore timeout on I2C

gustavonihei commented on a change in pull request #4558:
URL: https://github.com/apache/incubator-nuttx/pull/4558#discussion_r710077224



##########
File path: arch/risc-v/src/esp32c3/esp32c3_i2c.c
##########
@@ -799,8 +799,18 @@ static int esp32c3_i2c_sem_waitdone(struct esp32c3_i2c_priv_s *priv)
 
   clock_gettime(CLOCK_REALTIME, &abstime);
 
-  abstime.tv_sec += 10;
-  abstime.tv_nsec += 0;
+#if CONFIG_ESP32C3_I2CTIMEOSEC > 0
+  abstime.tv_sec += CONFIG_ESP32C3_I2CTIMEOSEC;
+#endif
+
+#if CONFIG_ESP32C3_I2CTIMEOMS > 0
+  abstime.tv_nsec += CONFIG_ESP32C3_I2CTIMEOMS * 1000 * 1000;
+  if (abstime.tv_nsec >= 1000 * 1000 * 1000)
+    {
+      abstime.tv_sec++;
+      abstime.tv_nsec -= 1000 * 1000 * 1000;
+    }
+#endif

Review comment:
       Nice suggestion, fixed! Thanks!




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org