← index #17696PR #18063
Duplicate · high · value 6.887
QUERY · ISSUE

Update api of esp32 i2c and other drivers.

openby Vincent1-pythonopened 2025-07-17updated 2025-07-31
enhancementport-esp32

Description

Update api of esp32 i2c and other drivers.Because it will be removed in idf 6, it will not be compiled.

Code Size

None

Implementation

I hope the MicroPython maintainers or community will implement this feature

Code of Conduct

Yes, I agree

CANDIDATE · PULL REQUEST

esp32/machine_i2c: Update to use new ESP-IDF driver API.

mergedby robert-hhopened 2025-09-13updated 2025-10-17
port-esp32

This is a rebase & resubmit of https://github.com/micropython/micropython/pull/17971 by @Vincent1-python and a continuation/replacement of #18049.

Summary

Replace the legacy ESP-IDF I2C driver (driver/i2c.h) with the new driver/i2c_master.h API for all ESP32-series SoCs. This change:
Removes dependency on the deprecated peripheral driver that is no longer present in ESP-IDF ≥ 6.0. Keeps the existing machine.I2C API almost unchanged (see Trade-offs), so user scripts do not require modification.

Prepared for creating dev_handle once at esp-idf v5.5. So it supports now v5.4.2 and v5.5. Tested with both versions.

Testing

Tested with ESP32 classic, ESP32S2, ESP32S3, ESP32C2, ESP32C3 and ESP32C5, esp-idf version 5.4.2, using a SAMD51 in target mode as device.
Tested with ESP32 classic and esp-idf v5.5.

Trade-offs and Alternatives

  • no control of the stop=True|False option. stop is always assumed to be True. An issue 17572 is raised at the esp-idf repository for it, but it's not clear whether this will be changed.
  • Separate call to probe the address at fixed 100kHz. The need is caused by the fact, that NACK on an address is considered as an hard error. According to espressif's issue tracker this is already changed for v6.x and will be backported to earlier versions. So we may see it in a version after V5.5.1 or in a version 5.4.3. There is code in comments to support zero-length writes.

Alternatives: We could keep the current legacy version until there is a strong need for a change, like boards only supported by esp-idf 6.x. Maybe until then some of the trade-offs are gone.

Keyboard

j / / n
next pair
k / / p
previous pair
1 / / h
show query pane
2 / / l
show candidate pane
c
copy suggested comment
r
toggle reasoning
g i
go to index
?
show this help
esc
close overlays

press ? or esc to close

copied