Demo of working sleep and deepsleep commands. mbed's version currently does not

Dependencies:   mbed

Fork of DipCortex-SleepyTime by Carl - SolderSplash Labs

Files at this revision

API Documentation at this revision

Comitter:
SolderSplashLabs
Date:
Thu Nov 14 22:31:45 2013 +0000
Child:
1:03baf535e2fc
Commit message:
Demo bypassing mbed library sleep and deepsleep commands

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.lib Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Thu Nov 14 22:31:45 2013 +0000
@@ -0,0 +1,56 @@
+#include "mbed.h"
+
+DigitalIn Button(P0_1);
+InterruptIn ButtonIrq(P0_1); 
+
+DigitalOut Led2(P1_22);
+
+Ticker timer;
+
+void sleep_normal ( void )
+{
+    // PCON[PD] set to sleep
+    LPC_PMU->PCON = 0x0;
+    
+    // SRC[SLEEPDEEP] set to 0 = sleep
+    SCB->SCR &= ~SCB_SCR_SLEEPDEEP_Msk;
+    
+    // wait for interrupt
+    __WFI();
+}
+
+// Section 3.9.4 of the LPC11U24 User Manual
+void sleep_deep ( void )
+{
+// PCON[PD] set to deepsleep
+    LPC_PMU->PCON = 0x1;
+    
+    // SRC[SLEEPDEEP] set to 1 = deep sleep
+    SCB->SCR |= SCB_SCR_SLEEPDEEP_Msk;
+    
+    // Power up everything after powerdown
+    LPC_SYSCON->PDAWAKECFG &= 0xFFFFF800;
+    
+    // wait for interrupt
+    __WFI();
+}
+
+void ButtonPressed ( void )
+{
+    // Wake up ..
+    Led2 = !Led2;
+}
+
+int main() 
+{
+    Led2 = 1;
+    Button.mode(PullUp);
+    ButtonIrq.fall(ButtonPressed);
+    
+    while(1) 
+    {
+        // All I do is sleep
+        //sleep_normal();
+        sleep_deep();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.lib	Thu Nov 14 22:31:45 2013 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/#f37f3b9c9f0b