diff options
author | Alec Berg <alecaberg@chromium.org> | 2014-08-21 15:37:23 -0700 |
---|---|---|
committer | chrome-internal-fetch <chrome-internal-fetch@google.com> | 2014-08-22 05:47:59 +0000 |
commit | 1b82905cfe66ae472cdb42f0e17c2ec94aa466c3 (patch) | |
tree | bd82db20027056415ace1b5d0d34bd8b66a26005 /common/charge_state_v2.c | |
parent | e307172bd581c5ec3ce2944333d09412626e6e10 (diff) | |
download | chrome-ec-1b82905cfe66ae472cdb42f0e17c2ec94aa466c3.tar.gz |
Add hysteresis to host events for battery capacity changed
Adds a small threshold for sending a host event to battery whenever
the full capacity changes. This helps avoid constant host events
when the battery decides the capacity is going back and forth 1mAh
BUG=none
BRANCH=none
TEST=load on samus. set LFCC_EVENT_THRESHOLD to 1 and see host
events very often. set LFCC_EVENT_THRESHOLD to 5 and see no host
events.
Change-Id: I2dc38f04e1a634539837dfed19b10ccfcfd0a8a3
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/213668
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
Diffstat (limited to 'common/charge_state_v2.c')
-rw-r--r-- | common/charge_state_v2.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/common/charge_state_v2.c b/common/charge_state_v2.c index f51a03f185..ea196b8f28 100644 --- a/common/charge_state_v2.c +++ b/common/charge_state_v2.c @@ -29,6 +29,7 @@ #define LOW_BATTERY_SHUTDOWN_TIMEOUT_US (LOW_BATTERY_SHUTDOWN_TIMEOUT * SECOND) #define PRECHARGE_TIMEOUT_US (PRECHARGE_TIMEOUT * SECOND) +#define LFCC_EVENT_THRESH 5 /* Full-capacity change reqd for host event */ /* * State for charger_task(). Here so we can reset it on a HOOK_INIT, and @@ -187,7 +188,8 @@ static void update_dynamic_battery_info(void) cap_changed = 0; if (!(curr.batt.flags & BATT_FLAG_BAD_FULL_CAPACITY) && - curr.batt.full_capacity != *memmap_lfcc) { + (curr.batt.full_capacity <= (*memmap_lfcc - LFCC_EVENT_THRESH) || + curr.batt.full_capacity >= (*memmap_lfcc + LFCC_EVENT_THRESH))) { *memmap_lfcc = curr.batt.full_capacity; cap_changed = 1; } |