mirror of
https://github.com/espressif/esp-idf.git
synced 2025-10-03 10:30:58 +02:00
change(esp_hw_support): warning in esp_sleep_pd_config instead of assert
Closes https://github.com/espressif/esp-idf/issues/16872#event-18649904083
This commit is contained in:
@@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Reference in New Issue
Block a user