diff options
author | Simon Glass <sjg@chromium.org> | 2018-02-14 13:09:03 -0700 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2018-02-15 21:43:53 -0800 |
commit | 5ae1a9915d3c1ce72430e9654839e2a8da1da0bc (patch) | |
tree | f45b2e7a556917bc31a364b72f86dcb020702dc4 /common | |
parent | be8462028fd04c050688013f135d36ed0d1820ad (diff) | |
download | chrome-ec-5ae1a9915d3c1ce72430e9654839e2a8da1da0bc.tar.gz |
led_pwm: Add a few more features to the ledtest command
Add a way to report the current state using this command. This is useful
when debugging.
BUG=b:71902053
BRANCH=none
TEST=manually
> ledtest 0
PWM LED 0: led_id=0, auto_control=1
> ledtest 0 enable amber
> ledtest 0
PWM LED 0: led_id=0, auto_control=0
Change-Id: I478980d82573b60b536ea0f4dcf324b7ccfb6fdb
Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/919764
Diffstat (limited to 'common')
-rw-r--r-- | common/led_pwm.c | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/common/led_pwm.c b/common/led_pwm.c index 7e86a64bb2..6c1a190df9 100644 --- a/common/led_pwm.c +++ b/common/led_pwm.c @@ -164,18 +164,23 @@ int command_ledtest(int argc, char **argv) int pwm_led_id; int led_id; - if (argc < 3) + if (argc < 2) return EC_ERROR_PARAM_COUNT; - if (!parse_bool(argv[2], &enable)) - return EC_ERROR_PARAM2; - pwm_led_id = atoi(argv[1]); if ((pwm_led_id < 0) || (pwm_led_id >= CONFIG_LED_PWM_COUNT)) return EC_ERROR_PARAM1; - led_id = supported_led_ids[pwm_led_id]; + if (argc == 2) { + ccprintf("PWM LED %d: led_id=%d, auto_control=%d\n", + pwm_led_id, led_id, + led_auto_control_is_enabled(led_id) != 0); + return EC_SUCCESS; + } + if (!parse_bool(argv[2], &enable)) + return EC_ERROR_PARAM2; + /* Inverted because this drives auto control. */ led_auto_control(led_id, !enable); |