From 424a72cba667f4895713021f6245d992be081414 Mon Sep 17 00:00:00 2001 From: Sudeep Mohanty Date: Tue, 13 Jun 2023 11:12:23 +0200 Subject: [PATCH] lp-core: Added support for abort() function on the LP core This commit adds support for the abort() function on the LP core. --- .../lp_core/lp_core/include/ulp_lp_core_utils.h | 6 ++++++ components/ulp/lp_core/lp_core/lp_core_utils.c | 15 +++++++++++++++ 2 files changed, 21 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 ce47034df65..00788397312 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 @@ -11,6 +11,7 @@ extern "C" { #endif #include +#include /** @@ -53,6 +54,11 @@ void ulp_lp_core_delay_cycles(uint32_t cycles); */ __attribute__((__noreturn__)) void ulp_lp_core_halt(void); +/** + * @brief The LP core puts itself to sleep and disables all wakeup sources. + */ +__attribute__((__noreturn__)) void ulp_lp_core_stop_lp_core(void); + #ifdef __cplusplus } #endif 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 e04b5c91155..cfdc68d4f4f 100644 --- a/components/ulp/lp_core/lp_core/lp_core_utils.c +++ b/components/ulp/lp_core/lp_core/lp_core_utils.c @@ -63,3 +63,18 @@ void ulp_lp_core_halt(void) while(1); } + +void ulp_lp_core_stop_lp_core(void) +{ + /* Disable wake-up source and put lp core to sleep */ + REG_SET_FIELD(PMU_LP_CPU_PWR1_REG, PMU_LP_CPU_WAKEUP_EN, 0); + REG_SET_FIELD(PMU_LP_CPU_PWR1_REG, PMU_LP_CPU_SLEEP_REQ, 1); +} + +void __attribute__((noreturn)) abort(void) +{ + /* Stop the LP Core */ + ulp_lp_core_stop_lp_core(); + + while (1); +}