Skip to content

fix(drivers): migrate I2C drivers to new esp_driver_i2c API#23

Closed
Ghost64847 wants to merge 4 commits intoHighCodeh:mainfrom
Ghost64847:update-c5-sdkconfig
Closed

fix(drivers): migrate I2C drivers to new esp_driver_i2c API#23
Ghost64847 wants to merge 4 commits intoHighCodeh:mainfrom
Ghost64847:update-c5-sdkconfig

Conversation

@Ghost64847
Copy link
Copy Markdown

@Ghost64847 Ghost64847 commented Mar 23, 2026

Summary

Migrates all I2C drivers from the deprecated driver/i2c.h API to the new driver/i2c_master.h API introduced in ESP-IDF v5.x.

Changes

components/Drivers/i2c_init/

  • i2c_init.c: Replaced i2c_config_t + i2c_param_config() + i2c_driver_install() with i2c_master_bus_config_t + i2c_new_master_bus(). The bus handle is stored globally and exposed via i2c_get_bus_handle().
    • i2c_init.h: Added #include "driver/i2c_master.h" and declared i2c_get_bus_handle().

components/Drivers/bq25896/

  • bq25896.h: Updated include from driver/i2c.h to driver/i2c_master.h.
    • bq25896.c: Replaced legacy i2c_cmd_link_create() / i2c_master_cmd_begin() pattern with i2c_master_bus_add_device() + i2c_master_transmit_receive() / i2c_master_transmit().

components/Drivers/pn7150/

  • pn7150.h: Updated include from driver/i2c.h to driver/i2c_master.h + i2c_init.h.
    • pn7150.c: Replaced all i2c_cmd_link_create() patterns with new transmit API. pn7150_i2c_init() now registers device on the shared bus via i2c_master_bus_add_device().

components/Core/kernel.c

  • Removed direct #include "driver/i2c.h" (now handled transitively via i2c_init.h).

Testing

Compiled successfully for ESP32-P4 with ESP-IDF v5.5.3. Confirmed working on hardware via serial monitor - I2CInit: I2C mestre inicializado com sucesso no I2C_NUM_0 usando o novo driver. appears at boot.

Related

  • Resolves build error: error: unknown type name 'i2c_config_t' caused by including driver/i2c_master.h while using legacy API symbols.

@Ghost64847 Ghost64847 force-pushed the update-c5-sdkconfig branch from f5241c8 to 7abde6d Compare March 23, 2026 14:44
Replace deprecated driver/i2c.h with driver/i2c_master.h across all
I2C-related components to fix build errors on ESP-IDF v5.5.3.

- i2c_init: use i2c_new_master_bus() and expose i2c_get_bus_handle()
- bq25896: register device via i2c_master_bus_add_device(), replace
  cmd_link pattern with i2c_master_transmit / transmit_receive
- pn7150: same migration as bq25896; pn7150_i2c_init now reuses
  the global bus handle instead of re-initializing the bus
- kernel: remove direct include of deprecated driver/i2c.h
@Ghost64847 Ghost64847 changed the title build(sdkconfig): update c5 and p4 sdkconfigs for 5.5.3 fix(drivers): migrate I2C drivers to new esp_driver_i2c API Mar 23, 2026
@anarchyysm
Copy link
Copy Markdown
Member

anarchyysm commented Mar 24, 2026

#22
just a reference to the message that a sent a couple of second

@anarchyysm anarchyysm closed this Mar 24, 2026
@Ghost64847 Ghost64847 deleted the update-c5-sdkconfig branch March 24, 2026 22:56
@Ghost64847
Copy link
Copy Markdown
Author

Additionally, I have a suggestion to use the esp_lvgl_adapter component (https://components.espressif.com/components/espressif/esp_lvgl_adapter/versions/0.4.1/readme) and its dependencies, which would facilitate support for more features, such as multilingual support. I hope you can consider it. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants