Skip to content

Commit 54b8263

Browse files
joelguittetkartben
authored andcommitted
drivers: counter: counter_reset api support to stm32 timer
Add support to reset counter value. Signed-off-by: Joel Guittet <[email protected]>
1 parent b25591b commit 54b8263

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

drivers/counter/counter_ll_stm32_timer.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,14 @@ static int counter_stm32_get_value(const struct device *dev, uint32_t *ticks)
155155
return 0;
156156
}
157157

158+
static int counter_stm32_reset(const struct device *dev)
159+
{
160+
const struct counter_stm32_config *config = dev->config;
161+
162+
LL_TIM_SetCounter(config->timer, 0);
163+
return 0;
164+
}
165+
158166
static uint32_t counter_stm32_ticks_add(uint32_t val1, uint32_t val2, uint32_t top)
159167
{
160168
uint32_t to_top;
@@ -577,6 +585,7 @@ static DEVICE_API(counter, counter_stm32_driver_api) = {
577585
.start = counter_stm32_start,
578586
.stop = counter_stm32_stop,
579587
.get_value = counter_stm32_get_value,
588+
.reset = counter_stm32_reset,
580589
.set_alarm = counter_stm32_set_alarm,
581590
.cancel_alarm = counter_stm32_cancel_alarm,
582591
.set_top_value = counter_stm32_set_top_value,

0 commit comments

Comments
 (0)