From 90aeac800a0ac861c64dda4b99db1a3f0ed91cea Mon Sep 17 00:00:00 2001 From: Rick Sorensen Date: Wed, 16 Apr 2025 09:28:39 -0500 Subject: [PATCH] esp32/machine_i2c: Fix default I2C pins for C3, S3. The default I2C init does not require setting SCL or SDA but the default I2C0 pins for C3, S3 conflict with the espressif GPIO usage. For the C3, pins 18/19 are for USB/JTAG. If used for I2C() they will cause the REPL to hang on initialization of the I2C. For the S3 pin 19 is allocated for USB/JTAG also but the defaults do not seem to affect the REPL. See related #16956. Fixes issue #17103. Signed-off-by: Rick Sorensen Signed-off-by: Angus Gratton --- ports/esp32/machine_i2c.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ports/esp32/machine_i2c.c b/ports/esp32/machine_i2c.c index 12b86e4aa..259101ee7 100644 --- a/ports/esp32/machine_i2c.c +++ b/ports/esp32/machine_i2c.c @@ -35,9 +35,14 @@ #if MICROPY_PY_MACHINE_I2C || MICROPY_PY_MACHINE_SOFTI2C #ifndef MICROPY_HW_I2C0_SCL +#if CONFIG_IDF_TARGET_ESP32C3 || CONFIG_IDF_TARGET_ESP32S3 +#define MICROPY_HW_I2C0_SCL (GPIO_NUM_9) +#define MICROPY_HW_I2C0_SDA (GPIO_NUM_8) +#else #define MICROPY_HW_I2C0_SCL (GPIO_NUM_18) #define MICROPY_HW_I2C0_SDA (GPIO_NUM_19) #endif +#endif #ifndef MICROPY_HW_I2C1_SCL #if CONFIG_IDF_TARGET_ESP32