Minimal version of mBuino Sleep

This is a cut down version of mBuino_Sleep that doesn't control any IO lines.

This version should work fine on any NXP LPC11Uxx CPUs although you will need to check the external pin pullup/down status, any conflicts between external and internal pulls will increase power usage.

If using this version on an mBuino ensure you disable the pullup on P0_3 (on by default for any unconfigured GPIO lines) and turn all the LEDs off before entering sleep. Failing to do so will increase the sleep mode power draw.

See mBuino_Sleep for usage details.

Files at this revision

API Documentation at this revision

Sun Sep 28 09:24:32 2014 +0000
Commit message:
Added watchdog modes

Changed in this revision

mBuinoSleep.cpp Show annotated file Show diff for this revision Revisions of this file
mBuinoSleep.h Show annotated file Show diff for this revision Revisions of this file
diff -r 219e1147c6fa -r 9c5cd0f7aa8a mBuinoSleep.cpp
--- a/mBuinoSleep.cpp	Mon Sep 22 09:15:52 2014 +0000
+++ b/mBuinoSleep.cpp	Sun Sep 28 09:24:32 2014 +0000
@@ -15,13 +15,19 @@
         case DeepSleep:
-        case PowerDown: {
-            if (mode == PowerDown)
+        case PowerDown:
+        case PowerDownWD:
+        case DeepSleepWD: {
+            if ((mode == PowerDown) || (mode == PowerDownWD))
                 LPC_PMU->PCON = 0x2;
                 LPC_PMU->PCON = 0x1;
             LPC_SYSCON->PDSLEEPCFG |= 0x7f;  // shut off everything we can.
+            if ((mode == DeepSleepWD) || (mode == PowerDownWD))
+                LPC_SYSCON->PDSLEEPCFG &= ~(1<<6);
             SCB->SCR |= SCB_SCR_SLEEPDEEP_Msk;
             bool IRCPowered = (LPC_SYSCON->PDRUNCFG & 0x01); // only used for cleen shutdown but defined here for scope reasons.
diff -r 219e1147c6fa -r 9c5cd0f7aa8a mBuinoSleep.h
--- a/mBuinoSleep.h	Mon Sep 22 09:15:52 2014 +0000
+++ b/mBuinoSleep.h	Sun Sep 28 09:24:32 2014 +0000
@@ -3,7 +3,7 @@
 #include "mbed.h"
-enum sleepMode_t {Sleep, DeepSleep, PowerDown, DeepPowerDown};
+enum sleepMode_t {Sleep, DeepSleep, DeepSleepWD, PowerDown, PowerDownWD, DeepPowerDown};
 void mBuinoSleep(enum sleepMode_t mode);