1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

sys/evtimer: remove support for xtimer backend

This commit is contained in:
Alexandre Abadie 2023-05-20 16:21:34 +02:00
parent 7eb50c5f05
commit 08fdb23185
No known key found for this signature in database
GPG Key ID: 1C919A403CAE1405
9 changed files with 13 additions and 83 deletions

View File

@ -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

View File

@ -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

View File

@ -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)
{

View File

@ -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 <stdint.h>
#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

View File

@ -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

View File

@ -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

View File

@ -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");
}

View File

@ -1,7 +1,7 @@
include ../Makefile.sys_common
USEMODULE += evtimer
USEMODULE += xtimer
USEMODULE += ztimer_msec
# microbit qemu lacks rtt
TEST_ON_CI_BLACKLIST += microbit

View File

@ -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)