BeRTOS
power.h
Go to the documentation of this file.
00001 
00037 #ifndef CPU_POWER_H
00038 #define CPU_POWER_H
00039 
00040 #include "cfg/cfg_proc.h"
00041 #include "cfg/cfg_wdt.h"
00042 
00043 #include <cfg/compiler.h>
00044 
00045 #if CONFIG_KERN
00046     #include <kern/proc.h>
00047 #endif
00048 
00049 #if CONFIG_WATCHDOG
00050     #include <drv/wdt.h>
00051 #endif
00052 
00069 INLINE void cpu_relax(void)
00070 {
00071     MEMORY_BARRIER;
00072 #if CONFIG_KERN
00073     if (proc_preemptAllowed())
00074         proc_yield();
00075 #endif
00076 
00077 #if CONFIG_WATCHDOG
00078     wdt_reset();
00079 #endif
00080 }
00081 
00106 INLINE void cpu_pause(void)
00107 {
00108     //ASSERT_IRQ_DISABLED();
00109     //IRQ_ENABLE();
00110     cpu_relax();
00111     //IRQ_DISABLE();
00112 }
00113 
00117 #define CPU_PAUSE_ON(COND) ATOMIC(while (!(COND)) { cpu_pause(); })
00118 
00119 #endif /* CPU_POWER_H */