diff --git a/cpu/msp430-common/lpm_cpu.c b/cpu/msp430-common/lpm_cpu.c index a5815912f..7346d96fc 100644 --- a/cpu/msp430-common/lpm_cpu.c +++ b/cpu/msp430-common/lpm_cpu.c @@ -20,9 +20,10 @@ * @} */ +#include #include #if (__GNUC__ >= 4) && (__GNUC_MINOR__ > 5) - #include // MSP430-gcc compiler instrinsics +#include // MSP430-gcc compiler instrinsics #endif #include "board.h" @@ -47,16 +48,9 @@ enum lpm_mode lpm_set(enum lpm_mode target) /* ensure that interrupts are enabled before going to sleep, or we're bound to hang our MCU! */ - if (target != LPM_ON) { - if ((__read_status_register() & GIE) == 0) { - printf("WARNING: entering low-power mode with interrupts disabled!\n"); - printf(" Forcing GIE bit to 1!\n\n"); - __bis_status_register(GIE); - } - } + assert((target == LPM_ON) || (__read_status_register() & GIE)); - switch (target) - { + switch (target) { case LPM_ON: /* fully running MCU */ __bic_status_register(CPUOFF | OSCOFF | SCG0 | SCG1); @@ -85,8 +79,8 @@ enum lpm_mode lpm_set(enum lpm_mode target) /* all blocks off */ break; default: - printf("ERROR: trying to set an invalid low-power mode!\n"); - printf(" Operation aborted.\n\n"); + assert(0); /* abort if NDEBUG is not defined */ + break; } return last_mode;