From c80390f28b2ae47eed26de3bdc731f394104290e Mon Sep 17 00:00:00 2001 From: Francisco Molina Date: Tue, 15 Jun 2021 12:19:07 +0200 Subject: [PATCH] ztimer: pull ztimer_periph_rtt for ZTIMER_MSEC if available --- sys/Makefile.include | 6 ++-- sys/ztimer/Kconfig | 52 +++++++++++++++++++++++++++---- sys/ztimer/Makefile.dep | 18 +++++++++++ sys/ztimer/Makefile.include | 15 +++++++++ tests/pkg_umorse/Makefile.ci | 2 ++ tests/ztimer_periodic/Makefile.ci | 2 ++ 6 files changed, 85 insertions(+), 10 deletions(-) create mode 100644 sys/ztimer/Makefile.include create mode 100644 tests/pkg_umorse/Makefile.ci create mode 100644 tests/ztimer_periodic/Makefile.ci diff --git a/sys/Makefile.include b/sys/Makefile.include index 69207bfc82..2ca8bdce07 100644 --- a/sys/Makefile.include +++ b/sys/Makefile.include @@ -133,10 +133,8 @@ ifneq (,$(filter test_utils_result_output,$(USEMODULE))) include $(RIOTBASE)/sys/test_utils/result_output/Makefile.include endif -# Convert xtimer into a pseudo module if its API is already implemented by -# ztimer's compatibility wrapper -ifneq (,$(filter ztimer_xtimer_compat,$(USEMODULE))) - PSEUDOMODULES += xtimer +ifneq (,$(filter ztimer,$(USEMODULE))) + include $(RIOTBASE)/sys/ztimer/Makefile.include endif ifneq (,$(filter prng,$(USEMODULE))) diff --git a/sys/ztimer/Kconfig b/sys/ztimer/Kconfig index 47e0fc97c7..e01bc61e5e 100644 --- a/sys/ztimer/Kconfig +++ b/sys/ztimer/Kconfig @@ -15,7 +15,11 @@ menuconfig MODULE_ZTIMER if MODULE_ZTIMER +config ZTIMER_CUSTOM_BACKEND_CONFIGURATION + bool "Override default backend selection" + menu "Backends" + visible if ZTIMER_CUSTOM_BACKEND_CONFIGURATION config MODULE_ZTIMER_PERIPH_RTC bool "RTC peripheral" @@ -26,7 +30,6 @@ config MODULE_ZTIMER_PERIPH_RTT bool "RTT peripheral" depends on HAS_PERIPH_RTT select MODULE_PERIPH_RTT - default y if !MODULE_ZTIMER_PERIPH_TIMER config MODULE_ZTIMER_PERIPH_PTP bool "PTP peripheral" @@ -37,7 +40,6 @@ config MODULE_ZTIMER_PERIPH_TIMER bool "Timer peripheral" depends on HAS_PERIPH_TIMER select MODULE_PERIPH_TIMER - default y endmenu # Backends @@ -45,19 +47,57 @@ menu "Clocks" config MODULE_ZTIMER_USEC bool "Microseconds" - depends on MODULE_ZTIMER_PERIPH_TIMER + select MODULE_ZTIMER_PERIPH_TIMER config MODULE_ZTIMER_MSEC bool "Milliseconds" - depends on MODULE_ZTIMER_PERIPH_TIMER || MODULE_ZTIMER_PERIPH_RTT + +choice + bool "Backend" + depends on MODULE_ZTIMER_MSEC + default ZTIMER_MSEC_BACKEND_RTT + +config ZTIMER_MSEC_BACKEND_TIMER + bool "Timer" + select MODULE_ZTIMER_PERIPH_TIMER + +config ZTIMER_MSEC_BACKEND_RTT + bool "RTT" + depends on HAS_PERIPH_RTT + select MODULE_ZTIMER_PERIPH_RTT + +endchoice config MODULE_ZTIMER_SEC bool "Seconds" - depends on MODULE_ZTIMER_PERIPH_TIMER || MODULE_ZTIMER_PERIPH_RTT || MODULE_ZTIMER_PERIPH_RTC + +choice + bool "Backend" + depends on MODULE_ZTIMER_SEC + default ZTIMER_SEC_BACKEND_RTC if !BOARD_NATIVE && \ + !CPU_COMMON_SAM0 && \ + !CPU_COMMON_EFM32 && \ + !CPU_COMMON_STM32F1 + default ZTIMER_SEC_BACKEND_RTT + +config ZTIMER_SEC_BACKEND_TIMER + bool "Timer" + select MODULE_ZTIMER_PERIPH_TIMER + +config ZTIMER_SEC_BACKEND_RTT + bool "RTT" + depends on HAS_PERIPH_RTT + select MODULE_ZTIMER_PERIPH_RTT + +config ZTIMER_SEC_BACKEND_RTC + bool "RTC" + depends on HAS_PERIPH_RTC + select MODULE_ZTIMER_PERIPH_RTC + +endchoice endmenu # Clocks - menu "Frequency conversion" config MODULE_ZTIMER_CONVERT_MULDIV64 diff --git a/sys/ztimer/Makefile.dep b/sys/ztimer/Makefile.dep index 9c874a2727..3ffe696b5d 100644 --- a/sys/ztimer/Makefile.dep +++ b/sys/ztimer/Makefile.dep @@ -89,4 +89,22 @@ endif ifneq (,$(filter ztimer_msec,$(USEMODULE))) USEMODULE += ztimer + FEATURES_OPTIONAL += periph_rtt + # HACK: periph_rtt will get used only in the next iteration but an updated + # state for FEATURES_USED is needed here so include `features_check.inc.mk` + # here instead. + # An other option would be to check FEATURES_PROVIDED this would avoid the + # order of inclusion problem but it would no take into account possible conflicts + # and is also currently not allowed in the build system. + # An other alternative would be to delay to the next loop, but this produce a + # case where another loop is not executed and the conditional not evaluated + # If these kind of usecases pop up before Kconfig migration is completed + # then another alternative would be introduce a variable to require an extra + # loop independent of USEMODULE, FEATURES_REQUIRED and USEPKG + include $(RIOTMAKE)/features_check.inc.mk + ifneq (,$(filter periph_rtt,$(FEATURES_USED))) + USEMODULE += ztimer_periph_rtt + else + USEMODULE += ztimer_periph_timer + endif endif diff --git a/sys/ztimer/Makefile.include b/sys/ztimer/Makefile.include new file mode 100644 index 0000000000..57c795bc82 --- /dev/null +++ b/sys/ztimer/Makefile.include @@ -0,0 +1,15 @@ +# Convert xtimer into a pseudo module if its API is already implemented by +# ztimer's compatibility wrapper +ifneq (,$(filter ztimer_xtimer_compat,$(USEMODULE))) + PSEUDOMODULES += xtimer +endif + +# By defaul use highest possible RTT_FREQUENCY for platforms that allow it. This +# might not be the most optimized for conversion guarantees that ztimer_periph_rtt +# will have a capable backend. +ifneq (,$(filter ztimer_periph_rtt,$(USEMODULE))) + ifneq (,$(filter stm32 nrf52 sam% kinetis efm32,$(CPU))) + RTT_FREQUENCY ?= RTT_MAX_FREQUENCY + CFLAGS += -DRTT_FREQUENCY=$(RTT_FREQUENCY) + endif +endif diff --git a/tests/pkg_umorse/Makefile.ci b/tests/pkg_umorse/Makefile.ci new file mode 100644 index 0000000000..36f350148a --- /dev/null +++ b/tests/pkg_umorse/Makefile.ci @@ -0,0 +1,2 @@ +BOARD_INSUFFICIENT_MEMORY := \ + nucleo-l011k4 \ diff --git a/tests/ztimer_periodic/Makefile.ci b/tests/ztimer_periodic/Makefile.ci new file mode 100644 index 0000000000..36f350148a --- /dev/null +++ b/tests/ztimer_periodic/Makefile.ci @@ -0,0 +1,2 @@ +BOARD_INSUFFICIENT_MEMORY := \ + nucleo-l011k4 \