Example use of the DeepSleepLock class.

Committer:
c1728p9
Date:
Fri Oct 27 21:04:30 2017 +0000
Revision:
0:66aac0656e71
Initial Commit

Who changed what in which revision?

UserRevisionLine numberNew contents of line
c1728p9 0:66aac0656e71 1 #include "mbed.h"
c1728p9 0:66aac0656e71 2
c1728p9 0:66aac0656e71 3 InterruptIn button(BUTTON1);
c1728p9 0:66aac0656e71 4 DigitalOut led(LED1);
c1728p9 0:66aac0656e71 5
c1728p9 0:66aac0656e71 6 void toggle()
c1728p9 0:66aac0656e71 7 {
c1728p9 0:66aac0656e71 8 led = !led;
c1728p9 0:66aac0656e71 9 }
c1728p9 0:66aac0656e71 10
c1728p9 0:66aac0656e71 11 int main()
c1728p9 0:66aac0656e71 12 {
c1728p9 0:66aac0656e71 13 button.rise(&toggle);
c1728p9 0:66aac0656e71 14 button.fall(&toggle);
c1728p9 0:66aac0656e71 15
c1728p9 0:66aac0656e71 16 // Lock deep sleep to decrease interrupt latency
c1728p9 0:66aac0656e71 17 // at the expense of high power consumption
c1728p9 0:66aac0656e71 18 DeepSleepLock lock;
c1728p9 0:66aac0656e71 19
c1728p9 0:66aac0656e71 20 while(1) {
c1728p9 0:66aac0656e71 21 // Wait and let interrupts take care of the rest
c1728p9 0:66aac0656e71 22 wait(1.0);
c1728p9 0:66aac0656e71 23 }
c1728p9 0:66aac0656e71 24 }