Changing power modes, Name, Synopsis – Comtrol eCos User Manual
Page 665: Changing the global power mode
Changing Power Modes
Name
Changing Power Modes
— reducing or increasing power consumption as needed
Synopsis
#include
<
cyg/power/power.h
>
void power_set_mode ( PowerMode new_mode );
void power_set_controller_mode ( PowerController* controller ,
PowerMode new_mode );
void power_set_controller_mode_now ( PowerController* controller ,
PowerMode new_mode
);
Changing the Global Power Mode
The primary functionality supported by the power management package is to change the system’s global power
mode. This is achieved by calling the function
power_set_mode
with a single argument, which should be one
of
PowerMode_Active
,
PowerMode_Idle
,
PowerMode_Sleep
or
PowerMode_Off
. Typically this function will
only be invoked in certain scenarios:
1. A typical system will contain a policy module which is primarily responsible for initiating power mode
changes, and a thread inside the power management package. The policy module will call
power_set_mode
,
which has the effect of manipulating some internal state in the power management package and waking up
its thread. When this thread gets scheduled to run (its priority is controlled by a configuration option), it will
iterate over the power controllers and invoke each controller to change its power mode. There is support for a
, and for
power controllers.
2. After a call to
power_set_mode
but before the power management thread has had a chance to iterate over
all the controllers, or even before the thread has been rescheduled at all, the policy module may decide that a
different power mode would be more appropriate for the current situation and calls
power_set_mode
again.
This has the effect of aborting the previous mode change, followed by the power management thread iterating
over the power controllers again for the new mode.
3. If there is no single policy module responsible for power mode changes, any code can call
power_set_mode
.
If there are multiple calls in quick succession, earlier calls will be aborted and the system should end up in the
power mode corresponding to the last call
4. As a special case, it is possible for a power controller to call
power_set_mode
when invoked by the power
management thread. For example a power controller could decide that it is inappropriate for the system to go
to sleep because the device it is associated with is still busy. The effect is as if the policy module had called
power_set_mode
again before the mode change had completed.
If the power management package has been configured not to use a separate thread then obviously the behaviour is
somewhat different. The call to
power_set_mode
will now iterate over the various power controllers immediately,
rather than leaving this to a separate thread, and the whole mode change completes before
power_set_mode
re-
turns. If some other thread or a DSR calls
power_set_mode
concurrently the behaviour of the system is undefined.
561