Skip to content

Commit a511e52

Browse files
committed
Fix espressif i2c timeouts
1 parent 5010170 commit a511e52

File tree

1 file changed

+3
-3
lines changed
  • ports/espressif/common-hal/busio

1 file changed

+3
-3
lines changed

ports/espressif/common-hal/busio/I2C.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ bool common_hal_busio_i2c_probe(busio_i2c_obj_t *self, uint8_t addr) {
141141
i2c_master_start(cmd);
142142
i2c_master_write_byte(cmd, addr << 1, true);
143143
i2c_master_stop(cmd);
144-
esp_err_t result = i2c_master_cmd_begin(self->i2c_num, cmd, 10);
144+
esp_err_t result = i2c_master_cmd_begin(self->i2c_num, cmd, 1);
145145
i2c_cmd_link_delete(cmd);
146146
return result == ESP_OK;
147147
}
@@ -172,7 +172,7 @@ uint8_t common_hal_busio_i2c_write(busio_i2c_obj_t *self, uint16_t addr,
172172
if (transmit_stop_bit) {
173173
i2c_master_stop(cmd);
174174
}
175-
esp_err_t result = i2c_master_cmd_begin(self->i2c_num, cmd, 100 /* wait in ticks */);
175+
esp_err_t result = i2c_master_cmd_begin(self->i2c_num, cmd, pdMS_TO_TICKS(1000));
176176
i2c_cmd_link_delete(cmd);
177177

178178
if (result == ESP_OK) {
@@ -193,7 +193,7 @@ uint8_t common_hal_busio_i2c_read(busio_i2c_obj_t *self, uint16_t addr,
193193
}
194194
i2c_master_read_byte(cmd, data + len - 1, 1);
195195
i2c_master_stop(cmd);
196-
esp_err_t result = i2c_master_cmd_begin(self->i2c_num, cmd, 100 /* wait in ticks */);
196+
esp_err_t result = i2c_master_cmd_begin(self->i2c_num, cmd, pdMS_TO_TICKS(1000));
197197
i2c_cmd_link_delete(cmd);
198198

199199
if (result == ESP_OK) {

0 commit comments

Comments
 (0)