diff options
author | gdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4> | 2009-01-05 15:07:55 +0000 |
---|---|---|
committer | gdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4> | 2009-01-05 15:07:55 +0000 |
commit | e55a45c9e8eb2d89878ae935dbf4892566374c86 (patch) | |
tree | 1abfa1bd16adc4bafc042b72f9cea09d29094761 /src/chsys.c | |
parent | bbabbf4ac29fc00d38a767cf07db01cf642e937d (diff) | |
download | ChibiOS-e55a45c9e8eb2d89878ae935dbf4892566374c86.tar.gz ChibiOS-e55a45c9e8eb2d89878ae935dbf4892566374c86.tar.bz2 ChibiOS-e55a45c9e8eb2d89878ae935dbf4892566374c86.zip |
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@583 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'src/chsys.c')
-rw-r--r-- | src/chsys.c | 42 |
1 files changed, 30 insertions, 12 deletions
diff --git a/src/chsys.c b/src/chsys.c index f57180dd7..0f5f7fa39 100644 --- a/src/chsys.c +++ b/src/chsys.c @@ -24,6 +24,24 @@ #include <ch.h> +static WORKING_AREA(idle_thread_wa, IDLE_THREAD_STACK_SIZE); + +/** + * This function implements the idle thread infinite loop. The function should + * put the processor in the lowest power mode capable to serve interrupts. + * The priority is internally set to the minimum system value so that this + * thread is executed only if there are no other ready threads in the system. + * @param p the thread parameter, unused in this scenario + * @note Implementation should declare this function as a weak symbol in order + * to allow applications to re-implement it. + */ +static void idle_thread(void *p) { + + while (TRUE) { + sys_wait_for_interrupt(); + } +} + /** * ChibiOS/RT initialization. After executing this function the current * instructions stream becomes the main thread. @@ -33,7 +51,6 @@ */ void chSysInit(void) { static Thread mainthread; - static WORKING_AREA(idle_wa, IDLE_THREAD_STACK_SIZE); chSchInit(); chDbgInit(); @@ -54,7 +71,8 @@ void chSysInit(void) { * serve interrupts in its context while keeping the lowest energy saving * mode compatible with the system status. */ - chThdCreateStatic(idle_wa, sizeof(idle_wa), IDLEPRIO, (tfunc_t)_idle, NULL); + chThdCreateStatic(idle_wa, sizeof(idle_thread_wa), IDLEPRIO, + (tfunc_t)idle_thread, NULL); } /** @@ -76,6 +94,16 @@ void chSysTimerHandlerI(void) { chVTDoTickI(); } +/** + * Abonormal system termination handler. Invoked by the ChibiOS/RT when an + * abnormal unrecoverable condition is met. + */ +void chSysHalt(void) { + + chSysDisable(); + sys_halt(); +} + #if !defined(CH_OPTIMIZE_SPEED) /** * Enters the ChibiOS/RT system mutual exclusion zone. @@ -107,14 +135,4 @@ void chSysUnlock(void) { } #endif /* !CH_OPTIMIZE_SPEED */ -/** - * Abonormal system termination handler. Invoked by the ChibiOS/RT when an - * abnormal unrecoverable condition is met. - */ -void chSysHalt(void) { - - chSysDisable(); - sys_halt(); -} - /** @} */ |