From 2fc85ca5a176efa54f580ed6c11768a0757024fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A0=D1=83=D1=81=D0=BB=D0=B0=D0=BD=20=D0=A3=D1=81?= Date: Thu, 9 Jul 2026 17:34:57 +0500 Subject: [PATCH] bugfix: fix hardcoded clk_source --- i2cdev.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/i2cdev.c b/i2cdev.c index 5c106b6..61b4baa 100644 --- a/i2cdev.c +++ b/i2cdev.c @@ -423,13 +423,19 @@ static esp_err_t i2c_setup_port(i2c_dev_t *dev) // dev is non-const to update de .i2c_port = dev->port, .sda_io_num = sda_pin, .scl_io_num = scl_pin, - .clk_source = I2C_CLK_SRC_DEFAULT, .glitch_ignore_cnt = 7, .flags.enable_internal_pullup = (sda_pullup || scl_pullup), // Bus speed is not set here. It's per-device or a global target for the bus can be set // if desired, but i2c_master supports per-device speeds. }; +#if SOC_LP_I2C_SUPPORTED + bus_config.clk_source = dev->port == (i2c_port_num_t)LP_I2C_NUM_0 + ? LP_I2C_SCLK_DEFAULT + : I2C_CLK_SRC_DEFAULT; +#else + bus_config.clk_source = I2C_CLK_SRC_DEFAULT; +#endif res = i2c_new_master_bus(&bus_config, &port_state->bus_handle); if (res == ESP_OK) {