diff --git a/avr-threads/src/avr-thread.c b/avr-threads/src/avr-thread.c --- a/avr-threads/src/avr-thread.c +++ b/avr-threads/src/avr-thread.c @@ -54,10 +54,14 @@ uint8_t avr_thread_idle_stack[128] __attribute__((weak)); void avr_thread_idle(void) { - // If we're idling, no need to try to task switch - // because there's no one to task switch to. - // Let the isr do the switch. - for (;;) - ; + set_sleep_mode(SLEEP_MODE_IDLE); + while (1) { + sleep_enable(); + + sleep_cpu(); + + sleep_disable(); + set_sleep_mode(SLEEP_MODE_IDLE); + } } @@ -62,5 +66,6 @@ } + void avr_thread_init(void) { // Initialize idle context.