diff options
Diffstat (limited to 'firmware/target/arm/pbell/vibe500/powermgmt-vibe500.c')
-rw-r--r-- | firmware/target/arm/pbell/vibe500/powermgmt-vibe500.c | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/firmware/target/arm/pbell/vibe500/powermgmt-vibe500.c b/firmware/target/arm/pbell/vibe500/powermgmt-vibe500.c new file mode 100644 index 0000000000..d84881cea1 --- /dev/null +++ b/firmware/target/arm/pbell/vibe500/powermgmt-vibe500.c | |||
@@ -0,0 +1,57 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id:$ | ||
9 | * | ||
10 | * Copyright (C) 2002 by Heikki Hannikainen, Uwe Freese | ||
11 | * Revisions copyright (C) 2005 by Gerald Van Baren | ||
12 | * Copyright (C) 2009 by Szymon Dziok | ||
13 | * | ||
14 | * This program is free software; you can redistribute it and/or | ||
15 | * modify it under the terms of the GNU General Public License | ||
16 | * as published by the Free Software Foundation; either version 2 | ||
17 | * of the License, or (at your option) any later version. | ||
18 | * | ||
19 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
20 | * KIND, either express or implied. | ||
21 | * | ||
22 | ****************************************************************************/ | ||
23 | |||
24 | #include "config.h" | ||
25 | #include "adc.h" | ||
26 | #include "powermgmt.h" | ||
27 | |||
28 | const unsigned short battery_level_dangerous[BATTERY_TYPES_COUNT] = | ||
29 | { | ||
30 | 3515 | ||
31 | }; | ||
32 | |||
33 | const unsigned short battery_level_shutoff[BATTERY_TYPES_COUNT] = | ||
34 | { | ||
35 | 3486 | ||
36 | }; | ||
37 | |||
38 | /* voltages (millivolt) of 0%, 10%, ... 100% when charging disabled */ | ||
39 | const unsigned short percent_to_volt_discharge[BATTERY_TYPES_COUNT][11] = | ||
40 | { | ||
41 | { 3474, 3515, 3556, 3597, 3638, 3679, 3720, 3761, 3802, 3843, 3884 } | ||
42 | }; | ||
43 | |||
44 | /* voltages (millivolt) of 0%, 10%, ... 100% when charging enabled */ | ||
45 | const unsigned short percent_to_volt_charge[11] = | ||
46 | { | ||
47 | 3474, 3515, 3556, 3597, 3638, 3679, 3720, 3761, 3802, 3843, 3884 | ||
48 | }; | ||
49 | |||
50 | #define BATTERY_SCALE_FACTOR 4200 | ||
51 | /* full-scale ADC readout (2^10) in millivolt */ | ||
52 | |||
53 | /* Returns battery voltage from ADC [millivolts] */ | ||
54 | unsigned int battery_adc_voltage(void) | ||
55 | { | ||
56 | return (adc_read(ADC_UNREG_POWER) * BATTERY_SCALE_FACTOR) >> 10; | ||
57 | } | ||