/**
*
- * @brief I2C bus reset
- * @param struct i2c_master_s *dev : structure visible to the I2C client
- * @return int : ==0 :OK
- * @note
- */
-#ifdef CONFIG_I2C_RESET
-int s5j_i2c_reset(FAR struct i2c_dev_s *dev)
-{
- struct s5j_i2c_priv_s *priv = (struct s5j_i2c_priv_s *)dev;
- unsigned int clock_count;
- unsigned int stretch_count;
- unsigned int scl_gpio;
- unsigned int sda_gpio;
- int ret = ERROR;
-
- DEBUGASSERT(priv && priv->config);
-
- /* Our caller must own a ref */
-
- ASSERT(priv->refs > 0);
-
- /* Lock out other clients */
-
- s5j_i2c_sem_wait(priv);
-
- /* Un-initialize the port */
-
- s5j_i2c_uninitialize(priv);
-
- /* Use GPIO configuration to un-wedge the bus */
-
- scl_gpio = priv->config->scl_pin;
- sda_gpio = priv->config->sda_pin;
-
- gpio_cfg_pin(scl_gpio, GPIO_FUNC(1));
- gpio_cfg_pin(sda_gpio, GPIO_FUNC(1));
-
- /* Let SDA go high */
-
- gpio_set_value(sda_gpio, 1);
- /* Clock the bus until any slaves currently driving it let it go. */
-
- clock_count = 0;
- while (!gpio_get_value(sda_gpio)) {
- /* Give up if we have tried too hard */
-
- if (clock_count++ > 10) {
- goto out;
- }
-
- /* Sniff to make sure that clock stretching has finished.
- *
- * If the bus never relaxes, the reset has failed.
- */
-
- stretch_count = 0;
- while (!gpio_get_value(scl_gpio)) {
- /* Give up if we have tried too hard */
-
- if (stretch_count++ > 10) {
- goto out;
- }
-
- up_udelay(10);
- }
-
- /* Drive SCL low */
-
- gpio_set_value(scl_gpio, 0);
- up_udelay(10);
-
- /* Drive SCL high again */
-
- gpio_set_value(scl_gpio, 1);
- up_udelay(10);
- }
-
- /* Generate a start followed by a stop to reset slave
- * state machines.
- */
-
- gpio_set_value(sda_gpio, 0);
- up_udelay(10);
- gpio_set_value(scl_gpio, 0);
- up_udelay(10);
- gpio_set_value(scl_gpio, 1);
- up_udelay(10);
- gpio_set_value(sda_gpio, 1);
- up_udelay(10);
-
- /* Revert the GPIO configuration. */
-
- gpio_cfg_pin(scl_gpio, GPIO_FUNC(0));
- gpio_cfg_pin(sda_gpio, GPIO_FUNC(0));
- /* Re-init the port */
-
- s5j_i2c_initialize(priv, priv->xfer_speed);
- ret = OK;
-
-out:
-
- /* Release the port for re-use by other clients */
- s5j_i2c_sem_post(priv);
- return ret;
-}
-#endif /* CONFIG_I2C_RESET */
-
-/**
- *
* @brief Initialize one I2C bus
* @param int port :
* @return struct i2c_master_s : device structure
int s5j_i2c_transfer(struct i2c_dev_s *dev, struct i2c_msg_s *msgv, int msgc);
int s5j_i2c_read(FAR struct i2c_dev_s *dev, FAR uint8_t *buffer, int buflen);
int s5j_i2c_write(FAR struct i2c_dev_s *dev, FAR const uint8_t *buffer, int buflen);
-#ifdef CONFIG_I2C_RESET
-int s5j_i2c_reset(FAR struct i2c_dev_s *dev);
-#endif
struct i2c_dev_s *up_i2cinitialize(int port);
int s5j_i2cbus_uninitialize(FAR struct i2c_dev_s *dev);
void s5j_i2c_register(int bus);
-#endif /* __ARCH_ARM_SRC_S5J_I2C_H */
+#endif /* __ARCH_ARM_SRC_S5J_I2C_H */