Skip to content

Commit dca598e

Browse files
sylvioalveskartben
authored andcommitted
drivers: counter: esp32: add reset counter function
Adds option to reset counter value. Signed-off-by: Sylvio Alves <[email protected]>
1 parent 8eb075f commit dca598e

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

drivers/counter/counter_esp32_tmr.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,10 +204,20 @@ uint32_t counter_esp32_get_freq(const struct device *dev)
204204
return data->clock_src_hz / config->config.divider;
205205
}
206206

207+
static int counter_esp32_reset(const struct device *dev)
208+
{
209+
struct counter_esp32_data *data = dev->data;
210+
211+
timer_hal_set_counter_value(&data->hal_ctx, 0);
212+
213+
return 0;
214+
}
215+
207216
static DEVICE_API(counter, counter_api) = {
208217
.start = counter_esp32_start,
209218
.stop = counter_esp32_stop,
210219
.get_value = counter_esp32_get_value,
220+
.reset = counter_esp32_reset,
211221
.get_value_64 = counter_esp32_get_value_64,
212222
.set_alarm = counter_esp32_set_alarm,
213223
.cancel_alarm = counter_esp32_cancel_alarm,

0 commit comments

Comments
 (0)