Skip to content

feat(i2c): Update i2c to default to new driver, and update driver to be more backwards compatible to facilitate upgrade#621

Merged
finger563 merged 16 commits into
mainfrom
feat/i2c-refactor
May 29, 2026
Merged

feat(i2c): Update i2c to default to new driver, and update driver to be more backwards compatible to facilitate upgrade#621
finger563 merged 16 commits into
mainfrom
feat/i2c-refactor

Conversation

@finger563
Copy link
Copy Markdown
Contributor

@finger563 finger563 commented May 28, 2026

Description

  • Update i2c component to default to new (non-EOL) i2c driver
  • Update all affected bsp and component examples to use new driver
  • Update docs

Motivation and Context

As of esp-idf v6.0 the older driver/i2c.h from esp-idf is end-of-lifed (EOL-ed), so we need to transition to the new driver.

The new espp driver is still included as i2c.hpp and is espp::I2c, but can be used now with additional device registration.

It still supports a backwards compatible API to facilitate migration.

How has this been tested?

  • Build and run i2c/example using v6.0
  • Build examples against v5.5 in CI
  • Build and run t-deck/example using v6.0

Screenshots (if appropriate, e.g. schematic, board, console logs, lab pictures):

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation Update
  • Hardware (schematic, board, system design) change
  • Software change

Checklist:

  • My change requires a change to the documentation.
  • I have added / updated the documentation related to this change via either README or WIKI

Software

  • I have added tests to cover my changes.
  • I have updated the .github/workflows/build.yml file to add my new test to the automated cloud build github action.
  • All new and existing tests passed.
  • My code follows the code style of this project.

…be more backwards compatible to facilitate upgrade
Copilot AI review requested due to automatic review settings May 28, 2026 20:57
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 28, 2026

✅Static analysis result - no issues found! ✅

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR modernizes ESPP’s i2c component by defaulting to ESP-IDF’s newer master/slave bus driver family while preserving the existing espp::I2c address-based helper API for easier upgrades across the codebase.

Changes:

  • Switched the i2c component Kconfig default to the new ESP-IDF master/slave bus API and updated docs to describe the “primary” compatibility API vs explicit bus/device wrappers.
  • Added/expanded compatibility helpers (add_device() + make_i2c_addressed_*() wrappers) and migrated many components/examples to use explicit device handles.
  • Reworked I2cSlaveDevice to buffer master-write transactions and dispatch callbacks in task context (rather than ISR context).

Reviewed changes

Copilot reviewed 68 out of 68 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
doc/en/i2c.rst Updates documentation to describe primary compatibility API + explicit master/slave APIs and legacy selection.
components/i2c/README.md Refreshes component overview to match new default driver and new slave behavior description.
components/i2c/Kconfig Defaults to new API and updates help text for legacy/new selection.
components/i2c/CMakeLists.txt Adds esp_driver_i2c dependency for new driver family support.
components/i2c/idf_component.yml Updates component description to reflect broader scope than legacy-only.
components/i2c/include/i2c.hpp Implements “primary” espp::I2c backed by new bus API (or legacy driver) + add_device() + addressed helper factories.
components/i2c/include/i2c_menu.hpp Makes I2cMenu available for the primary (compatibility) API and updates scan notes.
components/i2c/include/i2c_master.hpp Minor API refinement (inline config() accessor).
components/i2c/src/i2c_master.cpp Improves error mapping for master probe failures.
components/i2c/include/i2c_master_menu.hpp Updates CLI menu parsing/scan behavior and uses explicit timeouts for probing.
components/i2c/include/i2c_master_device_menu.hpp Updates CLI menu argument parsing and probe timeout usage.
components/i2c/include/i2c_slave.hpp Expands slave wrapper config/options; documents queued reads + task-context callbacks.
components/i2c/src/i2c_slave.cpp Implements slave buffering via message buffers + event task dispatch and improved error reporting.
components/i2c/include/i2c_slave_menu.hpp Updates slave CLI to match queued-transaction model and generic arg parsing.
components/i2c/example/main/i2c_example.cpp Reworks example to show primary API + optional explicit device menu + adds slave menu include for new API builds.
components/ws-s3-touch/src/touchpad.cpp Switches touch driver wiring to explicit add_device() + addressed read/write helpers.
components/ws-s3-touch/src/rtc.cpp Switches RTC wiring to explicit add_device() + addressed read/write helpers.
components/ws-s3-touch/src/imu.cpp Switches IMU wiring to explicit add_device() + addressed read/write helpers.
components/t-deck/src/t-deck.cpp Switches keyboard/touch wiring to explicit add_device() + addressed read/write helpers.
components/m5stack-tab5/src/touchpad.cpp Switches touch wiring to explicit add_device() + addressed read/write helpers.
components/m5stack-tab5/src/rtc.cpp Switches RTC wiring to explicit add_device() + addressed read/write helpers.
components/m5stack-tab5/src/power.cpp Switches INA226 wiring to explicit add_device() + addressed probe/read/write helpers.
components/m5stack-tab5/src/m5stack-tab5.cpp Switches IO expanders to explicit add_device() + addressed write/write_then_read helpers.
components/m5stack-tab5/src/imu.cpp Switches IMU wiring to explicit add_device() + addressed read/write helpers.
components/m5stack-tab5/src/audio.cpp Switches ES8388/ES7210 register access wiring to explicit add_device() + addressed helpers.
components/esp-box/src/touchpad.cpp Switches GT911/TT21100 wiring to explicit add_device() + addressed helpers.
components/esp-box/src/imu.cpp Switches IMU wiring to explicit add_device() + addressed read/write helpers.
components/esp-box/src/audio.cpp Switches codec register access wiring to explicit add_device() + addressed helpers.
components/seeed-studio-round-display/src/seeed-studio-round-display.cpp Switches touch wiring to explicit add_device() + addressed helpers.
components/smartpanlee-sc01-plus/src/smartpanlee-sc01-plus.cpp Switches touch wiring to explicit add_device() + addressed write/read_register helpers.
components/matouch-rotary-display/src/matouch-rotary-display.cpp Switches touch wiring to explicit add_device() + addressed helpers.
components/esp32-timer-cam/src/esp32-timer-cam.cpp Switches RTC wiring to explicit add_device() + addressed write/write_then_read helpers.
components/byte90/src/accelerometer.cpp Switches accelerometer wiring to explicit add_device() + addressed helpers.
components/t_keyboard/example/main/t_keyboard_example.cpp Updates example to create explicit device handle and use addressed helpers.
components/gt911/example/main/gt911_example.cpp Updates example to create explicit device handle and use addressed helpers.
components/ft5x06/example/main/ft5x06_example.cpp Updates example to create explicit device handle and use addressed helpers.
components/vl53l/example/main/vl53l_example.cpp Updates example to create explicit device handle and use addressed helpers.
components/tt21100/example/main/tt21100_example.cpp Updates example to create explicit device handle and use addressed helpers.
components/tla2528/example/main/tla2528_example.cpp Updates example to create explicit device handle and use addressed helpers.
components/rx8130ce/example/main/rx8130ce_example.cpp Updates example to create explicit device handle and use addressed helpers.
components/qwiicnes/example/main/qwiicnes_example.cpp Updates example to create explicit device handle and use addressed helpers.
components/qmi8658/example/main/qmi8658_example.cpp Updates example to create explicit device handle and use addressed helpers.
components/pi4ioe5v/example/main/pi4ioe5v_example.cpp Updates example to create explicit device handle and use addressed helpers.
components/pcf85063/example/main/pcf85063_example.cpp Updates example to create explicit device handle and use addressed helpers.
components/mt6701/example/main/mt6701_example.cpp Updates example to create explicit device handle and use addressed helpers.
components/mcp23x17/example/main/mcp23x17_example.cpp Updates example to create explicit device handle and use addressed helpers.
components/max1704x/example/main/max1704x_example.cpp Updates example to create explicit device handle and use addressed helpers.
components/lsm6dso/example/main/lsm6dso_example.cpp Updates example to create explicit device handle and use addressed helpers.
components/lp5817/example/main/lp5817_example.cpp Updates example to create explicit device handle and use addressed helpers.
components/kts1622/example/main/kts1622_example.cpp Updates example to create explicit device handle and use addressed helpers.
components/ina226/example/main/ina226_example.cpp Updates example to create explicit device handle and use addressed probe/read/write helpers.
components/icm42607/example/main/icm42607_example.cpp Updates example to create explicit device handle and use addressed helpers.
components/icm20948/example/main/icm20948_example.cpp Updates example to create explicit device handle and use addressed helpers.
components/drv2605/example/main/drv2605_example.cpp Updates example to create explicit device handle and use addressed helpers.
components/cst816/example/main/cst816_example.cpp Updates example to create explicit device handle and use addressed helpers.
components/chsc6x/example/main/chsc6x_example.cpp Updates example to create explicit device handle and use addressed helpers.
components/controller/example/main/controller_example.cpp Updates example to create explicit device handle and use addressed helpers.
components/bmi270/example/main/bmi270_example.cpp Updates example to create explicit device handle and use addressed helpers.
components/bm8563/example/main/bm8563_example.cpp Updates example to create explicit device handle and use addressed helpers.
components/bldc_motor/example/main/bldc_motor_example.cpp Updates example to create explicit device handle and use addressed helpers.
components/bldc_haptics/example/main/bldc_haptics_example.cpp Updates example to create explicit device handle and use addressed helpers.
components/aw9523/example/main/aw9523_example.cpp Updates example to create explicit device handle and use addressed helpers.
components/as5600/example/main/as5600_example.cpp Updates example to create explicit device handle and use addressed write_then_read helper.
components/adxl345/example/main/adxl345_example.cpp Updates example to create explicit device handle and use addressed helpers.
components/ads7138/example/main/ads7138_example.cpp Updates example to create explicit device handle and use addressed helpers.
components/ads1x15/example/main/ads1x15_example.cpp Updates example to create explicit device handle and use addressed helpers.
components/st25dv/example/main/st25dv_example.cpp Updates example to create explicit device handles for two ST25DV addresses and routes read/write via lambdas.

Comment thread components/i2c/src/i2c_slave.cpp Outdated
Comment thread components/st25dv/example/main/st25dv_example.cpp
Comment thread components/st25dv/example/main/st25dv_example.cpp
@finger563 finger563 self-assigned this May 28, 2026
@finger563 finger563 added enhancement New feature or request i2c labels May 28, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 68 out of 68 changed files in this pull request and generated 5 comments.

Comment thread components/i2c/include/i2c.hpp
Comment thread components/i2c/src/i2c_slave.cpp Outdated
Comment thread components/i2c/src/i2c_slave.cpp
Comment thread components/i2c/src/i2c_slave.cpp Outdated
Comment thread components/i2c/include/i2c_slave.hpp
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 72 out of 72 changed files in this pull request and generated 1 comment.

Comment thread doc/en/i2c.rst Outdated
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 81 out of 81 changed files in this pull request and generated 3 comments.

Comment thread components/i2c/example/main/i2c_example.cpp Outdated
Comment thread components/i2c/src/i2c_slave.cpp Outdated
Comment thread components/i2c/include/i2c_master_menu.hpp Outdated
finger563 and others added 3 commits May 29, 2026 11:42
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 81 out of 81 changed files in this pull request and generated 4 comments.

Comment thread components/i2c/include/i2c_menu.hpp
Comment thread components/i2c/include/i2c.hpp
Comment thread components/i2c/include/i2c.hpp
Comment thread components/i2c/src/i2c_slave.cpp Outdated
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 83 out of 83 changed files in this pull request and generated 1 comment.

Comment thread components/i2c/include/i2c_slave_menu.hpp
@finger563 finger563 merged commit e8442f8 into main May 29, 2026
107 of 108 checks passed
@finger563 finger563 deleted the feat/i2c-refactor branch May 29, 2026 18:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request i2c

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants