Skip to content

Commit

Permalink
I2C: Fix the reset counter
Browse files Browse the repository at this point in the history
  • Loading branch information
o-marshmallow authored and suda-morris committed Nov 3, 2022
1 parent 1ea5682 commit 4ef2ba2
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion components/driver/i2c.c
Original file line number Diff line number Diff line change
Expand Up @@ -1472,7 +1472,7 @@ static bool is_cmd_link_buffer_internal(const i2c_cmd_link_t *link)
}
#endif

static uint8_t clear_bus_cnt[2] = { 0, 0 };
static uint8_t clear_bus_cnt[I2C_NUM_MAX] = { 0 };

esp_err_t i2c_master_cmd_begin(i2c_port_t i2c_num, i2c_cmd_handle_t cmd_handle, TickType_t ticks_to_wait)
{
Expand Down Expand Up @@ -1557,6 +1557,7 @@ esp_err_t i2c_master_cmd_begin(i2c_port_t i2c_num, i2c_cmd_handle_t cmd_handle,
clear_bus_cnt[i2c_num]++;
if (clear_bus_cnt[i2c_num] >= I2C_ACKERR_CNT_MAX) {
clear_bus_cnt[i2c_num] = 0;
i2c_hw_fsm_reset(i2c_num);
}
ret = ESP_FAIL;
} else {
Expand Down

0 comments on commit 4ef2ba2

Please sign in to comment.