mbed_example
/
DeepSleepLock_Example_1
Example use of the DeepSleepLock class.
Diff: main.cpp
- Revision:
- 0:66aac0656e71
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Fri Oct 27 21:04:30 2017 +0000 @@ -0,0 +1,24 @@ +#include "mbed.h" + +InterruptIn button(BUTTON1); +DigitalOut led(LED1); + +void toggle() +{ + led = !led; +} + +int main() +{ + button.rise(&toggle); + button.fall(&toggle); + + // Lock deep sleep to decrease interrupt latency + // at the expense of high power consumption + DeepSleepLock lock; + + while(1) { + // Wait and let interrupts take care of the rest + wait(1.0); + } +} \ No newline at end of file