mirror of
https://github.com/espressif/esp-idf.git
synced 2025-09-30 19:19:21 +00:00
fix(i2c): Enhance lp clock source and avoid deadlock,
Closes https://github.com/espressif/esp-idf/issues/14908, Closes https://github.com/espressif/esp-idf/issues/14906
This commit is contained in:
@@ -932,6 +932,19 @@ esp_err_t i2c_new_master_bus(const i2c_master_bus_config_t *bus_config, i2c_mast
|
||||
}
|
||||
#if SOC_LP_I2C_SUPPORTED
|
||||
else {
|
||||
|
||||
soc_periph_lp_i2c_clk_src_t clk_srcs[] = SOC_LP_I2C_CLKS;
|
||||
bool lp_clock_match = false;
|
||||
for (int i = 0; i < sizeof(clk_srcs) / sizeof(clk_srcs[0]); i++) {
|
||||
if ((int)clk_srcs[i] == (int)i2c_master->base->clk_src) {
|
||||
/* Clock source matches. Override the source clock type with the user configured value */
|
||||
lp_clock_match = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
ESP_GOTO_ON_FALSE(lp_clock_match, ESP_ERR_NOT_SUPPORTED, err, TAG, "the clock source does not support lp i2c, please check");
|
||||
|
||||
LP_I2C_SRC_CLK_ATOMIC() {
|
||||
lp_i2c_ll_set_source_clk(hal->dev, i2c_master->base->clk_src);
|
||||
}
|
||||
|
Reference in New Issue
Block a user