summaryrefslogtreecommitdiff
path: root/util
diff options
context:
space:
mode:
authorAseda Aboagye <aaboagye@google.com>2018-08-17 10:36:44 -0700
committerchrome-bot <chrome-bot@chromium.org>2018-08-17 20:39:05 -0700
commit6bc276f40d3ec84de7dd5dfeeef25487eabc8ab2 (patch)
treea32942ad4a0c46e0c74e3fcc4b755edbe45fc718 /util
parent13e92a73c57d83eef08f6cf496e63a6f63f550d4 (diff)
downloadchrome-ec-6bc276f40d3ec84de7dd5dfeeef25487eabc8ab2.tar.gz
adc: Add ectool command for reading ADC channels.
BUG=b:76155036, b:112757066 BRANCH=None TEST=Flash nocturne; update ectool; verify that `ectool adcread <ch>` works as expected. Change-Id: I42545d25f005a7eb9e0af54c8b5cb72d5d844084 Signed-off-by: Aseda Aboagye <aaboagye@google.com> Reviewed-on: https://chromium-review.googlesource.com/1180095 Commit-Ready: Aseda Aboagye <aaboagye@chromium.org> Tested-by: Aseda Aboagye <aaboagye@chromium.org> Reviewed-by: Edward Hill <ecgh@chromium.org>
Diffstat (limited to 'util')
-rw-r--r--util/ectool.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/util/ectool.c b/util/ectool.c
index 929d5a4c65..e6332373c3 100644
--- a/util/ectool.c
+++ b/util/ectool.c
@@ -54,6 +54,8 @@ static struct option long_opts[] = {
const char help_str[] =
"Commands:\n"
+ " adcread <channel>\n"
+ " Read an ADC channel.\n"
" addentropy [reset]\n"
" Add entropy to device secret\n"
" autofanctrl <on>\n"
@@ -384,6 +386,31 @@ static int read_mapped_string(uint8_t offset, char *buffer, int max_size)
return ret;
}
+int cmd_adc_read(int argc, char *argv[])
+{
+ char *e;
+ struct ec_params_adc_read p;
+ struct ec_response_adc_read r;
+ int rv;
+
+ if (argc < 2) {
+ fprintf(stderr, "Usage: %s <adc channel>\n", argv[0]);
+ return -1;
+ }
+
+ p.adc_channel = (uint8_t)strtoul(argv[1], &e, 0);
+ if (e && *e) {
+ fprintf(stderr, "\"%s\": invalid channel!\n", argv[1]);
+ return -1;
+ }
+
+ rv = ec_command(EC_CMD_ADC_READ, 0, &p, sizeof(p), &r, sizeof(r));
+ if (rv > 0)
+ printf("%s: %d\n", argv[1], r.adc_value);
+
+ return rv;
+}
+
int cmd_add_entropy(int argc, char *argv[])
{
struct ec_params_rollback_add_entropy p;
@@ -8229,6 +8256,7 @@ int cmd_cec(int argc, char *argv[])
/* NULL-terminated list of commands */
const struct command commands[] = {
+ {"adcread", cmd_adc_read},
{"addentropy", cmd_add_entropy},
{"autofanctrl", cmd_thermal_auto_fan_ctrl},
{"backlight", cmd_lcd_backlight},