diff --git a/cpu/native/include/periph_cpu.h b/cpu/native/include/periph_cpu.h index 75709f4720..668c877aee 100644 --- a/cpu/native/include/periph_cpu.h +++ b/cpu/native/include/periph_cpu.h @@ -32,6 +32,18 @@ extern "C" { #define CPUID_LEN (4U) #endif +/** + * @name Power mode configuration + */ +#ifndef PM_NUM_MODES +#define PM_NUM_MODES (1U) +#endif + +/** + * @brief We provide our own pm_off() function for the native CPU + */ +#define PROVIDES_PM_LAYERED_OFF + /* GPIO configuration only if the module is available (=Linux) */ #if defined(MODULE_PERIPH_GPIO_LINUX) || defined(DOXYGEN) #include diff --git a/cpu/native/periph/pm.c b/cpu/native/periph/pm.c index ccb1d8122c..2f4944ec68 100644 --- a/cpu/native/periph/pm.c +++ b/cpu/native/periph/pm.c @@ -36,7 +36,7 @@ #define ENABLE_DEBUG 0 #include "debug.h" -void pm_set_lowest(void) +static void _native_sleep(void) { _native_in_syscall++; /* no switching here */ real_pause(); @@ -48,6 +48,20 @@ void pm_set_lowest(void) } } +#if !defined(MODULE_PM_LAYERED) +void pm_set_lowest(void) +{ + _native_sleep(); +} +#endif + +void pm_set(unsigned mode) +{ + if (mode == 0) { + _native_sleep(); + } +} + void pm_off(void) { puts("\nnative: exiting"); diff --git a/sys/include/pm_layered.h b/sys/include/pm_layered.h index c9e4233fa9..4cba7ee6a0 100644 --- a/sys/include/pm_layered.h +++ b/sys/include/pm_layered.h @@ -34,6 +34,7 @@ #ifndef PM_LAYERED_H #define PM_LAYERED_H +#include #include "periph_cpu.h" #ifdef __cplusplus