Merge branch 'bugfix/fix_some_pm_issue_v4.2' into 'release/v4.2'

esp_pm: add an interface to get pm configuration (backport to v4.2)

See merge request espressif/esp-idf!13124
pull/9609/head
Jiang Jiang Jian 2021-05-10 03:45:55 +00:00
commit d29cce7f0a
3 zmienionych plików z 42 dodań i 0 usunięć

Wyświetl plik

@ -237,6 +237,23 @@ esp_err_t esp_pm_configure(const void* vconfig)
return ESP_OK;
}
esp_err_t esp_pm_get_configuration(void* vconfig)
{
if (vconfig == NULL) {
return ESP_ERR_INVALID_ARG;
}
esp_pm_config_esp32_t* config = (esp_pm_config_esp32_t*) vconfig;
portENTER_CRITICAL(&s_switch_lock);
config->light_sleep_enable = s_light_sleep_en;
config->max_freq_mhz = s_cpu_freq_by_mode[PM_MODE_CPU_MAX].freq_mhz;
config->min_freq_mhz = s_cpu_freq_by_mode[PM_MODE_APB_MIN].freq_mhz;
portEXIT_CRITICAL(&s_switch_lock);
return ESP_OK;
}
static pm_mode_t IRAM_ATTR get_lowest_allowed_mode(void)
{
/* TODO: optimize using ffs/clz */

Wyświetl plik

@ -232,6 +232,23 @@ esp_err_t esp_pm_configure(const void* vconfig)
return ESP_OK;
}
esp_err_t esp_pm_get_configuration(void* vconfig)
{
if (vconfig == NULL) {
return ESP_ERR_INVALID_ARG;
}
esp_pm_config_esp32s2_t* config = (esp_pm_config_esp32s2_t*) vconfig;
portENTER_CRITICAL(&s_switch_lock);
config->light_sleep_enable = s_light_sleep_en;
config->max_freq_mhz = s_cpu_freq_by_mode[PM_MODE_CPU_MAX].freq_mhz;
config->min_freq_mhz = s_cpu_freq_by_mode[PM_MODE_APB_MIN].freq_mhz;
portEXIT_CRITICAL(&s_switch_lock);
return ESP_OK;
}
static pm_mode_t IRAM_ATTR get_lowest_allowed_mode(void)
{
/* TODO: optimize using ffs/clz */

Wyświetl plik

@ -59,6 +59,14 @@ typedef enum {
*/
esp_err_t esp_pm_configure(const void* config);
/**
* @brief Get implementation-specific power management configuration
* @param config pointer to implementation-specific configuration structure (e.g. esp_pm_config_esp32)
* @return
* - ESP_OK on success
* - ESP_ERR_INVALID_ARG if the pointer is null
*/
esp_err_t esp_pm_get_configuration(void* config);
/**
* @brief Opaque handle to the power management lock