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

sys/xtimer-ztimer: rework dependecies to ease backend switch

This adds a xtimer_no_ztimer_default that is currently always
selected in Makefile, but that can be switched off in Kconfig.
Removing its inclusion will allow switching the default xtimer
backend to ztimer, while allowing for an easy way back.
This commit is contained in:
Francisco Molina 2022-03-16 08:57:56 +01:00
parent 7227d1bb77
commit 0b1453667e
6 changed files with 46 additions and 28 deletions

View File

@ -13,3 +13,9 @@ endif
ifneq (,$(filter auto_init_saul,$(USEMODULE)))
USEMODULE += saul_init_devs
endif
ifneq (,$(filter xtimer,$(USEMODULE)))
ifeq (,$(filter ztimer_xtimer_compat,$(USEMODULE)))
USEMODULE += div
endif
endif

View File

@ -257,6 +257,7 @@ PSEUDOMODULES += vfs_default
PSEUDOMODULES += wakaama_objects_%
PSEUDOMODULES += wifi_enterprise
PSEUDOMODULES += xtimer_on_ztimer
PSEUDOMODULES += xtimer_no_ztimer_default
PSEUDOMODULES += zptr
PSEUDOMODULES += ztimer
PSEUDOMODULES += ztimer_%

View File

@ -8,17 +8,22 @@
menuconfig MODULE_XTIMER
bool "xtimer"
depends on HAS_PERIPH_TIMER
depends on TEST_KCONFIG
# use timer peripheral unless ztimer compatibility module is used
select MODULE_PERIPH_TIMER if HAS_PERIPH_TIMER && !MODULE_XTIMER_ON_ZTIMER && !MODULE_ZTIMER_XTIMER_COMPAT && !MODULE_ZTIMER64_XTIMER_COMPAT
select MODULE_PERIPH_TIMER
select MODULE_DIV if !MODULE_ZTIMER_XTIMER_COMPAT
select ZTIMER_USEC if !MODULE_XTIMER_NO_ZTIMER_DEFAULT
help
Include xtimer module. xtimer requires a low-level timer implementation
that can be provided either by a peripheral timer or the ztimer module
when MODULE_XTIMER_ON_ZTIMER is enabled.
if MODULE_XTIMER
config MODULE_XTIMER_NO_ZTIMER_DEFAULT
bool "xtimer does not select ztimer"
default y
config MODULE_AUTO_INIT_XTIMER
bool "Auto-init xtimer"
default y if MODULE_AUTO_INIT && !MODULE_ZTIMER_XTIMER_COMPAT
depends on MODULE_XTIMER
endif # MODULE_XTIMER

View File

@ -1,14 +1,31 @@
ifeq (,$(filter ztimer_xtimer_compat,$(USEMODULE)))
# xtimer is used, ztimer xtimer wrapper is not
DEFAULT_MODULE += auto_init_xtimer
USEMODULE += div
ifeq (,$(filter xtimer_on_ztimer,$(USEMODULE)))
# ztimer is not used, so use *periph_timer as low-level timer*.
FEATURES_REQUIRED += periph_timer
else
# will use *ztimer_usec as low-level timer*
DEFAULT_MODULE += auto_init_xtimer
# In whatever combination of backends periph_timer will be required
# - xtimer (only) -> periph_timer
# - xtimer_on_ztimer -> ztimer_usec -> ztimer_periph_timer -> periph_timer
# - ztimer_xtimer_compat -> ztimer_usec -> ztimer_periph_timer -> periph_timer
# But requesting it here avoid an ifeq dependency that would be subject to
# dependency inclusion order issues
FEATURES_REQUIRED += periph_timer
USEMODULE += xtimer_no_ztimer_default
ifeq (,$(filter xtimer_no_ztimer_default,$(USEMODULE)))
ifeq (,$(filter ztimer_xtimer_compat,$(USEMODULE)))
USEMODULE += xtimer_on_ztimer
endif
else
# ztimer_xtimer_compat is used, all of *xtimer's API will be mapped on ztimer
# or ztimer64 *
ifneq (,$(filter ztimer,$(USEMODULE)))
ifeq (,$(filter ztimer_xtimer_compat,$(USEMODULE)))
USEMODULE += xtimer_on_ztimer
endif
endif
endif
ifneq (,$(filter ztimer_xtimer_compat,$(USEMODULE)))
DISABLE_MODULE += auto_init_xtimer
USEMODULE += div
endif
# make xtimer use ztimer_usec as low level timer
ifneq (,$(filter xtimer_on_ztimer,$(USEMODULE)))
USEMODULE += ztimer_usec
endif

View File

@ -152,6 +152,7 @@ config MODULE_ZTIMER_XTIMER_COMPAT
bool "map xtimer calls to ztimer"
select MODULE_DIV
select MODULE_ZTIMER_USEC
select MODULE_ZTIMER_PERIPH_TIMER
help
This is a wrapper of xtimer API on ztimer_usec and is currently
incomplete. Unless doing testing, use xtimer on ztimer.

View File

@ -13,13 +13,6 @@ endif
# unless ztimer_xtimer_compat is used, make xtimer use ztimer_usec as backend.
ifneq (,$(filter ztimer,$(USEMODULE)))
ifneq (,$(filter xtimer,$(USEMODULE)))
ifeq (,$(filter ztimer_xtimer_compat ztimer64_xtimer_compat,$(USEMODULE)))
USEMODULE += xtimer_on_ztimer
else
USEMODULE += div
endif
endif
ifneq (,$(filter evtimer,$(USEMODULE)))
USEMODULE += evtimer_on_ztimer
endif
@ -34,11 +27,6 @@ ifneq (,$(filter ztimer64_xtimer_compat,$(USEMODULE)))
USEMODULE += ztimer_xtimer_compat
endif
# make xtimer use ztimer_usec as low level timer
ifneq (,$(filter xtimer_on_ztimer,$(USEMODULE)))
USEMODULE += ztimer_usec
endif
# make evtimer use ztimer_msec as low level timer
ifneq (,$(filter evtimer_on_ztimer,$(USEMODULE)))
USEMODULE += ztimer_msec