Skip to content

Commit acdfb06

Browse files
Surya-Tummakartben
authored andcommitted
drivers: counter: shell: start counter after configuration
Call counter_start() after configuration to prevent indefinite hangs. Signed-off-by: Surya Prakash T <suryat@aerlync.com>
1 parent 3feed15 commit acdfb06

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

drivers/counter/counter_timer_shell.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,12 @@ static int cmd_timer_oneshot(const struct shell *shctx, size_t argc, char **argv
137137
alarm_cfg.callback = timer_alarm_handler;
138138
alarm_cfg.user_data = NULL;
139139

140+
err = counter_start(timer_dev);
141+
if (err != 0 && err != -EALREADY) {
142+
shell_error(shctx, "%s: failed to start counter, err: %d", argv[ARGV_DEV], err);
143+
return err;
144+
}
145+
140146
/* set an alarm */
141147
err = counter_set_channel_alarm(timer_dev, (uint8_t)channel, &alarm_cfg);
142148
if (err != 0) {
@@ -189,6 +195,12 @@ static int cmd_timer_periodic(const struct shell *shctx, size_t argc, char **arg
189195
top_cfg.callback = timer_top_handler;
190196
top_cfg.user_data = NULL;
191197

198+
err = counter_start(timer_dev);
199+
if (err != 0 && err != -EALREADY) {
200+
shell_error(shctx, "%s: failed to start counter, err: %d", argv[ARGV_DEV], err);
201+
return err;
202+
}
203+
192204
/* set top value */
193205
err = counter_set_top_value(timer_dev, &top_cfg);
194206
if (err != 0) {

0 commit comments

Comments
 (0)