summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKarl Kurbjun <kkurbjun@gmail.com>2010-04-25 16:11:49 +0000
committerKarl Kurbjun <kkurbjun@gmail.com>2010-04-25 16:11:49 +0000
commitb15b7fac7e5aeafc0171ec51bb39b60f9024335d (patch)
tree04e442458b4b8df5024b3d94354d9e09c7b014f6
parent967e16f7c92cddcf75a0edb859faeb2eb362d97c (diff)
downloadrockbox-b15b7fac7e5aeafc0171ec51bb39b60f9024335d.tar.gz
rockbox-b15b7fac7e5aeafc0171ec51bb39b60f9024335d.zip
M:Robe 500 Power: Update battery Curve and simplify calculations.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@25715 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--firmware/target/arm/tms320dm320/mrobe-500/powermgmt-mr500.c31
1 files changed, 19 insertions, 12 deletions
diff --git a/firmware/target/arm/tms320dm320/mrobe-500/powermgmt-mr500.c b/firmware/target/arm/tms320dm320/mrobe-500/powermgmt-mr500.c
index d0f1a0bf59..5da03692f7 100644
--- a/firmware/target/arm/tms320dm320/mrobe-500/powermgmt-mr500.c
+++ b/firmware/target/arm/tms320dm320/mrobe-500/powermgmt-mr500.c
@@ -25,17 +25,20 @@
25#include "tsc2100.h" 25#include "tsc2100.h"
26#include "kernel.h" 26#include "kernel.h"
27 27
28unsigned short current_bat2 = 4200; 28unsigned short current_bat2 = 4100;
29unsigned short current_aux = 4200; 29unsigned short current_aux = 4100;
30static unsigned short current_voltage = 4200; 30static unsigned short current_voltage = 4100;
31
32/* This specifies the battery level that writes are still safe */
31const unsigned short battery_level_dangerous[BATTERY_TYPES_COUNT] = 33const unsigned short battery_level_dangerous[BATTERY_TYPES_COUNT] =
32{ 34{
33 3450 35 3600
34}; 36};
35 37
38/* Below this the player cannot be considered to operate reliably */
36const unsigned short battery_level_shutoff[BATTERY_TYPES_COUNT] = 39const unsigned short battery_level_shutoff[BATTERY_TYPES_COUNT] =
37{ 40{
38 3400 41 3580
39}; 42};
40 43
41/* Right now these are linear translations, it would be good to model them 44/* Right now these are linear translations, it would be good to model them
@@ -47,7 +50,7 @@ const unsigned short battery_level_shutoff[BATTERY_TYPES_COUNT] =
47/* voltages (millivolt) of 0%, 10%, ... 100% when charging disabled */ 50/* voltages (millivolt) of 0%, 10%, ... 100% when charging disabled */
48const unsigned short percent_to_volt_discharge[BATTERY_TYPES_COUNT][11] = 51const unsigned short percent_to_volt_discharge[BATTERY_TYPES_COUNT][11] =
49{ 52{
50 { 3400, 3300, 3600, 3700, 3800, 3900, 4000, 4100, 4200, 4300, 4400 }, 53 { 3600, 3650, 3700, 3750, 3800, 3850, 3900, 3950, 4000, 4090, 4150 },
51}; 54};
52 55
53/* voltages (millivolt) of 0%, 10%, ... 100% when charging enabled */ 56/* voltages (millivolt) of 0%, 10%, ... 100% when charging enabled */
@@ -63,12 +66,6 @@ unsigned int battery_adc_voltage(void)
63 static unsigned last_tick = 0; 66 static unsigned last_tick = 0;
64 short tsadc; 67 short tsadc;
65 68
66 if(tsc2100_read_volt(&bat1, &bat2, &aux)){
67 current_voltage=((short)((int)(bat1<<10)/4096*6*2.5));
68 current_bat2=((short)((int)(bat2<<10)/4096*6*2.5));
69 current_aux=((short)((int)(aux<<10)/4096*6*2.5));
70 }
71
72 tsadc=tsc2100_readreg(TSADC_PAGE, TSADC_ADDRESS); 69 tsadc=tsc2100_readreg(TSADC_PAGE, TSADC_ADDRESS);
73 70
74 /* Set the TSC2100 to read voltages if not busy with pen */ 71 /* Set the TSC2100 to read voltages if not busy with pen */
@@ -77,6 +74,16 @@ unsigned int battery_adc_voltage(void)
77 tsc2100_set_mode(true, 0x0B); 74 tsc2100_set_mode(true, 0x0B);
78 last_tick = current_tick; 75 last_tick = current_tick;
79 } 76 }
77
78 if(tsc2100_read_volt(&bat1, &bat2, &aux))
79 {
80 /* Calculation was:
81 * (val << 10) / 4096 * 6 * 2.5
82 */
83 current_voltage = (short)( (int) (bat1 * 15) >> 2 );
84 current_bat2 = (short)( (bat2 * 15) >> 2 );
85 current_aux = (short)( (aux * 15) >> 2 );
86 }
80 87
81 return current_voltage; 88 return current_voltage;
82} 89}