Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 23 additions & 21 deletions drivers/counter/counter_timer_shell.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
#define ARGV_ONESHOT_TIME 3

/* number of periodic interrupts */
#define PERIODIC_CYCLES 10
#define MAX_DELAY UINT32_MAX
#define MAX_CHANNEL 255U
#define PERIODIC_CYCLES 10
#define MAX_DELAY UINT32_MAX
#define MAX_CHANNEL 255U

static struct k_sem timer_sem;

Expand All @@ -29,8 +29,8 @@ static void timer_top_handler(const struct device *counter_dev, void *user_data)
k_sem_give(&timer_sem);
}

static void timer_alarm_handler(const struct device *counter_dev, uint8_t chan_id,
uint32_t ticks, void *user_data)
static void timer_alarm_handler(const struct device *counter_dev, uint8_t chan_id, uint32_t ticks,
void *user_data)
{
ARG_UNUSED(counter_dev);

Expand Down Expand Up @@ -69,7 +69,7 @@ static int cmd_timer_free_running(const struct shell *shctx, size_t argc, char *

shell_info(shctx, "%s: Timer is freerunning", argv[ARGV_DEV]);

return 0;
return 0;
}

static int cmd_timer_stop(const struct shell *shctx, size_t argc, char **argv)
Expand Down Expand Up @@ -215,20 +215,22 @@ static void device_name_get(size_t idx, struct shell_static_entry *entry)

SHELL_DYNAMIC_CMD_CREATE(dsub_device_name, device_name_get);

SHELL_STATIC_SUBCMD_SET_CREATE(sub_timer,
SHELL_CMD_ARG(periodic, &dsub_device_name,
"timer periodic <timer_instance_node_id> <time_in_us>",
cmd_timer_periodic, 3, 0),
SHELL_CMD_ARG(oneshot, &dsub_device_name,
"timer oneshot <timer_instance_node_id> <channel_id> <time_in_us>",
cmd_timer_oneshot, 4, 0),
SHELL_CMD_ARG(freerun, &dsub_device_name,
"timer freerun <timer_instance_node_id>",
cmd_timer_free_running, 2, 0),
SHELL_CMD_ARG(stop, &dsub_device_name,
"timer stop <timer_instance_node_id>",
cmd_timer_stop, 2, 0),
SHELL_SUBCMD_SET_END /* array terminated. */
);
SHELL_STATIC_SUBCMD_SET_CREATE(
sub_timer,
SHELL_CMD_ARG(periodic, &dsub_device_name,
SHELL_HELP("Start a periodic timer with specified interval",
"<timer_instance_node_id> <time_in_us>"),
cmd_timer_periodic, 3, 0),
SHELL_CMD_ARG(oneshot, &dsub_device_name,
SHELL_HELP("Set a one-shot alarm on specified channel",
"<timer_instance_node_id> <channel_id> <time_in_us>"),
cmd_timer_oneshot, 4, 0),
SHELL_CMD_ARG(freerun, &dsub_device_name,
SHELL_HELP("Start a timer in free-running mode", "<timer_instance_node_id>"),
cmd_timer_free_running, 2, 0),
SHELL_CMD_ARG(stop, &dsub_device_name,
SHELL_HELP("Stop a timer", "<timer_instance_node_id>"), cmd_timer_stop, 2, 0),
SHELL_SUBCMD_SET_END /* array terminated. */
);

SHELL_CMD_REGISTER(timer, &sub_timer, "Timer commands", NULL);