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:
1:219e1147c6fa
Parent:
0:af76f9a302ea
Child:
2:9c5cd0f7aa8a
--- a/mBuinoSleep.cpp	Sun Sep 21 11:02:19 2014 +0000
+++ b/mBuinoSleep.cpp	Mon Sep 22 09:15:52 2014 +0000
@@ -2,6 +2,10 @@
 
 void mBuinoSleep(enum sleepMode_t mode)
 {
+
+    if ((mode == DeepPowerDown) && (LPC_PMU->PCON & 0x08)) // bit 3 high blocks deep power down.
+        mode = PowerDown;
+
     switch (mode) {
         default:
         case Sleep:
@@ -47,5 +51,10 @@
                 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();
     }
 }