From 7e868599b1ce5ea06340e146a67326331b1a8ad7 Mon Sep 17 00:00:00 2001 From: Konstantin Kondrashov Date: Wed, 16 Apr 2025 09:46:29 +0300 Subject: [PATCH] fix(ulp): Fix accumulation of wakeup cause bits in ULP Closes https://github.com/espressif/esp-idf/issues/15794 --- components/ulp/lp_core/lp_core/include/ulp_lp_core_utils.h | 2 ++ components/ulp/lp_core/lp_core/lp_core_utils.c | 1 + 2 files changed, 3 insertions(+) diff --git a/components/ulp/lp_core/lp_core/include/ulp_lp_core_utils.h b/components/ulp/lp_core/lp_core/include/ulp_lp_core_utils.h index bee3d6c574..96e61359df 100644 --- a/components/ulp/lp_core/lp_core/include/ulp_lp_core_utils.h +++ b/components/ulp/lp_core/lp_core/include/ulp_lp_core_utils.h @@ -16,6 +16,8 @@ extern "C" { /** * @brief Traverse all possible wake-up sources and update the wake-up cause so that * ulp_lp_core_get_wakeup_cause can obtain the bitmap of the wake-up reasons. + * @note Do not call it from user ULP programs because it will clear the wake-up cause bits + * which were set at ULP startup in lp_core_startup(). */ void ulp_lp_core_update_wakeup_cause(void); diff --git a/components/ulp/lp_core/lp_core/lp_core_utils.c b/components/ulp/lp_core/lp_core/lp_core_utils.c index 4004cba9f6..ffb8f1808f 100644 --- a/components/ulp/lp_core/lp_core/lp_core_utils.c +++ b/components/ulp/lp_core/lp_core/lp_core_utils.c @@ -24,6 +24,7 @@ static uint32_t lp_wakeup_cause = 0; void ulp_lp_core_update_wakeup_cause(void) { + lp_wakeup_cause = 0; if ((REG_GET_FIELD(PMU_LP_CPU_PWR1_REG, PMU_LP_CPU_WAKEUP_EN) & ULP_LP_CORE_WAKEUP_SOURCE_HP_CPU) \ && (pmu_ll_lp_get_interrupt_raw(&PMU) & PMU_HP_SW_TRIGGER_INT_RAW)) { lp_wakeup_cause |= ULP_LP_CORE_WAKEUP_SOURCE_HP_CPU;