diff options
author | Bill Richardson <wfrichar@chromium.org> | 2013-11-05 07:00:17 -0800 |
---|---|---|
committer | chrome-internal-fetch <chrome-internal-fetch@google.com> | 2013-11-05 22:45:21 +0000 |
commit | d64de2bb1b903214ce19951918910a9f9ff10abf (patch) | |
tree | 6086702c7cac39ca78e04888703ead871be8e5ca /common/battery.c | |
parent | 48dfd8c5ee5679c13b3931cac843b4e3dc1f9ed4 (diff) | |
download | chrome-ec-d64de2bb1b903214ce19951918910a9f9ff10abf.tar.gz |
Show smart battery status with 'battery' command
The smart battery status register holds some useful info. This displays it
along with all the other stuff.
This decodes the alarm and status bits, but not the error code, since that
field is only valid immediately after a failed i2c transaction (that's how
the battery indicates error). Since we do all sorts of automatic battery
probing in other threads, that value will never be reliable when we run the
"battery" console command.
BUG=none
BRANCH=none
TEST=manual
Run "battery". You should see a new line amongst the output:
Status: 0x00c0 DCHG INIT
Change-Id: I5e684198af2cf7767f89786c91a7d946ad95d4c2
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/175659
Diffstat (limited to 'common/battery.c')
-rw-r--r-- | common/battery.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/common/battery.c b/common/battery.c index 25c4bcf1f9..0d47378f94 100644 --- a/common/battery.c +++ b/common/battery.c @@ -38,6 +38,30 @@ static int print_battery_info(void) char text[32]; const char *unit; + print_item_name("Status:"); + if (check_print_error(battery_status(&value))) { + const char * const st[] = {"EMPTY", "FULL", "DCHG", "INIT",}; + const char * const al[] = {"RT", "RC", "--", "TD", + "OT", "--", "TC", "OC"}; + int i; + ccprintf("0x%04x", value); + + /* bits 0-3 are only valid when the previous transaction + * failed, so ignore them */ + + /* bits 4-7 are status */ + for (i = 0; i < 4; i++) + if (value & (1 << (i+4))) + ccprintf(" %s", st[i]); + + /* bits 15-8 are alarms */ + for (i = 0; i < 8; i++) + if (value & (1 << (i+8))) + ccprintf(" %s", al[i]); + + ccprintf("\n"); + } + print_item_name("Temp:"); if (check_print_error(battery_temperature(&value))) ccprintf("0x%04x = %.1d K (%.1d C)\n", |