Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

xtimer: rework dependecies to ease backend switch #17809

Closed
wants to merge 9 commits into from
2 changes: 1 addition & 1 deletion boards/common/microbit/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@
config MODULE_MICROBIT
bool "BBC micro:bit specific LED matrix handling"
select MODULE_ZTIMER
select ZTIMER_USEC
select MODULE_ZTIMER_USEC
select MODULE_MINEPLEX
2 changes: 1 addition & 1 deletion cpu/lpc23xx/mci/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ config MODULE_MCI
bool "LPC23XX Multimedia Card Interface (MCI) driver"
depends on CPU_FAM_LPC23XX
depends on TEST_KCONFIG
select ZTIMER_USEC
select MODULE_ZTIMER_USEC
2 changes: 2 additions & 0 deletions cpu/native/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ config CPU_ARCH_NATIVE
# needed modules
select MODULE_PERIPH if TEST_KCONFIG
select MODULE_ZTIMER64_XTIMER_COMPAT if MODULE_ZTIMER_XTIMER_COMPAT
select MODULE_ZTIMER64_USEC if MODULE_ZTIMER_XTIMER_COMPAT
select MODULE_ZTIMER64 if MODULE_ZTIMER_XTIMER_COMPAT

config CPU_CORE_NATIVE
bool
Expand Down
2 changes: 0 additions & 2 deletions cpu/qn908x/periph/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,4 @@ config MODULE_PERIPH_GPIO_MUX
config MODULE_PERIPH_ADC
bool "ADC peripheral driver"
depends on HAS_PERIPH_ADC
select MODULE_ZTIMER
select MODULE_ZTIMER_USEC
select MODULE_ZTIMER_PERIPH_TIMER
2 changes: 1 addition & 1 deletion drivers/at30tse75x/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ config MODULE_AT30TSE75X
depends on TEST_KCONFIG
select MODULE_PERIPH_I2C
select MODULE_ZTIMER
select ZTIMER_USEC
select MODULE_ZTIMER_USEC
help
AT30TSE75x temperature sensor with serial EEPROM.

Expand Down
2 changes: 0 additions & 2 deletions drivers/ccs811/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@ menuconfig MODULE_CCS811
depends on TEST_KCONFIG
select MODULE_PERIPH_GPIO
select MODULE_PERIPH_I2C
select MODULE_ZTIMER
select MODULE_ZTIMER_USEC
select MODULE_ZTIMER_PERIPH_TIMER

config MODULE_CCS811_FULL
bool "Full functionalities"
Expand Down
2 changes: 1 addition & 1 deletion drivers/dsp0401/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ config MODULE_DSP0401
select MODULE_PERIPH_GPIO
select MODULE_PERIPH_PWM
select MODULE_ZTIMER
select ZTIMER_USEC
select MODULE_ZTIMER_USEC

config HAVE_DSP0401
bool
Expand Down
5 changes: 4 additions & 1 deletion drivers/ltc4150/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ config MODULE_LTC4150
depends on TEST_KCONFIG
select MODULE_PERIPH_GPIO
select MODULE_PERIPH_GPIO_IRQ
select ZTIMER64_USEC
select MODULE_ZTIMER_USEC
select MODULE_ZTIMER
select MODULE_ZTIMER64_USEC
select MODULE_ZTIMER64
help
Driver for the Linear Tech LTC4150 Coulomb Counter (a.k.a. battery
gauge sensor or power consumption sensor).
Expand Down
2 changes: 1 addition & 1 deletion drivers/nvram_spi/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ config MODULE_NVRAM_SPI
depends on TEST_KCONFIG
select MODULE_NVRAM
select MODULE_PERIPH_SPI
select ZTIMER_USEC
select MODULE_ZTIMER_USEC
5 changes: 4 additions & 1 deletion drivers/pir/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ config MODULE_PIR
depends on TEST_KCONFIG
select MODULE_PERIPH_GPIO
select MODULE_PERIPH_GPIO_IRQ
select ZTIMER64_USEC
select MODULE_ZTIMER64_USEC
select MODULE_ZTIMER64
select MODULE_ZTIMER_USEC
select MODULE_ZTIMER

config HAVE_PIR
bool
Expand Down
2 changes: 1 addition & 1 deletion drivers/sdcard_spi/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ config MODULE_SDCARD_SPI
select MODULE_PERIPH_SPI_RECONFIGURE if HAS_PERIPH_SPI_RECONFIGURE
select MODULE_CHECKSUM
select MODULE_ZTIMER
select ZTIMER_USEC
select MODULE_ZTIMER_USEC

config HAVE_SDCARD_SPI
bool
Expand Down
4 changes: 1 addition & 3 deletions drivers/sgp30/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@ menuconfig MODULE_SGP30
depends on TEST_KCONFIG
select MODULE_CHECKSUM
select MODULE_PERIPH_I2C
select MODULE_ZTIMER
select MODULE_ZTIMER_PERIPH_TIMER
select ZTIMER_USEC
select MODULE_ZTIMER_USEC

config MODULE_SGP30_STRICT
bool "Strict reading period"
Expand Down
2 changes: 1 addition & 1 deletion drivers/si1133/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ config MODULE_SI1133
depends on TEST_KCONFIG
select MODULE_PERIPH_I2C
select MODULE_ZTIMER
select ZTIMER_USEC
select MODULE_ZTIMER_USEC

config HAVE_SI1133
bool
Expand Down
4 changes: 1 addition & 3 deletions drivers/sm_pwm_01c/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@ menuconfig MODULE_SM_PWM_01C
depends on TEST_KCONFIG
select MODULE_PERIPH_GPIO
select MODULE_PERIPH_GPIO_IRQ
select MODULE_ZTIMER
select ZTIMER_USEC
select MODULE_ZTIMER_PERIPH_TIMER
select MODULE_ZTIMER_USEC

config MODULE_SM_PWM_01C_MA
bool "Use a moving average for sensor values"
Expand Down
3 changes: 1 addition & 2 deletions kconfigs/Kconfig.ztimer_only
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@
config HAVE_ZTIMER_ONLY
bool
default y
select MODULE_ZTIMER if MODULE_XTIMER
select MODULE_ZTIMER_PERIPH_TIMER if MODULE_XTIMER
select MODULE_ZTIMER_USEC if MODULE_XTIMER
help
Indicates that the board cannot generate a clock frequency suitable for
xtimer and requires ztimer for conversion. ztimer is used as backend.
1 change: 1 addition & 0 deletions makefiles/boards/ztimer_only.dep.mk
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@
ifneq (,$(filter xtimer,$(USEMODULE)))
ifeq (,$(filter ztimer_xtimer_compat ztimer64_xtimer_compat,$(USEMODULE)))
USEMODULE += xtimer_on_ztimer
USEMODULE += ztimer_usec
endif
endif
4 changes: 4 additions & 0 deletions makefiles/default_modules.deps.mk
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,7 @@ endif
ifneq (,$(filter auto_init_saul,$(USEMODULE)))
USEMODULE += saul_init_devs
endif

ifneq (,$(filter xtimer_on_periph_timer,$(USEMODULE)))
USEMODULE += div
endif
3 changes: 3 additions & 0 deletions makefiles/pseudomodules.inc.mk
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,9 @@ PSEUDOMODULES += vfs_default
PSEUDOMODULES += wakaama_objects_%
PSEUDOMODULES += wifi_enterprise
PSEUDOMODULES += xtimer_on_ztimer
PSEUDOMODULES += xtimer_on_periph_timer
PSEUDOMODULES += ztimer_xtimer_compat
PSEUDOMODULES += ztimer64_xtimer_compat
PSEUDOMODULES += zptr
PSEUDOMODULES += ztimer
PSEUDOMODULES += ztimer_%
Expand Down
2 changes: 1 addition & 1 deletion pkg/driver_sx126x/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ config PACKAGE_DRIVER_SX126X
depends on HAS_PERIPH_SPI
select MODULE_PERIPH_SPI
select MODULE_ZTIMER
select ZTIMER_USEC
select MODULE_ZTIMER_USEC
select MODULE_DRIVER_SX126X_HAL

config MODULE_DRIVER_SX126X_HAL
Expand Down
1 change: 0 additions & 1 deletion pkg/u8g2/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ config PACKAGE_U8G2
depends on TEST_KCONFIG
depends on HAS_PERIPH_GPIO
select MODULE_PERIPH_GPIO
select MODULE_ZTIMER
select MODULE_ZTIMER_USEC
select MODULE_U8G2_RIOT
select MODULE_U8G2_CSRC
Expand Down
1 change: 0 additions & 1 deletion pkg/ucglib/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ config PACKAGE_UCGLIB
depends on TEST_KCONFIG
depends on HAS_PERIPH_GPIO
select MODULE_PERIPH_GPIO
select MODULE_ZTIMER
select MODULE_ZTIMER_USEC
select MODULE_UCGLIB_RIOT
select MODULE_UCGLIB_CSRC
Expand Down
8 changes: 5 additions & 3 deletions sys/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -82,15 +82,17 @@ rsource "seq/Kconfig"
rsource "shell/Kconfig"
rsource "test_utils/Kconfig"
rsource "timex/Kconfig"
menu "Timers"
rsource "xtimer/Kconfig"
rsource "ztimer/Kconfig"
rsource "ztimer64/Kconfig"
endmenu # Timers
rsource "trace/Kconfig"
rsource "tsrb/Kconfig"
rsource "uri_parser/Kconfig"
rsource "usb/Kconfig"
rsource "usb_board_reset/Kconfig"
rsource "vfs/Kconfig"
rsource "xtimer/Kconfig"
rsource "ztimer/Kconfig"
rsource "ztimer64/Kconfig"

config MODULE_CPP
bool "Use CPP compiler"
Expand Down
2 changes: 2 additions & 0 deletions sys/Kconfig.newlib
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ config MODULE_NEWLIB_SYSCALLS_DEFAULT
depends on !HAVE_CUSTOM_NEWLIB_SYSCALLS
select MODULE_DIV
select MODULE_ZTIMER64_XTIMER_COMPAT if MODULE_ZTIMER_XTIMER_COMPAT
select MODULE_ZTIMER64_USEC if MODULE_ZTIMER_XTIMER_COMPAT
select MODULE_ZTIMER64 if MODULE_ZTIMER_XTIMER_COMPAT
help
Default implementation of newlib system calls.

Expand Down
15 changes: 1 addition & 14 deletions sys/Makefile.dep
Original file line number Diff line number Diff line change
Expand Up @@ -857,20 +857,7 @@ endif

# handle xtimer's deps. Needs to be done *after* ztimer
ifneq (,$(filter xtimer,$(USEMODULE)))
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*
endif
else
# ztimer_xtimer_compat is used, all of *xtimer's API will be mapped on ztimer
# or ztimer64 *
endif
include $(RIOTBASE)/sys/xtimer/Makefile.dep
endif

ifneq (,$(filter devfs_hwrng,$(USEMODULE)))
Expand Down
2 changes: 1 addition & 1 deletion sys/arduino/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ menuconfig MODULE_ARDUINO
select MODULE_FMT
select MODULE_ZTIMER
select MODULE_ZTIMER_MSEC
select ZTIMER_USEC
select MODULE_ZTIMER_USEC

config MODULE_ARDUINO_PWM
bool "PWM support for Arduino"
Expand Down
2 changes: 1 addition & 1 deletion sys/benchmark/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@
config MODULE_BENCHMARK
bool "Simple benchmarks support"
select MODULE_ZTIMER
select ZTIMER_USEC
select MODULE_ZTIMER_USEC
depends on TEST_KCONFIG
2 changes: 1 addition & 1 deletion sys/event/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,6 @@ config MODULE_EVENT_TIMEOUT_ZTIMER
config MODULE_EVENT_TIMEOUT
bool "Legacy API, support for triggering events after timeout"
select MODULE_EVENT_TIMEOUT_ZTIMER
select ZTIMER_USEC
select MODULE_ZTIMER_USEC

endif # MODULE_EVENT
2 changes: 1 addition & 1 deletion sys/schedstatistics/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@

config MODULE_SCHEDSTATISTICS
bool "Scheduler statistics support"
select ZTIMER_USEC
select MODULE_ZTIMER_USEC
depends on TEST_KCONFIG
select MODULE_SCHED_CB
3 changes: 2 additions & 1 deletion sys/sema/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@ config MODULE_SEMA
config MODULE_SEMA_DEPRECATED
bool "Semaphore compatible with 64bit timeouts, deprecated"
select MODULE_SEMA
select ZTIMER64_USEC
select MODULE_ZTIMER64_USEC
select MODULE_ZTIMER64
5 changes: 3 additions & 2 deletions sys/shell/commands/sc_gnrc_udp.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,10 @@
#include "net/utils.h"
#include "timex.h"
#include "utlist.h"
#if IS_USED(MODULE_ZTIMER)
#if IS_USED(MODULE_ZTIMER_USEC) || IS_USED(MODULE_ZTIMER_MSEC)
#include "ztimer.h"
#else
#endif
#if IS_USED(MODULE_XTIMER)
#include "xtimer.h"
#endif

Expand Down
2 changes: 0 additions & 2 deletions sys/trace/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,4 @@
config MODULE_TRACE
bool "Trace program flows"
depends on TEST_KCONFIG
select MODULE_ZTIMER
select MODULE_ZTIMER_USEC
select MODULE_ZTIMER_PERIPH_TIMER
48 changes: 39 additions & 9 deletions sys/xtimer/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,48 @@

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_DIV if !MODULE_ZTIMER_XTIMER_COMPAT
depends on HAS_PERIPH_TIMER
select MODULE_PERIPH_TIMER
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.
that can be provided either by a peripheral timer or the ztimer module.

if MODULE_XTIMER

config XTIMER_ZTIMER_BACKEND
bool "xtimer always implemented by ztimer"
select MODULE_ZTIMER_USEC

choice XTIMER_BACKEND
bool "xtimer backend"

config MODULE_XTIMER_ON_ZTIMER
bool "xtimer api implemented by xtimer, with ztimer_usec backend"
depends on MODULE_ZTIMER_PERIPH_TIMER
depends on MODULE_ZTIMER

config MODULE_ZTIMER_XTIMER_COMPAT
bool "xtimer api implemented by ztimer"
depends on MODULE_ZTIMER_USEC
select MODULE_DIV

config MODULE_XTIMER_ON_PERIPH_TIMER
bool "xtimer api implemented by xtimer, with periph_timer backend"
select MODULE_DIV
endchoice

config MODULE_ZTIMER64_XTIMER_COMPAT
bool "xtimer api implemented bt ztimer64"
select MODULE_DIV
depends on MODULE_ZTIMER64
depends on MODULE_ZTIMER64_USEC
depends on MODULE_ZTIMER_XTIMER_COMPAT
help
This is a wrapper of xtimer API on ztimer64_usec.

config MODULE_AUTO_INIT_XTIMER
bool "Auto-init xtimer"
default y if MODULE_AUTO_INIT && !MODULE_ZTIMER_XTIMER_COMPAT
depends on MODULE_XTIMER
default y if MODULE_AUTO_INIT && (MODULE_XTIMER && !MODULE_ZTIMER_XTIMER_COMPAT)

endif # MODULE_XTIMER
36 changes: 36 additions & 0 deletions sys/xtimer/Makefile.dep
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
DEFAULT_MODULE += auto_init_xtimer
# In whatever combination of backends periph_timer will be required
# - xtimer_on_ztimer -> ztimer_usec -> ztimer_periph_timer -> periph_timer
# - xtimer_on_periph_timer -> periph_timer
# - ztimer_xtimer_compat -> ztimer_usec -> ztimer_periph_timer -> periph_timer
# But requesting it here allows us to select `xtimer_on_periph_timer` only
# at the end of dependency resolution if `ztimer_periph_timer` was not selected
# without having an ifeq dependency that would be subject to dependency inclusion
# order issues, this way xtimer_on_periph_timer can be turned into a DEFAULT_MODULE
# that can be disabled if ztimer_periph_timer
FEATURES_REQUIRED += periph_timer
DEFAULT_MODULE += xtimer_on_periph_timer

# To avoid inclusion order changing dependencies this dependency is commented out
# but it models xtimer_on_periph_timer dependency explicitly, see comment above
# for more details
# ifneq (,$(filter xtimer_on_periph_timer,$(USEMODULE)))
# USEMODULE += div
# FEATURES_REQUIRED += periph_timer
# endif

ifneq (,$(filter ztimer_periph_timer,$(USEMODULE)))
DISABLE_MODULE += xtimer_on_periph_timer
ifeq (,$(filter ztimer_xtimer_compat,$(USEMODULE)))
USEMODULE += xtimer_on_ztimer
endif
endif

ifneq (,$(filter ztimer_xtimer_compat,$(USEMODULE)))
DISABLE_MODULE += auto_init_xtimer
endif

# make xtimer use ztimer_usec as low level timer
ifneq (,$(filter xtimer_on_ztimer,$(USEMODULE)))
USEMODULE += ztimer_periph_timer
endif
Loading