diff --git a/demos/ARMCM4-STM32F303-DISCOVERY/chconf.h b/demos/ARMCM4-STM32F303-DISCOVERY/chconf.h index 84efe76f6..0886d559c 100644 --- a/demos/ARMCM4-STM32F303-DISCOVERY/chconf.h +++ b/demos/ARMCM4-STM32F303-DISCOVERY/chconf.h @@ -90,16 +90,9 @@ /** * @brief Idle thread automatic spawn suppression. * @details When this option is activated the function @p chSysInit() - * does not spawn the idle thread automatically. The application has - * then the responsibility to do one of the following: - * - Spawn a custom idle thread at priority @p IDLEPRIO. - * - Change the main() thread priority to @p IDLEPRIO then enter - * an endless loop. In this scenario the @p main() thread acts as - * the idle thread. - * . - * @note Unless an idle thread is spawned the @p main() thread must not - * enter a sleep state. - */ + * does not spawn the idle thread. The application @p main() + * function becomes the idle thread and must implement an + * infinite loop. */ #if !defined(CH_CFG_NO_IDLE_THREAD) || defined(__DOXYGEN__) #define CH_CFG_NO_IDLE_THREAD FALSE #endif diff --git a/os/kernel/src/chsys.c b/os/kernel/src/chsys.c index 61157b1b9..7a6d3ea20 100644 --- a/os/kernel/src/chsys.c +++ b/os/kernel/src/chsys.c @@ -115,8 +115,14 @@ void chSysInit(void) { _trace_init(); #endif +#if !CH_CFG_NO_IDLE_THREAD /* Now this instructions flow becomes the main thread.*/ setcurrp(_thread_init(&mainthread, NORMALPRIO)); +#else + /* Now this instructions flow becomes the main thread.*/ + setcurrp(_thread_init(&mainthread, IDLEPRIO)); +#endif + currp->p_state = CH_STATE_CURRENT; #if CH_DBG_ENABLE_STACK_CHECK /* This is a special case because the main thread thread_t structure is not