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 2022/06/18 13:11:32 UTC

[GitHub] [incubator-nuttx] pkarashchenko commented on a diff in pull request #6468: Add I2C_M_NOSTART and I2C_M_NOSTOP support in esp32c3_i2c

pkarashchenko commented on code in PR #6468:
URL: https://github.com/apache/incubator-nuttx/pull/6468#discussion_r900892553


##########
arch/risc-v/src/esp32c3/esp32c3_i2c.c:
##########
@@ -1037,14 +1037,30 @@ static int esp32c3_i2c_transfer(struct i2c_master_s *dev,
 
       esp32c3_i2c_init_clock(priv, msgs[i].frequency);
 
-      /* Reset I2C trace logic */
+      if (msgs[i].flags & I2C_M_NOSTART)

Review Comment:
   Optional
   ```suggestion
         if ((msgs[i].flags & I2C_M_NOSTART) != 0)
   ```



##########
arch/risc-v/src/esp32c3/esp32c3_i2c.c:
##########
@@ -1037,14 +1037,30 @@ static int esp32c3_i2c_transfer(struct i2c_master_s *dev,
 
       esp32c3_i2c_init_clock(priv, msgs[i].frequency);
 
-      /* Reset I2C trace logic */
+      if (msgs[i].flags & I2C_M_NOSTART)
+        {
+          esp32c3_i2c_traceevent(priv, I2CEVENT_SENDBYTE, priv->bytes,
+                                 getreg32(I2C_SR_REG(priv->id)));
+          esp32c3_i2c_senddata(priv);
 
-      esp32c3_i2c_tracereset(priv);
+          if (priv->bytes == msgs[i].length)
+            {
+              priv->i2cstate = I2CSTATE_STOP;
+              if (msgs[i].flags & I2C_M_NOSTOP)
+                priv->i2cstate = I2CSTATE_FINISH;

Review Comment:
   Optionnal
   ```suggestion
                 if ((msgs[i].flags & I2C_M_NOSTOP) != 0)
                   {
                     priv->i2cstate = I2CSTATE_FINISH;
                   }
   ```
   adding `{}` not optional



##########
arch/risc-v/src/esp32c3/esp32c3_i2c.c:
##########
@@ -1454,6 +1470,8 @@ static inline void esp32c3_i2c_process(struct esp32c3_i2c_priv_s *priv,
               if (priv->bytes == msg->length)
                 {
                   priv->i2cstate = I2CSTATE_STOP;
+                  if (msg->flags & I2C_M_NOSTOP)
+                    priv->i2cstate = I2CSTATE_FINISH;

Review Comment:
   ```suggestion
                     if (msg->flags & I2C_M_NOSTOP)
                       {
                         priv->i2cstate = I2CSTATE_FINISH;
                       }
   ```



-- 
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