diff --git a/makefiles/pseudomodules.inc.mk b/makefiles/pseudomodules.inc.mk index e71195bf85..c26a8776cd 100644 --- a/makefiles/pseudomodules.inc.mk +++ b/makefiles/pseudomodules.inc.mk @@ -64,7 +64,6 @@ PSEUDOMODULES += event_% PSEUDOMODULES += event_timeout PSEUDOMODULES += event_timeout_ztimer PSEUDOMODULES += evtimer_mbox -PSEUDOMODULES += evtimer_on_ztimer PSEUDOMODULES += fatfs_vfs_format PSEUDOMODULES += fmt_% PSEUDOMODULES += gcoap_forward_proxy diff --git a/sys/Makefile.dep b/sys/Makefile.dep index b8a0dd8b11..b27127765e 100644 --- a/sys/Makefile.dep +++ b/sys/Makefile.dep @@ -998,14 +998,7 @@ ifneq (,$(filter ztimer64%,$(USEMODULE))) endif ifneq (,$(filter evtimer,$(USEMODULE))) - ifneq (,$(filter evtimer_on_ztimer,$(USEMODULE))) - USEMODULE += ztimer_msec - else - USEMODULE += xtimer - ifneq (,$(filter ztimer_xtimer_compat,$(USEMODULE))) - USEMODULE += evtimer_on_ztimer - endif - endif + USEMODULE += ztimer_msec endif # handle xtimer's deps. Needs to be done *after* ztimer diff --git a/sys/evtimer/evtimer.c b/sys/evtimer/evtimer.c index 4821336d37..a8f8132446 100644 --- a/sys/evtimer/evtimer.c +++ b/sys/evtimer/evtimer.c @@ -93,19 +93,9 @@ static void _del_event_from_list(evtimer_t *evtimer, evtimer_event_t *event) static void _set_timer(evtimer_t *evtimer) { evtimer_event_t *next_event = evtimer->events; - -#if IS_USED(MODULE_EVTIMER_ON_ZTIMER) evtimer->base = ztimer_set(ZTIMER_MSEC, &evtimer->timer, next_event->offset); DEBUG("evtimer: now=%" PRIu32 " ms setting ztimer to %" PRIu32 " ms\n", evtimer->base, next_event->offset); -#else - uint64_t offset_us = (uint64_t)next_event->offset * US_PER_MS; - - DEBUG("evtimer: now=%" PRIu32 " us setting xtimer to %" PRIu32 ":%" PRIu32 " us\n", - xtimer_now_usec(), (uint32_t)(offset_us >> 32), (uint32_t)(offset_us)); - - xtimer_set64(&evtimer->timer, offset_us); -#endif } static void _update_timer(evtimer_t *evtimer) @@ -114,15 +104,10 @@ static void _update_timer(evtimer_t *evtimer) _set_timer(evtimer); } else { -#if IS_USED(MODULE_EVTIMER_ON_ZTIMER) ztimer_remove(ZTIMER_MSEC, &evtimer->timer); -#else - xtimer_remove(&evtimer->timer); -#endif } } -#if IS_USED(MODULE_EVTIMER_ON_ZTIMER) static void _update_head_offset(evtimer_t *evtimer) { if (evtimer->events) { @@ -137,23 +122,6 @@ static void _update_head_offset(evtimer_t *evtimer) evtimer->base = now; } } -#else /* IS_USED(MODULE_EVTIMER_ON_ZTIMER) */ -static uint32_t _get_offset(xtimer_t *timer) -{ - uint64_t left = xtimer_left_usec(timer); - /* add half of 125 so integer division rounds to nearest */ - return div_u64_by_125((left >> 3) + 62); -} - -static void _update_head_offset(evtimer_t *evtimer) -{ - if (evtimer->events) { - evtimer_event_t *event = evtimer->events; - event->offset = _get_offset(&evtimer->timer); - DEBUG("evtimer: _update_head_offset(): new head offset %" PRIu32 "\n", event->offset); - } -} -#endif /* !IS_USED(MODULE_EVTIMER_ON_ZTIMER) */ void evtimer_add(evtimer_t *evtimer, evtimer_event_t *event) { diff --git a/sys/include/evtimer.h b/sys/include/evtimer.h index 66ff0a5d4b..28844200c2 100644 --- a/sys/include/evtimer.h +++ b/sys/include/evtimer.h @@ -15,24 +15,20 @@ * * @note Experimental and likely to replaced with unified timer API * - * RIOT's main timer subsystem is @ref sys_xtimer "xtimer", but for many - * applications @ref sys_xtimer "xtimer's" 64-bit absolute time values are - * wasteful or clumsy to use. - * - * Compared to @ref sys_xtimer "xtimer", evtimer offers: + * RIOT's main timer subsystem is @ref sys_ztimer "ztimer" but compared to + * @ref sys_ztimer "ztimer", evtimer offers: * * - only relative 32-bit millisecond timer values * Events can be scheduled with a relative offset of up to ~49.7 days in the * future. - * **For time-critical stuff, use @ref sys_xtimer "xtimer"!** + * **For time-critical stuff, use @ref sys_ztimer "ztimer"!** * - more flexible, "intrusive" timer type @ref evtimer_event_t only contains * the necessary fields, which can be extended as needed, and handlers define * actions taken on timer triggers. Check out @ref evtimer_msg_event_t as * example. - * - uses @ref sys_xtimer "xtimer" as backend by default. Alternatively, with - * the pseudomodule "evtimer_on_ztimer" compiled in, evtimer is backend by - * @ref sys_ztimer "ZTIMER_MSEC". - * + * - when a number of timeouts with the same callback function need to be + * scheduled, evtimer is using less RAM (due to storing the callback function + * only once), while each ztimer has a function pointer for the callback. * @{ * * @file @@ -48,13 +44,7 @@ #include #include "modules.h" -#if IS_USED(MODULE_EVTIMER_ON_ZTIMER) #include "ztimer.h" -#else -#include "xtimer.h" -#endif - -#include "timex.h" #ifdef __cplusplus extern "C" { @@ -77,12 +67,8 @@ typedef void(*evtimer_callback_t)(evtimer_event_t* event); * @brief Event timer */ typedef struct { -#if IS_USED(MODULE_EVTIMER_ON_ZTIMER) ztimer_t timer; /**< Timer */ uint32_t base; /**< Absolute time the first event is built on */ -#else - xtimer_t timer; /**< Timer */ -#endif evtimer_callback_t callback; /**< Handler function for this evtimer's event type */ evtimer_event_t *events; /**< Event queue */ @@ -128,11 +114,7 @@ void evtimer_print(const evtimer_t *evtimer); */ static inline uint32_t evtimer_now_msec(void) { -#if IS_USED(MODULE_EVTIMER_ON_ZTIMER) return ztimer_now(ZTIMER_MSEC); -#else - return xtimer_now_usec64() / US_PER_MS; -#endif } #ifdef __cplusplus diff --git a/sys/ztimer/Makefile.dep b/sys/ztimer/Makefile.dep index eec51b70b0..e20ba7e2a7 100644 --- a/sys/ztimer/Makefile.dep +++ b/sys/ztimer/Makefile.dep @@ -11,13 +11,6 @@ ifneq (,$(filter ztimer,$(USEMODULE))) DEFAULT_MODULE += ztimer_init endif -# unless ztimer_xtimer_compat is used, make xtimer use ztimer_usec as backend. -ifneq (,$(filter ztimer,$(USEMODULE))) - ifneq (,$(filter evtimer,$(USEMODULE))) - USEMODULE += evtimer_on_ztimer - endif -endif - ifneq (,$(filter ztimer_xtimer_compat,$(USEMODULE))) USEMODULE += ztimer_usec endif @@ -27,11 +20,6 @@ ifneq (,$(filter ztimer64_xtimer_compat,$(USEMODULE))) USEMODULE += ztimer_xtimer_compat endif -# make evtimer use ztimer_msec as low level timer -ifneq (,$(filter evtimer_on_ztimer,$(USEMODULE))) - USEMODULE += ztimer_msec -endif - ifneq (,$(filter ztimer_%,$(USEMODULE))) USEMODULE += ztimer_core USEMODULE += ztimer_extend diff --git a/tests/sys/evtimer_msg/Makefile b/tests/sys/evtimer_msg/Makefile index aacc3125a5..007687a90c 100644 --- a/tests/sys/evtimer_msg/Makefile +++ b/tests/sys/evtimer_msg/Makefile @@ -1,7 +1,7 @@ include ../Makefile.sys_common USEMODULE += evtimer -USEMODULE += xtimer +USEMODULE += ztimer_msec # This test randomly fails on `native` so disable it from CI TEST_ON_CI_BLACKLIST += native diff --git a/tests/sys/evtimer_msg/main.c b/tests/sys/evtimer_msg/main.c index 961e2f5c8e..59e4f6de14 100644 --- a/tests/sys/evtimer_msg/main.c +++ b/tests/sys/evtimer_msg/main.c @@ -23,7 +23,7 @@ #include "evtimer_msg.h" #include "thread.h" #include "msg.h" -#include "xtimer.h" +#include "ztimer.h" static char worker_stack[THREAD_STACKSIZE_MAIN]; static evtimer_t evtimer; @@ -111,7 +111,7 @@ int main(void) NEVENTS); /* The last offset is the largest, wait for it and a tiny bit more */ - xtimer_msleep((offsets[3] + 10)); + ztimer_sleep(ZTIMER_MSEC, (offsets[3] + 10)); puts("By now all msgs should have been received"); puts("If yes, the tests were successful"); } diff --git a/tests/sys/evtimer_underflow/Makefile b/tests/sys/evtimer_underflow/Makefile index 485222d0a7..071591b0b1 100644 --- a/tests/sys/evtimer_underflow/Makefile +++ b/tests/sys/evtimer_underflow/Makefile @@ -1,7 +1,7 @@ include ../Makefile.sys_common USEMODULE += evtimer -USEMODULE += xtimer +USEMODULE += ztimer_msec # microbit qemu lacks rtt TEST_ON_CI_BLACKLIST += microbit diff --git a/tests/sys/evtimer_underflow/main.c b/tests/sys/evtimer_underflow/main.c index 89768ee4ec..43ecfb2122 100644 --- a/tests/sys/evtimer_underflow/main.c +++ b/tests/sys/evtimer_underflow/main.c @@ -23,7 +23,7 @@ #include "evtimer_msg.h" #include "thread.h" #include "msg.h" -#include "xtimer.h" +#include "ztimer.h" #define WORKER_MSG_QUEUE_SIZE (8) @@ -61,7 +61,7 @@ void *worker_thread(void *arg) void sleep_msec(uint16_t t) { - xtimer_msleep(t); + ztimer_sleep(ZTIMER_MSEC, t); } int main(void)