mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
Merge branch 'refactor/improve_flash_power_down_logic_backport_v4.4' into 'release/v4.4'
system/sleep: improve flash power down logic(backport v4.4) See merge request espressif/esp-idf!18587
This commit is contained in:
commit
b085cd2821
@ -637,6 +637,22 @@ static esp_err_t esp_light_sleep_inner(uint32_t pd_flags,
|
|||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* vddsdio is used for power supply of spi flash
|
||||||
|
*
|
||||||
|
* pd flash via menuconfig | pd flash via `esp_sleep_pd_config` | result
|
||||||
|
* ---------------------------------------------------------------------------------------------------
|
||||||
|
* 0 | 0 | no pd flash
|
||||||
|
* x | 1 | pd flash with relaxed conditions(force_pd)
|
||||||
|
* 1 | 0 | pd flash with strict conditions(safe_pd)
|
||||||
|
*/
|
||||||
|
static inline bool can_power_down_vddsdio(const uint32_t vddsdio_pd_sleep_duration)
|
||||||
|
{
|
||||||
|
bool force_pd = !(s_config.wakeup_triggers & RTC_TIMER_TRIG_EN) || (s_config.sleep_duration > vddsdio_pd_sleep_duration);
|
||||||
|
bool safe_pd = (s_config.wakeup_triggers == RTC_TIMER_TRIG_EN) && (s_config.sleep_duration > vddsdio_pd_sleep_duration);
|
||||||
|
return (s_config.pd_options[ESP_PD_DOMAIN_VDDSDIO] == ESP_PD_OPTION_OFF) ? force_pd : safe_pd;
|
||||||
|
}
|
||||||
|
|
||||||
esp_err_t esp_light_sleep_start(void)
|
esp_err_t esp_light_sleep_start(void)
|
||||||
{
|
{
|
||||||
s_config.ccount_ticks_record = cpu_ll_get_cycle_count();
|
s_config.ccount_ticks_record = cpu_ll_get_cycle_count();
|
||||||
@ -712,7 +728,7 @@ esp_err_t esp_light_sleep_start(void)
|
|||||||
flash_enable_time_us + LIGHT_SLEEP_MIN_TIME_US + s_config.sleep_time_adjustment
|
flash_enable_time_us + LIGHT_SLEEP_MIN_TIME_US + s_config.sleep_time_adjustment
|
||||||
+ rtc_time_slowclk_to_us(RTC_MODULE_SLEEP_PREPARE_CYCLES, s_config.rtc_clk_cal_period));
|
+ rtc_time_slowclk_to_us(RTC_MODULE_SLEEP_PREPARE_CYCLES, s_config.rtc_clk_cal_period));
|
||||||
|
|
||||||
if (s_config.sleep_duration > vddsdio_pd_sleep_duration) {
|
if (can_power_down_vddsdio(vddsdio_pd_sleep_duration)) {
|
||||||
if (s_config.sleep_time_overhead_out < flash_enable_time_us) {
|
if (s_config.sleep_time_overhead_out < flash_enable_time_us) {
|
||||||
s_config.sleep_time_adjustment += flash_enable_time_us;
|
s_config.sleep_time_adjustment += flash_enable_time_us;
|
||||||
}
|
}
|
||||||
@ -1322,9 +1338,7 @@ static uint32_t get_power_down_flags(void)
|
|||||||
* value of this field.
|
* value of this field.
|
||||||
*/
|
*/
|
||||||
if (s_config.pd_options[ESP_PD_DOMAIN_VDDSDIO] == ESP_PD_OPTION_AUTO) {
|
if (s_config.pd_options[ESP_PD_DOMAIN_VDDSDIO] == ESP_PD_OPTION_AUTO) {
|
||||||
#ifdef CONFIG_ESP_SLEEP_POWER_DOWN_FLASH
|
#ifndef CONFIG_ESP_SLEEP_POWER_DOWN_FLASH
|
||||||
s_config.pd_options[ESP_PD_DOMAIN_VDDSDIO] = ESP_PD_OPTION_OFF;
|
|
||||||
#else
|
|
||||||
s_config.pd_options[ESP_PD_DOMAIN_VDDSDIO] = ESP_PD_OPTION_ON;
|
s_config.pd_options[ESP_PD_DOMAIN_VDDSDIO] = ESP_PD_OPTION_ON;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user