The power management thread – Comtrol eCos User Manual

Page 663

Advertising
background image

Power Management Information

#endif

#include

<

cyg/power/power.h

>

static const char*

mode_to_string(PowerMode mode)

{

const char* result;

switch(mode) {

case PowerMode_Active : result = "active"; break;

case PowerMode_Idle

: result = "idle"; break;

case PowerMode_Sleep

: result = "sleep"; break;

case PowerMode_Off

: result = "off"; break;

default

: result = "

<

unknown

>

"; break;

}

return result;

}

int

main(int argc, char** argv)

{

PowerController* controller;

for (controller = &(__POWER__[0]);

controller != &(__POWER_END__);

controller++) {

printf("Controller @ %p: %s, %s\n", controller,

power_get_controller_id(controller),

mode_to_string(power_get_controller_mode(controller)));

}

return 0;

}

The Power Management Thread

If the power management package is configured to use a separate thread then a handle for that thread is made
available to higher-level code via the variable

power_thread_handle

. This handle can be used for a variety of

purposes, including manipulating that thread’s priority.

559

Advertising