Andy A / mBuino_Sleep

Dependents:   mBuDice SleepyCounting

Revision:
3:a3fd27c4a161
Parent:
2:9586ea22ab1b
Child:
4:c3f400cbe2fe
--- a/mBuinoSleep.cpp	Sun Sep 21 11:01:27 2014 +0000
+++ b/mBuinoSleep.cpp	Mon Sep 22 09:16:10 2014 +0000
@@ -15,6 +15,9 @@
 
     progMode.mode(PullNone);
 
+    if ((mode == DeepPowerDown) && (LPC_PMU->PCON & 0x08)) // bit 3 high blocks deep power down.
+        mode = PowerDown;
+
     switch (mode) {
         default:
         case Sleep:
@@ -60,6 +63,11 @@
                 LPC_SYSCON->PDRUNCFG |= 0x01; // power down the IRC if it was off before
         }
         break;
+        case DeepPowerDown:
+            LPC_PMU->PCON = 0x3;
+            LPC_SYSCON->PDSLEEPCFG |= 0x7f;  // shut off everything we can.
+            SCB->SCR |= SCB_SCR_SLEEPDEEP_Msk;
+            __WFI();
     }
     LEDs = oldLEDState;
 }