summaryrefslogtreecommitdiff
path: root/board/winky/battery.c
diff options
context:
space:
mode:
Diffstat (limited to 'board/winky/battery.c')
-rwxr-xr-xboard/winky/battery.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/board/winky/battery.c b/board/winky/battery.c
index 1b21e6ee28..8c662ca149 100755
--- a/board/winky/battery.c
+++ b/board/winky/battery.c
@@ -67,6 +67,7 @@ DECLARE_CONSOLE_COMMAND(battcutoff, command_battcutoff,
NULL);
#ifdef CONFIG_BATTERY_OVERRIDE_PARAMS
+static timestamp_t start_lowvoltage_time;
static int oem_battery_state;
#define OEM_BATTERY_STATE_DEFAULT 0x00
#define OEM_BATTERY_STATE_ERROR 0x01
@@ -104,7 +105,15 @@ void battery_override_params(struct batt_params *batt)
/* Check battery overvoltage */
if(batt->voltage > info.voltage_max) {
oem_battery_state |= OEM_BATTERY_STATE_ERROR;
+ } else if(batt->voltage < info.voltage_min) {
+ if((get_time().val - start_lowvoltage_time.val) > 2*HOUR) {
+ oem_battery_state |= OEM_BATTERY_STATE_ERROR;
+ }
+ } else {
+ start_lowvoltage_time = get_time();
}
+ } else if((chstate == PWR_STATE_IDLE) || (chstate == PWR_STATE_IDLE0)) {
+ start_lowvoltage_time = get_time();
}
}