From 7c3bfb980e5a35045bc9ae45c22a10f2c3b0886f Mon Sep 17 00:00:00 2001 From: Benjamin Valentin Date: Tue, 29 Mar 2022 18:12:32 +0200 Subject: [PATCH] cpu/samd5x: allow to block IDLE mode Make it possible to prevent the CPU clock from stopping. --- cpu/samd5x/include/periph_cpu.h | 6 +++++- cpu/samd5x/periph/pm.c | 4 +++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/cpu/samd5x/include/periph_cpu.h b/cpu/samd5x/include/periph_cpu.h index ce20777e76..43ad25e499 100644 --- a/cpu/samd5x/include/periph_cpu.h +++ b/cpu/samd5x/include/periph_cpu.h @@ -53,7 +53,11 @@ extern "C" { * @name Power mode configuration * @{ */ -#define PM_NUM_MODES (3) +#define PM_NUM_MODES 4 /**< Backup, Hibernate, Standby, Idle */ + +#ifndef PM_BLOCKER_INITIAL +#define PM_BLOCKER_INITIAL 0x00010101 /**< Block all modes but Idle */ +#endif /** @} */ /** diff --git a/cpu/samd5x/periph/pm.c b/cpu/samd5x/periph/pm.c index e06b3c6dd6..e8db91cb79 100644 --- a/cpu/samd5x/periph/pm.c +++ b/cpu/samd5x/periph/pm.c @@ -45,11 +45,13 @@ void pm_set(unsigned mode) _mode = PM_SLEEPCFG_SLEEPMODE_STANDBY; deep = 1; break; - default: /* Falls through */ case 3: DEBUG_PUTS("pm_set(): setting IDLE2 mode."); _mode = PM_SLEEPCFG_SLEEPMODE_IDLE2; break; + default: + /* no sleep */ + return; } /* write sleep configuration */