3030#include "hal/rtc_io_hal.h"
3131#include "hal/clk_tree_hal.h"
3232
33+ #if SOC_SLEEP_SYSTIMER_STALL_WORKAROUND
34+ #include "hal/systimer_ll.h"
35+ #endif
36+
3337#if SOC_PM_SUPPORT_PMU_MODEM_STATE
3438#include "esp_private/pm_impl.h"
3539#endif
@@ -870,11 +874,6 @@ static esp_err_t IRAM_ATTR esp_sleep_start(uint32_t pd_flags, esp_sleep_mode_t m
870874 }
871875 }
872876
873- #if CONFIG_ESP_SLEEP_SYSTIMER_STALL_WORKAROUND
874- if (!(pd_flags & RTC_SLEEP_PD_XTAL )) {
875- rtc_sleep_systimer_enable (false);
876- }
877- #endif
878877
879878 if (should_skip_sleep ) {
880879 result = ESP_ERR_SLEEP_REJECT ;
@@ -883,9 +882,9 @@ static esp_err_t IRAM_ATTR esp_sleep_start(uint32_t pd_flags, esp_sleep_mode_t m
883882#endif
884883 } else {
885884#if CONFIG_ESP_SLEEP_DEBUG
886- if (s_sleep_ctx != NULL ) {
887- s_sleep_ctx -> wakeup_triggers = s_config .wakeup_triggers ;
888- }
885+ if (s_sleep_ctx != NULL ) {
886+ s_sleep_ctx -> wakeup_triggers = s_config .wakeup_triggers ;
887+ }
889888#endif
890889 if (deep_sleep ) {
891890#if !SOC_GPIO_SUPPORT_HOLD_SINGLE_IO_IN_DSLP
@@ -913,6 +912,13 @@ static esp_err_t IRAM_ATTR esp_sleep_start(uint32_t pd_flags, esp_sleep_mode_t m
913912 result = rtc_deep_sleep_start (s_config .wakeup_triggers , reject_triggers );
914913#endif
915914 } else {
915+ #if SOC_SLEEP_SYSTIMER_STALL_WORKAROUND
916+ if (!(pd_flags & RTC_SLEEP_PD_XTAL )) {
917+ for (uint32_t counter_id = 0 ; counter_id < SOC_SYSTIMER_COUNTER_NUM ; ++ counter_id ) {
918+ systimer_ll_enable_counter (& SYSTIMER , counter_id , false);
919+ }
920+ }
921+ #endif
916922 /* Cache Suspend 1: will wait cache idle in cache suspend */
917923 suspend_cache ();
918924 /* On esp32c6, only the lp_aon pad hold function can only hold the GPIO state in the active mode.
@@ -977,13 +983,14 @@ static esp_err_t IRAM_ATTR esp_sleep_start(uint32_t pd_flags, esp_sleep_mode_t m
977983#endif
978984 /* Cache Resume 1: Resume cache for continue running*/
979985 resume_cache ();
980- }
981-
982- #if CONFIG_ESP_SLEEP_SYSTIMER_STALL_WORKAROUND
986+ #if SOC_SLEEP_SYSTIMER_STALL_WORKAROUND
983987 if (!(pd_flags & RTC_SLEEP_PD_XTAL )) {
984- rtc_sleep_systimer_enable (true);
988+ for (uint32_t counter_id = 0 ; counter_id < SOC_SYSTIMER_COUNTER_NUM ; ++ counter_id ) {
989+ systimer_ll_enable_counter (& SYSTIMER , counter_id , true);
990+ }
985991 }
986992#endif
993+ }
987994 }
988995#if CONFIG_ESP_SLEEP_CACHE_SAFE_ASSERTION
989996 if (pd_flags & RTC_SLEEP_PD_VDDSDIO ) {
0 commit comments