diff options
Diffstat (limited to 'firmware/target/arm/rk27xx/hm801/powermgmt-hm801.c')
-rw-r--r-- | firmware/target/arm/rk27xx/hm801/powermgmt-hm801.c | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/firmware/target/arm/rk27xx/hm801/powermgmt-hm801.c b/firmware/target/arm/rk27xx/hm801/powermgmt-hm801.c new file mode 100644 index 0000000000..a815d893b2 --- /dev/null +++ b/firmware/target/arm/rk27xx/hm801/powermgmt-hm801.c | |||
@@ -0,0 +1,60 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright © 2011 Andrew Ryabinin | ||
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 | |||
22 | #include "config.h" | ||
23 | #include "adc.h" | ||
24 | #include "adc-target.h" | ||
25 | #include "powermgmt.h" | ||
26 | |||
27 | /* Battery voltage calculation and discharge/charge curves for the HiFiMAN HM-801. | ||
28 | |||
29 | I don't know how to calculate battery voltage, so all values represented here is just | ||
30 | values from adc battery channel, not millivolts. | ||
31 | Discharge and charge curves have not been calibrated yet. | ||
32 | */ | ||
33 | |||
34 | const unsigned short battery_level_dangerous[BATTERY_TYPES_COUNT] = | ||
35 | { | ||
36 | /* OF power off device when this value reached */ | ||
37 | 430 | ||
38 | }; | ||
39 | |||
40 | const unsigned short battery_level_shutoff[BATTERY_TYPES_COUNT] = | ||
41 | { | ||
42 | 425 | ||
43 | }; | ||
44 | |||
45 | /* adc values of 0%, 10%, ... 100% when charging disabled */ | ||
46 | const unsigned short percent_to_volt_discharge[BATTERY_TYPES_COUNT][11] = | ||
47 | { | ||
48 | /* TODO: simple uncalibrated curve */ | ||
49 | { 425, 430, 440, 450, 460, 470, 480, 490, 500, 510, 520 } | ||
50 | }; | ||
51 | |||
52 | /* adc values of 0%, 10%, ... 100% when charging enabled */ | ||
53 | const unsigned short percent_to_volt_charge[11] = | ||
54 | /* TODO: simple uncalibrated curve */ | ||
55 | { 425, 430, 440, 450, 460, 470, 480, 490, 500, 510, 520 }; | ||
56 | |||
57 | unsigned int battery_adc_voltage(void) | ||
58 | { | ||
59 | return adc_read(ADC_BATTERY); | ||
60 | } | ||