diff options
author | Simon Glass <sjg@chromium.org> | 2018-02-14 13:09:03 -0700 |
---|---|---|
committer | Daisuke Nojiri <dnojiri@chromium.org> | 2018-02-19 10:33:13 -0800 |
commit | e283fb91efae31caaa9c523a2b022e2af4e9ec12 (patch) | |
tree | d44f71e1e1f95aa157027643503657a4f29067ae | |
parent | 2ec462ccd023e78debeb6f14cebd96b81a7ada54 (diff) | |
download | chrome-ec-e283fb91efae31caaa9c523a2b022e2af4e9ec12.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
-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); |