Skip to content

Commit 77b9880

Browse files
authored
Merge pull request #9942 from dhalbert/i2c-probe-delay
ports/espressif/common-hal/busio/I2C.c: add delay after probe
2 parents 61992cc + 71ba035 commit 77b9880

File tree

1 file changed

+7
-0
lines changed
  • ports/espressif/common-hal/busio

1 file changed

+7
-0
lines changed

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
#include "shared-bindings/busio/I2C.h"
88
#include "py/mperrno.h"
9+
#include "py/mphal.h"
910
#include "py/runtime.h"
1011

1112
#include "components/driver/i2c/include/driver/i2c.h"
@@ -134,6 +135,12 @@ void common_hal_busio_i2c_deinit(busio_i2c_obj_t *self) {
134135

135136
bool common_hal_busio_i2c_probe(busio_i2c_obj_t *self, uint8_t addr) {
136137
esp_err_t result = i2c_master_probe(self->handle, addr, 10);
138+
139+
#if defined(CONFIG_IDF_TARGET_ESP32S2)
140+
// ESP32-S2 gives spurious results when probe is called multiple times in succession without this delay.
141+
mp_hal_delay_ms(1);
142+
#endif
143+
137144
return result == ESP_OK;
138145
}
139146

0 commit comments

Comments
 (0)