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/11/05 12:47:50 UTC

[GitHub] [incubator-nuttx] yunkya2 commented on a change in pull request #4786: rp2040: support I2C_RESET

yunkya2 commented on a change in pull request #4786:
URL: https://github.com/apache/incubator-nuttx/pull/4786#discussion_r743631676



##########
File path: arch/arm/src/rp2040/rp2040_i2c.c
##########
@@ -639,7 +642,158 @@ static int rp2040_i2c_transfer(FAR struct i2c_master_s *dev,
 #ifdef CONFIG_I2C_RESET
 static int rp2040_i2c_reset(FAR struct i2c_master_s *dev)
 {
-  return OK;
+  FAR struct rp2040_i2cdev_s *priv = (struct rp2040_i2cdev_s *)dev;
+  unsigned int clock_count;
+  unsigned int stretch_count;
+  uint32_t scl_gpio;
+  uint32_t sda_gpio;
+  uint32_t subsys;
+  uint32_t frequency;
+  int ret;
+
+  DEBUGASSERT(dev);
+
+  /* Our caller must own a ref */
+
+  DEBUGASSERT(priv->refs > 0);
+
+  /* Lock out other clients */
+
+  i2c_takesem(&priv->mutex);
+
+  ret = -EIO;
+
+  /* De-init the port */
+
+  rp2040_i2c_disable(priv);
+
+  /* Use GPIO configuration to un-wedge the bus */
+
+  switch (priv->port)
+    {
+      case 0:
+#if defined(CONFIG_RP2040_I2C0) && CONFIG_RP2040_I2C0_GPIO >= 0
+        sda_gpio = CONFIG_RP2040_I2C0_GPIO;

Review comment:
       Currently all RP2040 GPIO pins are assigned in https://github.com/apache/incubator-nuttx/blob/master/boards/arm/rp2040/raspberrypi-pico/src/rp2040_boardinitialize.c
   The functions, such as I2C and SPI, are assigned here according to the kernel configurations, but the current GPIO API design have no assumption that the assignment may be changed after the boot.  This is the reason of the dirty design in rp2040_i2c_reset().
   
   I think it is better to provide the APIs to retrieve the current GPIO function assignment to make it clean.




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