You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by ac...@apache.org on 2022/06/20 13:34:28 UTC

[incubator-nuttx] branch master updated: Add I2C_M_NOSTART and I2C_M_NOSTOP support in esp32c3_i2c

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

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


The following commit(s) were added to refs/heads/master by this push:
     new 0fe219a8c9 Add I2C_M_NOSTART and I2C_M_NOSTOP support in esp32c3_i2c
0fe219a8c9 is described below

commit 0fe219a8c94cb58d8037d6c2e4a9178d0ab27d82
Author: AuroraRAS <ch...@gmail.com>
AuthorDate: Sat Jun 18 19:40:06 2022 +0800

    Add I2C_M_NOSTART and I2C_M_NOSTOP support in esp32c3_i2c
    
    Signed-off-by: AuroraRAS <ch...@gmail.com>
---
 arch/risc-v/src/esp32c3/esp32c3_i2c.c | 36 ++++++++++++++++++++++++++++++-----
 1 file changed, 31 insertions(+), 5 deletions(-)

diff --git a/arch/risc-v/src/esp32c3/esp32c3_i2c.c b/arch/risc-v/src/esp32c3/esp32c3_i2c.c
index e762567f34..64ba8238fb 100644
--- a/arch/risc-v/src/esp32c3/esp32c3_i2c.c
+++ b/arch/risc-v/src/esp32c3/esp32c3_i2c.c
@@ -1037,14 +1037,34 @@ static int esp32c3_i2c_transfer(struct i2c_master_s *dev,
 
       esp32c3_i2c_init_clock(priv, msgs[i].frequency);
 
-      /* Reset I2C trace logic */
+#ifndef CONFIG_I2C_POLLED
+      if ((msgs[i].flags & I2C_M_NOSTART) != 0)
+        {
+          esp32c3_i2c_traceevent(priv, I2CEVENT_SENDBYTE, priv->bytes,
+                                 getreg32(I2C_SR_REG(priv->id)));
+          esp32c3_i2c_senddata(priv);
+
+          if (priv->bytes == msgs[i].length)
+            {
+              priv->i2cstate = I2CSTATE_STOP;
+              if ((msgs[i].flags & I2C_M_NOSTOP) != 0)
+                {
+                  priv->i2cstate = I2CSTATE_FINISH;
+                }
+            }
+        }
+      else
+#endif
+        {
+          /* Reset I2C trace logic */
 
-      esp32c3_i2c_tracereset(priv);
+          esp32c3_i2c_tracereset(priv);
 
-      esp32c3_i2c_traceevent(priv, I2CEVENT_SENDADDR, msgs[i].addr,
-                             getreg32(I2C_SR_REG(priv->id)));
+          esp32c3_i2c_traceevent(priv, I2CEVENT_SENDADDR, msgs[i].addr,
+                                 getreg32(I2C_SR_REG(priv->id)));
 
-      esp32c3_i2c_sendstart(priv);
+          esp32c3_i2c_sendstart(priv);
+        }
 
 #ifndef CONFIG_I2C_POLLED
       if (esp32c3_i2c_sem_waitdone(priv) < 0)
@@ -1454,6 +1474,12 @@ static inline void esp32c3_i2c_process(struct esp32c3_i2c_priv_s *priv,
               if (priv->bytes == msg->length)
                 {
                   priv->i2cstate = I2CSTATE_STOP;
+#ifndef CONFIG_I2C_POLLED
+                  if ((msg->flags & I2C_M_NOSTOP) != 0)
+                    {
+                      priv->i2cstate = I2CSTATE_FINISH;
+                    }
+#endif
                 }
             }
         }