summaryrefslogtreecommitdiff
path: root/firmware/target
diff options
context:
space:
mode:
authorBertrik Sikken <bertrik@sikken.nl>2008-11-23 15:00:44 +0000
committerBertrik Sikken <bertrik@sikken.nl>2008-11-23 15:00:44 +0000
commit078753395d8e184000ed3c08ef372783e997b3c0 (patch)
tree4b367fa5be60e5f0ea3ff6d5033b1beacfbc91a8 /firmware/target
parent7ff34c40122edfc2364849a5e709076aa499a352 (diff)
downloadrockbox-078753395d8e184000ed3c08ef372783e997b3c0.tar.gz
rockbox-078753395d8e184000ed3c08ef372783e997b3c0.zip
Implement a basic uncalibrated battery reading for all as3525 targets with a lithium battery.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@19189 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/target')
-rw-r--r--firmware/target/arm/as3525/powermgmt-as3525.c29
-rw-r--r--firmware/target/arm/as3525/sansa-clip/adc-target.h24
-rw-r--r--firmware/target/arm/as3525/sansa-e200v2/adc-target.h24
-rw-r--r--firmware/target/arm/as3525/sansa-fuze/adc-target.h24
-rw-r--r--firmware/target/arm/as3525/sansa-m200v4/adc-target.h24
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
28const unsigned short battery_level_dangerous[BATTERY_TYPES_COUNT] = 36const 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
33const unsigned short battery_level_shutoff[BATTERY_TYPES_COUNT] = 42const 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 */
39const unsigned short percent_to_volt_discharge[BATTERY_TYPES_COUNT][11] = 49const 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 */
46const unsigned short percent_to_volt_charge[11] = 57const 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] */
53unsigned int battery_adc_voltage(void) 69unsigned 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_ */