sleep: allow esp_sleep_get_wakeup_cause to be used for light sleep
This commit is contained in:
parent
6fbf585703
commit
09d0b8d47b
2 changed files with 7 additions and 3 deletions
|
@ -305,9 +305,9 @@ void system_deep_sleep(uint64_t time_in_us) __attribute__((noreturn, deprecated)
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Get the source which caused wakeup from sleep
|
* @brief Get the wakeup source which caused wakeup from sleep
|
||||||
*
|
*
|
||||||
* @return wakeup cause, or ESP_DEEP_SLEEP_WAKEUP_UNDEFINED if reset happened for reason other than deep sleep wakeup
|
* @return cause of wake up from last sleep (deep sleep or light sleep)
|
||||||
*/
|
*/
|
||||||
esp_sleep_wakeup_cause_t esp_sleep_get_wakeup_cause();
|
esp_sleep_wakeup_cause_t esp_sleep_get_wakeup_cause();
|
||||||
|
|
||||||
|
|
|
@ -81,6 +81,8 @@ static sleep_config_t s_config = {
|
||||||
.wakeup_triggers = 0
|
.wakeup_triggers = 0
|
||||||
};
|
};
|
||||||
|
|
||||||
|
bool s_light_sleep_wakeup = false;
|
||||||
|
|
||||||
/* Updating RTC_MEMORY_CRC_REG register via set_rtc_memory_crc()
|
/* Updating RTC_MEMORY_CRC_REG register via set_rtc_memory_crc()
|
||||||
is not thread-safe. */
|
is not thread-safe. */
|
||||||
static _lock_t lock_rtc_memory_crc;
|
static _lock_t lock_rtc_memory_crc;
|
||||||
|
@ -327,6 +329,8 @@ esp_err_t esp_light_sleep_start()
|
||||||
esp_err_t err = esp_light_sleep_inner(pd_flags,
|
esp_err_t err = esp_light_sleep_inner(pd_flags,
|
||||||
flash_enable_time_us, vddsdio_config);
|
flash_enable_time_us, vddsdio_config);
|
||||||
|
|
||||||
|
s_light_sleep_wakeup = true;
|
||||||
|
|
||||||
// FRC1 has been clock gated for the duration of the sleep, correct for that.
|
// FRC1 has been clock gated for the duration of the sleep, correct for that.
|
||||||
uint64_t rtc_ticks_at_end = rtc_time_get();
|
uint64_t rtc_ticks_at_end = rtc_time_get();
|
||||||
uint64_t frc_time_at_end = esp_timer_get_time();
|
uint64_t frc_time_at_end = esp_timer_get_time();
|
||||||
|
@ -590,7 +594,7 @@ esp_err_t esp_sleep_enable_uart_wakeup(int uart_num)
|
||||||
|
|
||||||
esp_sleep_wakeup_cause_t esp_sleep_get_wakeup_cause()
|
esp_sleep_wakeup_cause_t esp_sleep_get_wakeup_cause()
|
||||||
{
|
{
|
||||||
if (rtc_get_reset_reason(0) != DEEPSLEEP_RESET) {
|
if (rtc_get_reset_reason(0) != DEEPSLEEP_RESET && !s_light_sleep_wakeup) {
|
||||||
return ESP_SLEEP_WAKEUP_UNDEFINED;
|
return ESP_SLEEP_WAKEUP_UNDEFINED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue