Daiki Kato
/
Sleep_test_use_OS
This is a sample to make sleep using OS.
Diff: main.cpp
- Revision:
- 1:8ba32924482c
- Parent:
- 0:680321964ff9
- Child:
- 2:22bc64c6ee90
--- a/main.cpp Fri Nov 18 08:52:33 2016 +0000 +++ b/main.cpp Fri Nov 18 09:42:04 2016 +0000 @@ -4,6 +4,13 @@ InterruptIn button(USER_BUTTON0); DigitalOut led1(LED1); Thread * pTestTask = NULL; +static int debug_cnt = 0; // for debug + +static void idle_hook(void) { + __SEV(); + __WFE(); + __WFE(); +} static void interrupt_button(void) { if (pTestTask != NULL) { @@ -26,6 +33,7 @@ } int main() { + Thread::attach_idle_hook(idle_hook); pTestTask = new Thread(); pTestTask->start(test_task); }