Merge branch 'fix/add_sleep_duration_check_for_timer_wakeup' into 'master'

fix(esp_hw_support): add timer wakeup sleep duration check

Closes IDFGH-14485

See merge request espressif/esp-idf!36793
This commit is contained in:
Wu Zheng Hui
2025-02-13 10:42:58 +08:00
24 changed files with 119 additions and 46 deletions
@@ -57,6 +57,10 @@ __attribute__((unused)) static struct timeval tv_start, tv_stop;
#if SOC_LIGHT_SLEEP_SUPPORTED
TEST_CASE("wake up from light sleep using timer", "[lightsleep]")
{
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);
gettimeofday(&tv_start, NULL);
esp_light_sleep_start();