diff --git a/drivers/dac/dac_shell.c b/drivers/dac/dac_shell.c index 97d9feb7e5c991..48b7455cac4717 100644 --- a/drivers/dac/dac_shell.c +++ b/drivers/dac/dac_shell.c @@ -94,14 +94,31 @@ static int cmd_write_value(const struct shell *sh, size_t argc, char **argv) return 0; } +static bool device_is_dac(const struct device *dev) +{ + return device_is_ready(dev) && DEVICE_API_IS(dac, dev); +} + +static void device_name_get(size_t idx, struct shell_static_entry *entry) +{ + const struct device *dev = shell_device_filter(idx, device_is_dac); + + entry->syntax = (dev != NULL) ? dev->name : NULL; + entry->handler = NULL; + entry->help = NULL; + entry->subcmd = NULL; +} + +SHELL_DYNAMIC_CMD_CREATE(dsub_device_name, device_name_get); + SHELL_STATIC_SUBCMD_SET_CREATE(dac_cmds, - SHELL_CMD_ARG(setup, NULL, + SHELL_CMD_ARG(setup, &dsub_device_name, "Setup DAC channel\n" "Usage: setup [-b] [-i]\n" "-b Enable output buffer\n" "-i Connect internally", cmd_setup, 4, 2), - SHELL_CMD_ARG(write_value, NULL, + SHELL_CMD_ARG(write_value, &dsub_device_name, "Write DAC value\n" "Usage: write ", cmd_write_value, 4, 0),