Example use of the DeepSleepLock class.

main.cpp

Committer:
c1728p9
Date:
24 months ago
Revision:
0:66aac0656e71

File content as of revision 0:66aac0656e71:

#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);
    }
}