summaryrefslogtreecommitdiff
path: root/firmware/target/hosted/powermgmt.c
diff options
context:
space:
mode:
authorThomas Martitz <kugel@rockbox.org>2012-01-03 23:44:38 +0000
committerThomas Martitz <kugel@rockbox.org>2012-01-03 23:44:38 +0000
commitc1bd9b0361ba92c29ceef68d74093e70a1a3e481 (patch)
tree1a42acdf2099b7f5ac06eee11e1d488b388c6d9f /firmware/target/hosted/powermgmt.c
parent949e6398c89e3c277a4c542f67a5ee788c6f642d (diff)
downloadrockbox-c1bd9b0361ba92c29ceef68d74093e70a1a3e481.tar.gz
rockbox-c1bd9b0361ba92c29ceef68d74093e70a1a3e481.zip
Rework powermgmt to enable code re-use on appliation and sims.
* Introduce CONFIG_BATTERY_MEASURE define, to allow targets (application) to break powermgmt.c's assumption about the ability to read battery voltage. There's now additionally percentage (android) and remaining time measure (maemo). No measure at all also works (sdl app). If voltage can't be measured, then battery_level() is king and it'll be used for power_history and runtime estimation. * Implement target's API in the simulator, i.e. _battery_voltage(), so it doesn't need to implement it's own powermgmt.c and other stubs. Now the sim behaves much more like a native target, although it still changes the simulated battery voltage quickly, * Other changes include include renaming battery_adc_voltage() to _battery_voltage(), for consistency with the new target functions and making some of the apps code aware that voltage and runtime estimation is not always available. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@31548 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/target/hosted/powermgmt.c')
-rw-r--r--firmware/target/hosted/powermgmt.c56
1 files changed, 0 insertions, 56 deletions
diff --git a/firmware/target/hosted/powermgmt.c b/firmware/target/hosted/powermgmt.c
deleted file mode 100644
index bf05e5ff19..0000000000
--- a/firmware/target/hosted/powermgmt.c
+++ /dev/null
@@ -1,56 +0,0 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2011 by Thomas Jarosch
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
16 *
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
19 *
20 ****************************************************************************/
21#include "config.h"
22#include "powermgmt.h"
23#include "thread.h"
24#include "kernel.h"
25
26static char power_stack[DEFAULT_STACK_SIZE];
27static const char power_thread_name[] = "power";
28
29void powermgmt_init_target(void);
30
31#if !(CONFIG_PLATFORM & PLATFORM_ANDROID)
32void powermgmt_init_target(void)
33{
34 /* Nothing to do */
35}
36#endif
37
38static void power_thread(void)
39{
40 powermgmt_init_target();
41
42 while (1)
43 {
44 /* Sleep two seconds */
45 sleep(HZ*2);
46
47 handle_auto_poweroff();
48 }
49} /* power_thread */
50
51void powermgmt_init(void)
52{
53 create_thread(power_thread, power_stack, sizeof(power_stack), 0,
54 power_thread_name IF_PRIO(, PRIORITY_SYSTEM)
55 IF_COP(, CPU));
56}