feat(i2c): Update i2c to default to new driver, and update driver to be more backwards compatible to facilitate upgrade#621
Merged
Merged
Conversation
…be more backwards compatible to facilitate upgrade
|
✅Static analysis result - no issues found! ✅ |
Contributor
There was a problem hiding this comment.
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
i2ccomponent 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
I2cSlaveDeviceto 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. |
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Motivation and Context
As of esp-idf v6.0 the older
driver/i2c.hfrom 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.hppand isespp::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?
i2c/exampleusing v6.0t-deck/exampleusing v6.0Screenshots (if appropriate, e.g. schematic, board, console logs, lab pictures):
Types of changes
Checklist:
Software
.github/workflows/build.ymlfile to add my new test to the automated cloud build github action.