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.

Revision:
2:9c5cd0f7aa8a
Parent:
1:219e1147c6fa
--- 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 @@
             break;
 
         case DeepSleep:
-        case PowerDown: {
-            if (mode == PowerDown)
+        case PowerDown:
+        case PowerDownWD:
+        case DeepSleepWD: {
+            if ((mode == PowerDown) || (mode == PowerDownWD))
                 LPC_PMU->PCON = 0x2;
             else
                 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.