esp32: Deactivate wakeup trigger after first wakeup

The timer wakeup function once activated cannot be disabled later using existing api. If user wants to use different wakeup sources after first sleep but it does not work. This change disables timer wakeup trigger in configuration that will be set into appropriate RTC registers in esp_light_sleep_start() function.

Added function esp_sleep_disable_wakeup_source() to deactivate wakeup trigger for selected source.
Updated documentation for this function in sleep_modes.rst file to pass make html.
Updated unit test to check this functionality for light sleep.
The test_sleep.c unit test is updated to add reliability for auto unit testing.

(TW#18952)
Closes https://github.com/espressif/esp-idf/issues/1677
This commit is contained in:
Alex Lisitsyn
2018-03-14 10:54:45 +05:00
parent 77eae33a7e
commit 2d90da0817
5 changed files with 86 additions and 4 deletions

View File

@@ -303,6 +303,22 @@ esp_err_t esp_sleep_enable_timer_wakeup(uint64_t time_in_us)
return ESP_OK;
}
esp_err_t esp_sleep_disable_timer_wakeup()
{
if (s_config.wakeup_triggers & RTC_TIMER_TRIG_EN) {
// The only timer wakeup trigger should be disabled, setup will
// be performed in rtc_sleep_start() which updates wakeup options
// in RTC peripheral registers
s_config.wakeup_triggers &= ~RTC_TIMER_TRIG_EN;
s_config.sleep_duration = 0;
}
else {
ESP_LOGE(TAG, "The timer wake-up trigger is not set.");
return ESP_ERR_INVALID_STATE;
}
return ESP_OK;
}
static void timer_wakeup_prepare()
{
uint32_t period = esp_clk_slowclk_cal_get();