This is a sample to make sleep without using OS.

Dependencies:   mbed

main.cpp

Committer:
dkato
Date:
2016-11-18
Revision:
1:ec156833bab2
Parent:
0:19a3b76f6ca9

File content as of revision 1:ec156833bab2:

#include "mbed.h"

InterruptIn button(USER_BUTTON0);
DigitalOut led1(LED1);

static void interrupt_button(void) {
    // do nothing
}

int main() {
    int test_cnt = 0;

    button.fall(&interrupt_button);
    button.rise(&interrupt_button);

    while (true) {
        // Transition to Sleep Mode
        __SEV();
        __WFE();
        __WFE();
        led1 = !led1;
        printf("%d\n", test_cnt++);
    }
}