Merge branch 'bugfix/fix_light_sleep_enter_error' into 'master'

sleep: fix enter light sleep mode error

See merge request sdk/ESP8266_RTOS_SDK!1109
This commit is contained in:
Dong Heng
2019-09-23 11:06:44 +08:00

View File

@ -162,11 +162,16 @@ void esp_sleep_start(void)
uart_tx_wait_idle(0);
uart_tx_wait_idle(1);
int slept = 0;
int cpu_wait = 1;
pm_soc_clk_t clk;
const esp_irqflag_t irqflag = soc_save_local_irq();
const uint32_t wdevflag = save_local_wdev();
if (s_lock_cnt) {
cpu_wait = 0;
goto exit;
}
save_soc_clk(&clk);
const uint32_t sleep_us = min_sleep_us(&clk);
@ -184,13 +189,14 @@ void esp_sleep_start(void)
update_soc_clk(&clk, sleep_us);
slept = 1;
cpu_wait = 0;
}
}
exit:
restore_local_wdev(wdevflag);
soc_restore_local_irq(irqflag);
if (!slept)
if (cpu_wait)
soc_wait_int();
}