power.h File Reference
CPU power management functions. More...
#include "cfg/cfg_proc.h"
#include "cfg/cfg_wdt.h"
Go to the source code of this file.
Defines | |
| #define | CPU_PAUSE_ON(COND) ATOMIC(while (!(COND)) { cpu_pause(); }) |
| Safely call cpu_pause() until the COND predicate becomes true. | |
Functions | |
| void | cpu_relax (void) |
| Let the CPU rest in tight busy loops. | |
| void | cpu_pause (void) |
| Stop the processor until the next interrupt occurs. | |
Detailed Description
CPU power management functions.
Definition in file power.h.
Function Documentation
| void cpu_pause | ( | void | ) | [inline] |
Stop the processor until the next interrupt occurs.
Pausing the CPU effectively reduces power usage, and should be used whenever the program is idle waiting for the next event to occur.
To avoid deadlocking, the caller should normally check for the desired condition with interrupts disabled, and enter this function while interrupts are still disabled:
IRQ_DISABLE();
while (!event_occurred)
cpu_pause();
IRQ_ENABLE();
- Note:
- Some implementations of cpu_pause() may return before any interrupt has occurred. Calling code should take this possibility into account.
This function is currently unimplemented
- See also:
- cpu_relax() cpu_yield()
| void cpu_relax | ( | void | ) | [inline] |
Let the CPU rest in tight busy loops.
User code that sits in a busy loop should call cpu_relax() every once in a while to perform system-dependent idle processing.
Depending on the system configuration, this might perform different actions:
- yield the CPU to other processes
- reset the watchdog timer to avoid it from triggering
- scale the CPU speed down to save power (unimplemented)
- let the event loop of the emulator process a few events
- See also:
- proc_yield() cpu_pause()
