Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed
Diff: main.cpp
- Revision:
- 0:8e1b0b607dc3
- Child:
- 1:053449444c29
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Tue Dec 01 15:45:13 2015 +0000 @@ -0,0 +1,39 @@ +#include "mbed.h" + +InterruptIn event(USER_BUTTON); +DigitalOut myled(LED1); + +int go_to_sleep = 0; + +void pressed() +{ + printf("Button pressed\n"); + go_to_sleep = !go_to_sleep; +} + +int main() +{ + + HAL_PWR_EnableWakeUpPin(USER_BUTTON); + int i = 0; + + //event.fall(&pressed); + + while (1) { + event.fall(&pressed); + if (go_to_sleep) { + //myled = 1; + printf("%d: Entering sleep (press user button to resume)\n", i); + //sleep(); + //deepsleep(); + HAL_PWR_EnterSTOPMode(PWR_MAINREGULATOR_ON, PWR_STOPENTRY_WFI); + + //wait(0.1); + } else { + printf("%d: Running\n", i); + myled = !myled; + wait(1.0); + } + i++; + } +}