Example of using sleep/deepsleep with the LPC812

Dependencies:   mbed-src WakeUp

After some initial code the device goes into powerdown (deepsleep), or sleep mode. By creating a rising edge on pin D0 (I just use a cable to connect it to Vdd) it will leave sleep, blink blue, and go to sleep again. Aditionally after 10 seconds of sleep it will blink green using the low-power wake-up timer.

Brownout detection and Watchdog timer are disabled since in deepsleep they are the primary power consumers.

Files at this revision

API Documentation at this revision

Comitter:
Sissors
Date:
Sat Nov 23 11:36:34 2013 +0000
Parent:
0:273b2570ead8
Commit message:
Added wakeup timer.

Changed in this revision

WakeUp.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed-src.lib Show annotated file Show diff for this revision Revisions of this file
diff -r 273b2570ead8 -r 85ca0ec1e66f WakeUp.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/WakeUp.lib	Sat Nov 23 11:36:34 2013 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/Sissors/code/WakeUp/#fc439458a359
diff -r 273b2570ead8 -r 85ca0ec1e66f main.cpp
--- a/main.cpp	Wed Nov 20 21:26:47 2013 +0000
+++ b/main.cpp	Sat Nov 23 11:36:34 2013 +0000
@@ -1,27 +1,42 @@
 #include "mbed.h"
+#include "WakeUp.h"
 
-DigitalOut myled(LED1);
+DigitalOut led1(LED1);
+DigitalOut led2(LED2);
 InterruptIn inter(D0);
 
 
-void interirq(void) {
+void interirq(void)
+{
+    led1 = 0;
+    wait(0.2);
+    led1 = 1;
+}
 
+void wakeirq(void)
+{
+    led2 = 0;
+    wait(0.2);
+    led2 = 1;
 }
 
-int main() {
+int main()
+{
+    led1 = 1;
+    led2 = 1;
     inter.rise(interirq);
-    
-    //Disable BOD and WDT:
+    WakeUp::calibrate();
+    WakeUp::attach(wakeirq);
+
+
+    //Disable BOD and WDT (only done to get nice low deepsleep power):
     LPC_SYSCON->PDRUNCFG |= (1<<3) | (1<<6);
-    
+ 
+    WakeUp::set(10);
     while(1) {
-        for (int i = 0; i<10; i++) {
-            myled = 0;
-            wait(0.2);
-            myled = 1;
-            wait(0.2);
-        }
         //sleep();
         deepsleep();
+        WakeUp::set(10);
     }
 }
+
diff -r 273b2570ead8 -r 85ca0ec1e66f mbed-src.lib
--- a/mbed-src.lib	Wed Nov 20 21:26:47 2013 +0000
+++ b/mbed-src.lib	Sat Nov 23 11:36:34 2013 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/Sissors/code/mbed-src-LP81x-sleep/#42f26c765a05
+http://mbed.org/users/mbed_official/code/mbed-src/#a1af374b4197