This is an automated email from the ASF dual-hosted git repository. aguettouche 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 4693857 xtensa/esp32: Fix ESP32 I2C driver issues 4693857 is described below commit 4693857b2c98ca2d21f7111cb943d6fab074ab09 Author: Dong Heng <dongh...@espressif.com> AuthorDate: Fri Jan 8 20:29:12 2021 +0800 xtensa/esp32: Fix ESP32 I2C driver issues 1. when sending a message in a group fails, exit immediately 2. when catch I2C error interrupt, close interrupt 3. clear clock configuration when deinit I2C 4. free I2C interrupt when deinit I2C --- arch/xtensa/src/esp32/esp32_i2c.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/arch/xtensa/src/esp32/esp32_i2c.c b/arch/xtensa/src/esp32/esp32_i2c.c index 37bf52e..fb480ea 100644 --- a/arch/xtensa/src/esp32/esp32_i2c.c +++ b/arch/xtensa/src/esp32/esp32_i2c.c @@ -548,6 +548,8 @@ static void esp32_i2c_deinit(FAR struct esp32_i2c_priv_s *priv) { const struct esp32_i2c_config_s *config = priv->config; + priv->clk_freq = 0; + modifyreg32(DPORT_PERIP_RST_EN_REG, 0, config->rst_bit); modifyreg32(DPORT_PERIP_CLK_EN_REG, config->clk_bit, 0); } @@ -709,6 +711,7 @@ static int esp32_i2c_transfer(FAR struct i2c_master_s *dev, if (priv->error) { ret = -EIO; + break; } else { @@ -782,6 +785,7 @@ static int esp32_i2c_irq(int cpuint, void *context, FAR void *arg) if (I2C_INT_ERR_EN_BITS & status) { priv->error = status & I2C_INT_ERR_EN_BITS; + esp32_i2c_set_reg(priv, I2C_INT_ENA_OFFSET, 0); nxsem_post(&priv->sem_isr); } else @@ -946,6 +950,12 @@ int esp32_i2cbus_uninitialize(FAR struct i2c_master_s *dev) leave_critical_section(flags); + up_disable_irq(priv->cpuint); + esp32_detach_peripheral(priv->config->cpu, + priv->config->periph, + priv->cpuint); + esp32_free_cpuint(priv->cpuint); + esp32_i2c_deinit(priv); esp32_i2c_sem_destroy(priv);