From d019aea47b70ad9b6be488ea836e05fac0da9f88 Mon Sep 17 00:00:00 2001 From: James Roy Date: Wed, 19 Mar 2025 12:40:55 +0800 Subject: [PATCH] drivers: counter: Add native-posix implementation example Implement the '.reset' interface in the native-posix driver to allow the upper layers to use the counter_reset function. Signed-off-by: James Roy --- drivers/counter/counter_native_sim.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/drivers/counter/counter_native_sim.c b/drivers/counter/counter_native_sim.c index 1f66d54fbc3..c044f8eef3d 100644 --- a/drivers/counter/counter_native_sim.c +++ b/drivers/counter/counter_native_sim.c @@ -124,6 +124,14 @@ static int ctr_get_value(const struct device *dev, uint32_t *ticks) return 0; } +static int ctr_reset(const struct device *dev) +{ + ARG_UNUSED(dev); + + hw_counter_reset(); + return 0; +} + static uint32_t ctr_get_pending_int(const struct device *dev) { ARG_UNUSED(dev); @@ -237,6 +245,7 @@ static DEVICE_API(counter, ctr_api) = { .start = ctr_start, .stop = ctr_stop, .get_value = ctr_get_value, + .reset = ctr_reset, .set_alarm = ctr_set_alarm, .cancel_alarm = ctr_cancel_alarm, .set_top_value = ctr_set_top_value,