fix(rtc_timer): disable target before setting wakeup time to avoid intermediate states

This commit is contained in:
wuzhenghui
2026-07-22 12:55:52 +08:00
parent 10f8b195b0
commit 412bce6544
16 changed files with 180 additions and 14 deletions
@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2023-2025 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2023-2026 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
@@ -103,11 +103,23 @@ FORCE_INLINE_ATTR void rtc_timer_ll_alarm_intr_enable(lp_timer_dev_t *dev, uint8
*/
FORCE_INLINE_ATTR void rtc_timer_ll_set_wakeup_time(uint8_t timer_id, uint64_t ticks)
{
rtc_timer_ll_set_target_enable(&LP_TIMER, timer_id, false);
rtc_timer_ll_clear_alarm_intr_status(&LP_TIMER, timer_id);
rtc_timer_ll_set_alarm_target(&LP_TIMER, timer_id, ticks);
rtc_timer_ll_set_target_enable(&LP_TIMER, timer_id, true);
}
/**
* @brief Clear/disarm the wakeup timer alarm enabled by rtc_timer_ll_set_wakeup_time()
*
* @param timer_id Timer ID
*/
FORCE_INLINE_ATTR void rtc_timer_ll_clear_wakeup_time(uint8_t timer_id)
{
rtc_timer_ll_set_target_enable(&LP_TIMER, timer_id, false);
rtc_timer_ll_clear_alarm_intr_status(&LP_TIMER, timer_id);
}
/**
* @brief Get current RTC timer cycle count
* Note: For ESP32-P4, counter[timer_id] is used after snapshot