@@ -123,25 +123,26 @@ static int i2c_esp32_config_pin(const struct device *dev)
123123{
124124 const struct i2c_esp32_config * config = dev -> config ;
125125 struct i2c_esp32_data * data = (struct i2c_esp32_data * const )(dev )-> data ;
126+ int ret = 0 ;
126127
127128 if (config -> index >= SOC_I2C_NUM ) {
128129 LOG_ERR ("Invalid I2C peripheral number" );
129130 return - EINVAL ;
130131 }
131132
132133 gpio_pin_set (data -> sda_gpio , config -> sda .pin , 1 );
133- gpio_pin_configure (data -> sda_gpio , config -> sda .pin ,
134+ ret = gpio_pin_configure (data -> sda_gpio , config -> sda .pin ,
134135 GPIO_PULL_UP | GPIO_OPEN_DRAIN | GPIO_OUTPUT | GPIO_INPUT );
135136 esp_rom_gpio_matrix_out (config -> sda .pin , config -> sda .sig_out , 0 , 0 );
136137 esp_rom_gpio_matrix_in (config -> sda .pin , config -> sda .sig_in , 0 );
137138
138139 gpio_pin_set (data -> scl_gpio , config -> scl .pin , 1 );
139- gpio_pin_configure (data -> scl_gpio , config -> scl .pin ,
140+ ret |= gpio_pin_configure (data -> scl_gpio , config -> scl .pin ,
140141 GPIO_PULL_UP | GPIO_OPEN_DRAIN | GPIO_OUTPUT | GPIO_INPUT );
141142 esp_rom_gpio_matrix_out (config -> scl .pin , config -> scl .sig_out , 0 , 0 );
142143 esp_rom_gpio_matrix_in (config -> scl .pin , config -> scl .sig_in , 0 );
143144
144- return 0 ;
145+ return ret ;
145146}
146147
147148/* Some slave device will die by accident and keep the SDA in low level,
@@ -275,8 +276,6 @@ static int i2c_esp32_configure(const struct device *dev, uint32_t dev_config)
275276 i2c_hal_set_bus_timing (& data -> hal , config -> bitrate , i2c_get_clk_src (config -> bitrate ));
276277 i2c_hal_update_config (& data -> hal );
277278
278- irq_enable (data -> irq_line );
279-
280279 return 0 ;
281280}
282281
@@ -473,6 +472,7 @@ static int IRAM_ATTR i2c_esp32_write_msg(const struct device *dev,
473472 if (wr_filled > 0 ) {
474473 i2c_hal_write_txfifo (& data -> hal , write_pr , wr_filled );
475474 i2c_hal_write_cmd_reg (& data -> hal , cmd , data -> cmd_idx ++ );
475+ i2c_hal_write_cmd_reg (& data -> hal , hw_end_cmd , data -> cmd_idx ++ );
476476 }
477477
478478 if (msg -> len == 0 && (msg -> flags & I2C_MSG_STOP )) {
@@ -482,8 +482,6 @@ static int IRAM_ATTR i2c_esp32_write_msg(const struct device *dev,
482482 .byte_num = 0
483483 };
484484 i2c_hal_write_cmd_reg (& data -> hal , cmd , data -> cmd_idx ++ );
485- } else {
486- i2c_hal_write_cmd_reg (& data -> hal , hw_end_cmd , data -> cmd_idx ++ );
487485 }
488486
489487 i2c_hal_enable_master_tx_it (& data -> hal );
@@ -651,7 +649,7 @@ static int IRAM_ATTR i2c_esp32_init(const struct device *dev)
651649
652650 clock_control_on (config -> clock_dev , config -> clock_subsys );
653651
654- data -> irq_line = esp_intr_alloc (config -> irq_source , 0 , i2c_esp32_isr , (void * )dev , NULL );
652+ esp_intr_alloc (config -> irq_source , 0 , i2c_esp32_isr , (void * )dev , NULL );
655653
656654 return i2c_esp32_configure (dev , config -> default_config );
657655}
0 commit comments