mirror of
https://github.com/espressif/esp-idf.git
synced 2025-10-03 10:30:58 +02:00
Merge branch 'change/remove_assert_in_esp_sleep_pd_config_v5.4' into 'release/v5.4'
change(esp_hw_support): warning in esp_sleep_pd_config instead of assert (v5.4) See merge request espressif/esp-idf!41118
This commit is contained in:
@@ -2250,17 +2250,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;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char* s_submode2str[] = {
|
static const char* s_submode2str[] = {
|
||||||
|
Reference in New Issue
Block a user