diff options
Diffstat (limited to 'firmware')
-rw-r--r-- | firmware/target/arm/as3525/powermgmt-as3525.c | 29 | ||||
-rw-r--r-- | firmware/target/arm/as3525/sansa-clip/adc-target.h | 24 | ||||
-rw-r--r-- | firmware/target/arm/as3525/sansa-e200v2/adc-target.h | 24 | ||||
-rw-r--r-- | firmware/target/arm/as3525/sansa-fuze/adc-target.h | 24 | ||||
-rw-r--r-- | firmware/target/arm/as3525/sansa-m200v4/adc-target.h | 24 |
5 files changed, 23 insertions, 102 deletions
diff --git a/firmware/target/arm/as3525/powermgmt-as3525.c b/firmware/target/arm/as3525/powermgmt-as3525.c index ac1ee79f00..47e037684a 100644 --- a/firmware/target/arm/as3525/powermgmt-as3525.c +++ b/firmware/target/arm/as3525/powermgmt-as3525.c | |||
@@ -21,36 +21,53 @@ | |||
21 | 21 | ||
22 | #include "config.h" | 22 | #include "config.h" |
23 | #include "adc.h" | 23 | #include "adc.h" |
24 | #include "adc-target.h" | ||
24 | #include "powermgmt.h" | 25 | #include "powermgmt.h" |
25 | 26 | ||
26 | /* TODO */ | 27 | /* TODO |
28 | Each as3525 target should probably define its own battery properties | ||
29 | (dangerous/shutoff battery level, discharge/charge curves) in a file | ||
30 | called powermgmt-<target>.c in its own sub-directory. | ||
31 | |||
32 | For now, this file provides simple uncalibrated settings to get at least | ||
33 | a basic reading for all as3525 targets with a lithium battery. | ||
34 | */ | ||
27 | 35 | ||
28 | const unsigned short battery_level_dangerous[BATTERY_TYPES_COUNT] = | 36 | const unsigned short battery_level_dangerous[BATTERY_TYPES_COUNT] = |
29 | { | 37 | { |
30 | 0 | 38 | /* TODO: this is just an initial guess */ |
39 | 3400 | ||
31 | }; | 40 | }; |
32 | 41 | ||
33 | const unsigned short battery_level_shutoff[BATTERY_TYPES_COUNT] = | 42 | const unsigned short battery_level_shutoff[BATTERY_TYPES_COUNT] = |
34 | { | 43 | { |
35 | 0 | 44 | /* TODO: this is just an initial guess */ |
45 | 3300 | ||
36 | }; | 46 | }; |
37 | 47 | ||
38 | /* voltages (millivolt) of 0%, 10%, ... 100% when charging disabled */ | 48 | /* voltages (millivolt) of 0%, 10%, ... 100% when charging disabled */ |
39 | const unsigned short percent_to_volt_discharge[BATTERY_TYPES_COUNT][11] = | 49 | const unsigned short percent_to_volt_discharge[BATTERY_TYPES_COUNT][11] = |
40 | { | 50 | { |
41 | { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } | 51 | /* TODO: simple uncalibrated curve, linear except for first 10% */ |
52 | { 3300, 3390, 3480, 3570, 3660, 3750, 3840, 3930, 4020, 4110, 4200 } | ||
42 | }; | 53 | }; |
43 | 54 | ||
44 | #if CONFIG_CHARGING | 55 | #if CONFIG_CHARGING |
45 | /* voltages (millivolt) of 0%, 10%, ... 100% when charging enabled */ | 56 | /* voltages (millivolt) of 0%, 10%, ... 100% when charging enabled */ |
46 | const unsigned short percent_to_volt_charge[11] = | 57 | const unsigned short percent_to_volt_charge[11] = |
47 | { | 58 | { |
48 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 | 59 | /* TODO: simple uncalibrated curve, linear except for first 10% */ |
60 | 3300, 3390, 3480, 3570, 3660, 3750, 3840, 3930, 4020, 4110, 4200 | ||
49 | }; | 61 | }; |
50 | #endif /* CONFIG_CHARGING */ | 62 | #endif /* CONFIG_CHARGING */ |
51 | 63 | ||
64 | /* ADC should read 0x3ff=5.12V */ | ||
65 | #define BATTERY_SCALE_FACTOR 5125 | ||
66 | /* full-scale ADC readout (2^10) in millivolt */ | ||
67 | |||
52 | /* Returns battery voltage from ADC [millivolts] */ | 68 | /* Returns battery voltage from ADC [millivolts] */ |
53 | unsigned int battery_adc_voltage(void) | 69 | unsigned int battery_adc_voltage(void) |
54 | { | 70 | { |
55 | return 1; | 71 | return (adc_read(ADC_RTCSUP) * BATTERY_SCALE_FACTOR) >> 10; |
56 | } | 72 | } |
73 | |||
diff --git a/firmware/target/arm/as3525/sansa-clip/adc-target.h b/firmware/target/arm/as3525/sansa-clip/adc-target.h deleted file mode 100644 index bea0272496..0000000000 --- a/firmware/target/arm/as3525/sansa-clip/adc-target.h +++ /dev/null | |||
@@ -1,24 +0,0 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2008 ?? | ||
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 | #ifndef _ADC_TARGET_H_ | ||
22 | #define _ADC_TARGET_H_ | ||
23 | |||
24 | #endif /* _ADC_TARGET_H_ */ | ||
diff --git a/firmware/target/arm/as3525/sansa-e200v2/adc-target.h b/firmware/target/arm/as3525/sansa-e200v2/adc-target.h deleted file mode 100644 index bea0272496..0000000000 --- a/firmware/target/arm/as3525/sansa-e200v2/adc-target.h +++ /dev/null | |||
@@ -1,24 +0,0 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2008 ?? | ||
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 | #ifndef _ADC_TARGET_H_ | ||
22 | #define _ADC_TARGET_H_ | ||
23 | |||
24 | #endif /* _ADC_TARGET_H_ */ | ||
diff --git a/firmware/target/arm/as3525/sansa-fuze/adc-target.h b/firmware/target/arm/as3525/sansa-fuze/adc-target.h deleted file mode 100644 index bea0272496..0000000000 --- a/firmware/target/arm/as3525/sansa-fuze/adc-target.h +++ /dev/null | |||
@@ -1,24 +0,0 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2008 ?? | ||
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 | #ifndef _ADC_TARGET_H_ | ||
22 | #define _ADC_TARGET_H_ | ||
23 | |||
24 | #endif /* _ADC_TARGET_H_ */ | ||
diff --git a/firmware/target/arm/as3525/sansa-m200v4/adc-target.h b/firmware/target/arm/as3525/sansa-m200v4/adc-target.h deleted file mode 100644 index bea0272496..0000000000 --- a/firmware/target/arm/as3525/sansa-m200v4/adc-target.h +++ /dev/null | |||
@@ -1,24 +0,0 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2008 ?? | ||
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 | #ifndef _ADC_TARGET_H_ | ||
22 | #define _ADC_TARGET_H_ | ||
23 | |||
24 | #endif /* _ADC_TARGET_H_ */ | ||