Merge branch 'change/remove_assert_in_esp_sleep_pd_config_v5.2' into 'release/v5.2'

change(esp_hw_support): warning in esp_sleep_pd_config instead of assert (v5.2)

See merge request espressif/esp-idf!41120
This commit is contained in:
Jiang Jiang Jian
2025-08-21 15:35:22 +08:00

View File

@@ -2042,17 +2042,33 @@ esp_err_t esp_sleep_pd_config(esp_sleep_pd_domain_t domain, esp_sleep_pd_option_
if (domain >= ESP_PD_DOMAIN_MAX || option > ESP_PD_OPTION_AUTO) { if (domain >= ESP_PD_DOMAIN_MAX || option > ESP_PD_OPTION_AUTO) {
return ESP_ERR_INVALID_ARG; return ESP_ERR_INVALID_ARG;
} }
esp_err_t err = ESP_OK;
portENTER_CRITICAL_SAFE(&s_config.lock); portENTER_CRITICAL_SAFE(&s_config.lock);
int refs = 0;
int refs = (option == ESP_PD_OPTION_ON) ? s_config.domain[domain].refs++ \ if (s_config.domain[domain].pd_option == ESP_PD_OPTION_AUTO) {
s_config.domain[domain].refs = (option == ESP_PD_OPTION_ON) ? 1 : 0;
s_config.domain[domain].pd_option = option;
} else {
if (option == ESP_PD_OPTION_AUTO) {
s_config.domain[domain].refs = 0;
s_config.domain[domain].pd_option = option;
} else {
refs = (option == ESP_PD_OPTION_ON) ? s_config.domain[domain].refs++ \
: (option == ESP_PD_OPTION_OFF) ? --s_config.domain[domain].refs \ : (option == ESP_PD_OPTION_OFF) ? --s_config.domain[domain].refs \
: s_config.domain[domain].refs; : s_config.domain[domain].refs;
if (refs == 0) { if (refs == 0) {
s_config.domain[domain].pd_option = option; s_config.domain[domain].pd_option = option;
} else if (refs < 0) {
s_config.domain[domain].refs = 0;
err = ESP_ERR_INVALID_STATE;
}
}
} }
portEXIT_CRITICAL_SAFE(&s_config.lock); portEXIT_CRITICAL_SAFE(&s_config.lock);
assert(refs >= 0); if (err == ESP_ERR_INVALID_STATE) {
return ESP_OK; ESP_LOGE(TAG, "Domain is already in ESP_PD_OPTION_OFF state, please check whether the domain pd_option is managed symmetrically.");
}
return err;
} }
/** /**