Skip to content

Commit f417ef5

Browse files
committed
drivers: led: shell: add blink cmd
Add blink command to led shell module Signed-off-by: Yishai Jaffe <[email protected]>
1 parent f6883c4 commit f417ef5

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

drivers/led/led_shell.c

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,27 @@ static int cmd_on(const struct shell *sh, size_t argc, char **argv)
8585
return err;
8686
}
8787

88+
static int cmd_blink(const struct shell *sh, size_t argc, char **argv)
89+
{
90+
const struct device *dev;
91+
uint32_t led;
92+
int err;
93+
94+
err = parse_common_args(sh, argv, &dev, &led);
95+
if (err < 0) {
96+
return err;
97+
}
98+
99+
shell_print(sh, "%s: blinking LED %d", dev->name, led);
100+
101+
err = led_blink(dev, led);
102+
if (err) {
103+
shell_error(sh, "Error: %d", err);
104+
}
105+
106+
return err;
107+
}
108+
88109
static const char *led_color_to_str(uint8_t color)
89110
{
90111
switch (color) {
@@ -350,6 +371,7 @@ SHELL_DYNAMIC_CMD_CREATE(dsub_device_name, device_name_get);
350371
SHELL_STATIC_SUBCMD_SET_CREATE(
351372
sub_led, SHELL_CMD_ARG(off, &dsub_device_name, "<device> <led>", cmd_off, 3, 0),
352373
SHELL_CMD_ARG(on, &dsub_device_name, "<device> <led>", cmd_on, 3, 0),
374+
SHELL_CMD_ARG(blink, &dsub_device_name, "<device> <led>", cmd_blink, 3, 0),
353375
SHELL_CMD_ARG(get_info, &dsub_device_name, "<device> <led>", cmd_get_info, 3, 0),
354376
SHELL_CMD_ARG(set_brightness, &dsub_device_name, "<device> <led> <value [0-100]>",
355377
cmd_set_brightness, 4, 0),

0 commit comments

Comments
 (0)