Example use of the DeepSleepLock class.

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 
00003 InterruptIn button(BUTTON1);
00004 DigitalOut led(LED1);
00005 
00006 void toggle()
00007 {
00008     led = !led;
00009 }
00010 
00011 int main()
00012 {
00013     button.rise(&toggle);
00014     button.fall(&toggle);
00015 
00016     // Lock deep sleep to decrease interrupt latency
00017     // at the expense of high power consumption
00018     DeepSleepLock lock;
00019 
00020     while(1) {
00021         // Wait and let interrupts take care of the rest
00022         wait(1.0);
00023     }
00024 }