summaryrefslogtreecommitdiff
path: root/ports/esp32/machine_i2c.c
diff options
context:
space:
mode:
authorRick Sorensen <rick.sorensen@gmail.com>2025-04-16 09:28:39 -0500
committerDamien George <damien@micropython.org>2025-05-16 17:39:10 +1000
commit90aeac800a0ac861c64dda4b99db1a3f0ed91cea (patch)
tree08f68a27aa8a3ab3bc20c4b6ed81c7f9ac6c4695 /ports/esp32/machine_i2c.c
parent06d8c084b90cb6e56ab9be0de040dcae439ce261 (diff)
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 <rick.sorensen@gmail.com> Signed-off-by: Angus Gratton <angus@redyak.com.au>
Diffstat (limited to 'ports/esp32/machine_i2c.c')
-rw-r--r--ports/esp32/machine_i2c.c5
1 files changed, 5 insertions, 0 deletions
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