mirror of
https://github.com/espressif/esp-idf.git
synced 2025-09-30 19:19:21 +00:00
fix(esp_hw_support): add timer wakeup sleep duration check
Closes https://github.com/espressif/esp-idf/issues/15255
This commit is contained in:
@@ -19,6 +19,7 @@
|
||||
#include "soc/rtc.h" // for wakeup trigger defines
|
||||
#include "soc/rtc_periph.h" // for read rtc registers directly (cause)
|
||||
#include "soc/soc.h" // for direct register read macros
|
||||
#include "esp_clk_tree.h"
|
||||
#include "esp_newlib.h"
|
||||
#include "test_utils.h"
|
||||
#include "sdkconfig.h"
|
||||
@@ -26,6 +27,7 @@
|
||||
#include "esp_rom_sys.h"
|
||||
#include "esp_timer.h"
|
||||
#include "esp_private/esp_clk.h"
|
||||
#include "esp_private/esp_clk_tree_common.h"
|
||||
#include "esp_private/uart_private.h"
|
||||
#include "esp_random.h"
|
||||
#include "nvs_flash.h"
|
||||
@@ -57,6 +59,10 @@ static void deep_sleep_task(void *arg)
|
||||
|
||||
static void do_deep_sleep_from_app_cpu(void)
|
||||
{
|
||||
TEST_ASSERT_EQUAL(ESP_ERR_INVALID_ARG, esp_sleep_enable_timer_wakeup(UINT64_MAX));
|
||||
uint64_t lp_timer_max_allowed_time_in_us = ((BIT64(SOC_LP_TIMER_BIT_WIDTH_LO + SOC_LP_TIMER_BIT_WIDTH_HI) - 1) / esp_clk_tree_lp_slow_get_freq_hz(ESP_CLK_TREE_SRC_FREQ_PRECISION_APPROX)) * MHZ;
|
||||
TEST_ASSERT_EQUAL(ESP_OK, esp_sleep_enable_timer_wakeup(lp_timer_max_allowed_time_in_us));
|
||||
TEST_ASSERT_EQUAL(ESP_ERR_INVALID_ARG, esp_sleep_enable_timer_wakeup(lp_timer_max_allowed_time_in_us + 1));
|
||||
esp_sleep_enable_timer_wakeup(2000000);
|
||||
|
||||
xTaskCreatePinnedToCore(&deep_sleep_task, "ds", 2048, NULL, 5, NULL, 1);
|
||||
|
Reference in New Issue
Block a user