Skip to content

Commit d019aea

Browse files
rruuaanngkartben
authored andcommitted
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 <[email protected]>
1 parent 355d904 commit d019aea

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

drivers/counter/counter_native_sim.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,14 @@ static int ctr_get_value(const struct device *dev, uint32_t *ticks)
124124
return 0;
125125
}
126126

127+
static int ctr_reset(const struct device *dev)
128+
{
129+
ARG_UNUSED(dev);
130+
131+
hw_counter_reset();
132+
return 0;
133+
}
134+
127135
static uint32_t ctr_get_pending_int(const struct device *dev)
128136
{
129137
ARG_UNUSED(dev);
@@ -237,6 +245,7 @@ static DEVICE_API(counter, ctr_api) = {
237245
.start = ctr_start,
238246
.stop = ctr_stop,
239247
.get_value = ctr_get_value,
248+
.reset = ctr_reset,
240249
.set_alarm = ctr_set_alarm,
241250
.cancel_alarm = ctr_cancel_alarm,
242251
.set_top_value = ctr_set_top_value,

0 commit comments

Comments
 (0)