mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
esp_pm: fix an issue and add an interface (backport to v4.3)
This commit is contained in:
parent
693aaef039
commit
bd03a0e66a
@ -63,6 +63,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
|
||||
|
@ -323,6 +323,31 @@ 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;
|
||||
}
|
||||
|
||||
#if CONFIG_IDF_TARGET_ESP32
|
||||
esp_pm_config_esp32_t* config = (esp_pm_config_esp32_t*) vconfig;
|
||||
#elif CONFIG_IDF_TARGET_ESP32S2
|
||||
esp_pm_config_esp32s2_t* config = (esp_pm_config_esp32s2_t*) vconfig;
|
||||
#elif CONFIG_IDF_TARGET_ESP32S3
|
||||
esp_pm_config_esp32s3_t* config = (esp_pm_config_esp32s3_t*) vconfig;
|
||||
#elif CONFIG_IDF_TARGET_ESP32C3
|
||||
esp_pm_config_esp32c3_t* config = (esp_pm_config_esp32c3_t*) vconfig;
|
||||
#endif
|
||||
|
||||
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 */
|
||||
|
@ -702,6 +702,7 @@ esp_err_t esp_light_sleep_start(void)
|
||||
esp_clk_slowclk_cal_set(s_config.rtc_clk_cal_period);
|
||||
#else
|
||||
s_config.rtc_clk_cal_period = rtc_clk_cal(RTC_CAL_RTC_MUX, RTC_CLK_SRC_CAL_CYCLES);
|
||||
esp_clk_slowclk_cal_set(s_config.rtc_clk_cal_period);
|
||||
#endif
|
||||
|
||||
/*
|
||||
|
Loading…
Reference in New Issue
Block a user