Nuvoton
/
NuMaker-mbed-tickless-example
NuMaker tickless example
Diff: main.cpp
- Revision:
- 13:c1c711d573f2
- Parent:
- 11:0c4b39c54af2
- Child:
- 21:5424989f037f
--- a/main.cpp Fri Apr 13 10:48:07 2018 +0800 +++ b/main.cpp Wed Apr 18 14:51:31 2018 +0800 @@ -6,7 +6,9 @@ static void flush_stdio_uart_fifo(void); static void check_wakeup_source(uint32_t, bool deepsleep); +#if (! defined(MBED_TICKLESS)) static void idle_hdlr(void); +#endif EventFlags wakeup_eventflags; @@ -20,9 +22,13 @@ //config_uart_wakeup(); //config_i2c_wakeup(); +#if defined(MBED_TICKLESS) + /* Run Mbed OS internal idle handler */ +#else /* Register idle handler which supports tickless */ Thread::attach_idle_hook(idle_hdlr); - +#endif + while (true) { printf("I am going to shallow/deep sleep\n"); @@ -130,6 +136,8 @@ } } +#if (! defined(MBED_TICKLESS)) + #define US_PER_SEC (1000 * 1000) #define US_PER_OS_TICK (US_PER_SEC / OS_TICK_FREQ) @@ -176,3 +184,5 @@ /* Resume the system */ osKernelResume(elapsed_ticks); } + +#endif