From ed9f740edde87fb69ed2a214ed6348024088fa2f Mon Sep 17 00:00:00 2001 From: Benjamin Valentin Date: Sat, 2 Apr 2022 21:01:42 +0200 Subject: [PATCH] examples/lorawan: move enabling of sleep modes to C code --- examples/lorawan/Makefile | 4 ---- examples/lorawan/main.c | 11 +++++++++++ 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/examples/lorawan/Makefile b/examples/lorawan/Makefile index 10438ba181..08bb04ecd3 100644 --- a/examples/lorawan/Makefile +++ b/examples/lorawan/Makefile @@ -53,10 +53,6 @@ else ifeq (abp,$(ACTIVATION_MODE)) CFLAGS += -DUSE_ABP endif -# Enable deep sleep power mode (e.g. STOP mode on STM32) which -# in general provides RAM retention after wake-up. -CFLAGS += -DPM_BLOCKER_INITIAL=0x00000001 - # Comment this out to disable code in RIOT that does safety checking # which is not needed in a production environment but helps in the # development process: diff --git a/examples/lorawan/main.c b/examples/lorawan/main.c index 34ca9f929f..7bb6d0671c 100644 --- a/examples/lorawan/main.c +++ b/examples/lorawan/main.c @@ -27,6 +27,7 @@ #include "thread.h" #include "fmt.h" +#include "periph/pm.h" #if IS_USED(MODULE_PERIPH_RTC) #include "periph/rtc.h" #else @@ -148,6 +149,16 @@ int main(void) puts("LoRaWAN Class A low-power application"); puts("====================================="); + /* + * Enable deep sleep power mode (e.g. STOP mode on STM32) which + * in general provides RAM retention after wake-up. + */ +#if IS_USED(MODULE_PM_LAYERED) + for (unsigned i = 1; i < PM_NUM_MODES; ++i) { + pm_unblock(i); + } +#endif + /* Initialize the radio driver */ #if IS_USED(MODULE_SX127X) sx127x_setup(&sx127x, &sx127x_params[0], 0);