summaryrefslogtreecommitdiff
path: root/firmware/target/arm/tms320dm320/mrobe-500/powermgmt-mr500.c
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/target/arm/tms320dm320/mrobe-500/powermgmt-mr500.c')
-rwxr-xr-xfirmware/target/arm/tms320dm320/mrobe-500/powermgmt-mr500.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/firmware/target/arm/tms320dm320/mrobe-500/powermgmt-mr500.c b/firmware/target/arm/tms320dm320/mrobe-500/powermgmt-mr500.c
index 60949b2c18..b81c34ac3b 100755
--- a/firmware/target/arm/tms320dm320/mrobe-500/powermgmt-mr500.c
+++ b/firmware/target/arm/tms320dm320/mrobe-500/powermgmt-mr500.c
@@ -25,29 +25,35 @@
25#include "tsc2100.h" 25#include "tsc2100.h"
26#include "kernel.h" 26#include "kernel.h"
27 27
28unsigned short current_bat2 = 3910;
29unsigned short current_aux = 3910;
28static unsigned short current_voltage = 3910; 30static unsigned short current_voltage = 3910;
29const unsigned short battery_level_dangerous[BATTERY_TYPES_COUNT] = 31const unsigned short battery_level_dangerous[BATTERY_TYPES_COUNT] =
30{ 32{
31 0 33 3450
32}; 34};
33 35
34const unsigned short battery_level_shutoff[BATTERY_TYPES_COUNT] = 36const unsigned short battery_level_shutoff[BATTERY_TYPES_COUNT] =
35{ 37{
36 0 38 3400
37}; 39};
38 40
41/* Right now these are linear translations, it would be good to model them
42 * appropriate to the actual battery curve.
43 */
44
39/* 6.10 format */ 45/* 6.10 format */
40 46
41/* voltages (millivolt) of 0%, 10%, ... 100% when charging disabled */ 47/* voltages (millivolt) of 0%, 10%, ... 100% when charging disabled */
42const unsigned short percent_to_volt_discharge[BATTERY_TYPES_COUNT][11] = 48const unsigned short percent_to_volt_discharge[BATTERY_TYPES_COUNT][11] =
43{ 49{
44 { 375, 1125, 1500, 1875, 2250, 2625, 3000, 3375, 3750, 4500, 4950 }, 50 { 3400, 3300, 3600, 3700, 3800, 3900, 4000, 4100, 4200, 4300, 4400 },
45}; 51};
46 52
47/* voltages (millivolt) of 0%, 10%, ... 100% when charging enabled */ 53/* voltages (millivolt) of 0%, 10%, ... 100% when charging enabled */
48const unsigned short percent_to_volt_charge[11] = 54const unsigned short percent_to_volt_charge[11] =
49{ 55{
50 375, 1125, 1500, 1875, 2250, 2625, 3000, 3375, 3750, 4500, 4950, 56 4000, 4105, 4210, 4315, 4420, 4525, 4630, 4735, 4840, 4945, 5050,
51}; 57};
52 58
53/* Returns battery voltage from ADC [millivolts] */ 59/* Returns battery voltage from ADC [millivolts] */
@@ -59,6 +65,8 @@ unsigned int battery_adc_voltage(void)
59 65
60 if(tsc2100_read_volt(&bat1, &bat2, &aux)){ 66 if(tsc2100_read_volt(&bat1, &bat2, &aux)){
61 current_voltage=((short)((int)(bat1<<10)/4096*6*2.5)); 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));
62 } 70 }
63 71
64 if (TIME_BEFORE(last_tick+2*HZ, current_tick)) 72 if (TIME_BEFORE(last_tick+2*HZ, current_tick))