Simon Kallweit <[email protected]> writes: > Hello > > Would it make sense to include support for sleeping ("wfi" > instruction) in idle thread for the cortex m3 architecture? The > current code in hal_arch.h looks like: > > #if 0 //ndef HAL_IDLE_THREAD_ACTION > #define HAL_IDLE_THREAD_ACTION(__count) __asm__ volatile ( "wfi\n" ) > #else > #define HAL_IDLE_THREAD_ACTION(__count) CYG_EMPTY_STATEMENT > #endif > > I guess this is not what it was meant to be. I would propose to add an option > like CYGHWR_HAL_CORTEXM_IDLE_SLEEP to enable the wfi instruction: > > #ifndef HAL_IDLE_THREAD_ACTION > # ifdef CYGHWR_HAL_CORTEXM_IDLE_SLEEP > # define HAL_IDLE_THREAD_ACTION(__count) __asm__ volatile ( "wfi\n" ) > # else > # define HAL_IDLE_THREAD_ACTION(__count) CYG_EMPTY_STATEMENT > # endif > #endif > > Also, currently var_arch.h gets not included in the hal_arch.h header, so > it's impossible to override for example the HAL_IDLE_THREAD_ACTION macro. I > guess this was just overlooked, or is it intentional? > > I can provide a patch if there are no objections.
The "#if 0" is an oversight on my part. When debugging via JTAG I was having difficulties breaking in to an idle system. Stopping it using WFI solved this. The #else part is also a consequence of this, so that code should really be: #ifndef HAL_IDLE_THREAD_ACTION #define HAL_IDLE_THREAD_ACTION(__count) __asm__ volatile ( "wfi\n" ) #endif Given this I don't really see any need for the CYGHWR_HAL_CORTEXM_IDLE_SLEEP option. If a variant or platform HAL needs to override this it can very easily by redefining HAL_IDLE_THREAD_ACTION(). var_arch.h should certainly be included in hal_arch.h. It is only because the STM32 has an empty var_arch.h that we haven't noticed this before. -- Nick Garnett eCos Kernel Architect eCosCentric Limited http://www.eCosCentric.com The eCos experts Barnwell House, Barnwell Drive, Cambridge, UK. Tel: +44 1223 245571 Registered in England and Wales: Reg No: 4422071 Besuchen Sie uns vom 3.-5.03.09 auf der Embedded World 2009, Stand 11-300 Visit us at Embedded World 2009, Nürnberg, Germany, 3-5 Mar, Stand 11-300 -- Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss
