Skip to content

Commit

Permalink
Merge pull request #9942 from dhalbert/i2c-probe-delay
Browse files Browse the repository at this point in the history
ports/espressif/common-hal/busio/I2C.c: add delay after probe
  • Loading branch information
dhalbert authored Jan 9, 2025
2 parents 61992cc + 71ba035 commit 77b9880
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions ports/espressif/common-hal/busio/I2C.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

#include "shared-bindings/busio/I2C.h"
#include "py/mperrno.h"
#include "py/mphal.h"
#include "py/runtime.h"

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

bool common_hal_busio_i2c_probe(busio_i2c_obj_t *self, uint8_t addr) {
esp_err_t result = i2c_master_probe(self->handle, addr, 10);

#if defined(CONFIG_IDF_TARGET_ESP32S2)
// ESP32-S2 gives spurious results when probe is called multiple times in succession without this delay.
mp_hal_delay_ms(1);
#endif

return result == ESP_OK;
}

Expand Down

0 comments on commit 77b9880

Please sign in to comment.