tests: boards: board_shell: enable DAC commands
Enable DAC commands in the board_shell test application. Signed-off-by: Henrik Brix Andersen <henrik@brixandersen.dk>
This commit is contained in:
parent
8a5ba4539c
commit
7ede80be46
2 changed files with 9 additions and 20 deletions
|
@ -16,19 +16,15 @@
|
|||
struct args_index {
|
||||
u8_t device;
|
||||
u8_t channel;
|
||||
u8_t reference;
|
||||
u8_t value;
|
||||
u8_t buffered;
|
||||
u8_t resolution;
|
||||
};
|
||||
|
||||
static const struct args_index args_indx = {
|
||||
.device = 1,
|
||||
.channel = 2,
|
||||
.reference = 3,
|
||||
.value = 3,
|
||||
.buffered = 4,
|
||||
.resolution = 4,
|
||||
.resolution = 3,
|
||||
};
|
||||
|
||||
static int cmd_setup(const struct shell *shell, size_t argc, char **argv)
|
||||
|
@ -44,14 +40,7 @@ static int cmd_setup(const struct shell *shell, size_t argc, char **argv)
|
|||
}
|
||||
|
||||
cfg.channel_id = strtoul(argv[args_indx.channel], NULL, 0);
|
||||
/* TODO: Allow text input for reference */
|
||||
cfg.reference = strtoul(argv[args_indx.reference], NULL, 0);
|
||||
|
||||
if (argc == (args_indx.buffered + 1)) {
|
||||
cfg.buffered = strtoul(argv[args_indx.buffered], NULL, 2);
|
||||
} else {
|
||||
cfg.buffered = false;
|
||||
}
|
||||
cfg.resolution = strtoul(argv[args_indx.resolution], NULL, 0);
|
||||
|
||||
err = dac_channel_setup(dac, &cfg);
|
||||
if (err) {
|
||||
|
@ -65,7 +54,6 @@ static int cmd_setup(const struct shell *shell, size_t argc, char **argv)
|
|||
static int cmd_write_value(const struct shell *shell, size_t argc, char **argv)
|
||||
{
|
||||
struct device *dac;
|
||||
u8_t resolution;
|
||||
u8_t channel;
|
||||
u32_t value;
|
||||
int err;
|
||||
|
@ -78,9 +66,8 @@ static int cmd_write_value(const struct shell *shell, size_t argc, char **argv)
|
|||
|
||||
channel = strtoul(argv[args_indx.channel], NULL, 0);
|
||||
value = strtoul(argv[args_indx.value], NULL, 0);
|
||||
resolution = strtoul(argv[args_indx.resolution], NULL, 0);
|
||||
|
||||
err = dac_write_value(dac, channel, value, resolution);
|
||||
err = dac_write_value(dac, channel, value);
|
||||
if (err) {
|
||||
shell_error(shell, "Failed to write DAC value (err %d)", err);
|
||||
return err;
|
||||
|
@ -90,10 +77,10 @@ static int cmd_write_value(const struct shell *shell, size_t argc, char **argv)
|
|||
}
|
||||
|
||||
SHELL_STATIC_SUBCMD_SET_CREATE(dac_cmds,
|
||||
SHELL_CMD_ARG(setup, NULL, "<device> <channel> <reference> [buffered]",
|
||||
cmd_setup, 4, 1),
|
||||
SHELL_CMD_ARG(write_value, NULL, "<device> <channel> <value> <resolution>",
|
||||
cmd_write_value, 5, 0),
|
||||
SHELL_CMD_ARG(setup, NULL, "<device> <channel> <resolution>",
|
||||
cmd_setup, 4, 0),
|
||||
SHELL_CMD_ARG(write_value, NULL, "<device> <channel> <value>",
|
||||
cmd_write_value, 4, 0),
|
||||
SHELL_SUBCMD_SET_END
|
||||
);
|
||||
|
||||
|
|
|
@ -27,3 +27,5 @@ CONFIG_EEPROM=y
|
|||
CONFIG_EEPROM_SHELL=y
|
||||
CONFIG_SENSOR=y
|
||||
CONFIG_SENSOR_SHELL=y
|
||||
CONFIG_DAC=y
|
||||
CONFIG_DAC_SHELL=y
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue