From d5c0e30a11da4aa36bac14c161bec06f56e7ce98 Mon Sep 17 00:00:00 2001 From: Marian Buschsieweke Date: Wed, 19 Aug 2020 21:19:51 +0200 Subject: [PATCH] boards/waspmote: Fix timer config - Set XTIMER_HZ to something that is actually possible to generate with one of the available clock dividers from the core frequency - Use xtimer_on_ztimer if xtimer is used and not ztimer_xtimer_compat is used - This is needed because xtimer is simply not compatible with any of the possible clock frequencies of this board --- boards/waspmote-pro/Makefile.dep | 2 ++ boards/waspmote-pro/include/board.h | 15 ++++++++++++++- makefiles/boards/ztimer_only.dep.mk | 11 +++++++++++ 3 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 makefiles/boards/ztimer_only.dep.mk diff --git a/boards/waspmote-pro/Makefile.dep b/boards/waspmote-pro/Makefile.dep index 1c9242803f..54f2a1d597 100644 --- a/boards/waspmote-pro/Makefile.dep +++ b/boards/waspmote-pro/Makefile.dep @@ -1,3 +1,5 @@ #ifneq (,$(filter saul_default,$(USEMODULE))) # USEMODULE += saul_gpio #endif + +include $(RIOTMAKE)/boards/ztimer_only.dep.mk diff --git a/boards/waspmote-pro/include/board.h b/boards/waspmote-pro/include/board.h index 24bd916769..c014c054ac 100644 --- a/boards/waspmote-pro/include/board.h +++ b/boards/waspmote-pro/include/board.h @@ -159,13 +159,26 @@ extern "C" { /** * @name xtimer configuration values + * @warning This configuration is not actually compatible with xtimer. Sadly, + * no compatible clock frequency can be generated with the given core + * frequency * @{ */ #define XTIMER_WIDTH (16) -#define XTIMER_HZ (62500UL) +#define XTIMER_HZ (230400LU) #define XTIMER_BACKOFF (40) /** @} */ +/** + * @name ztimer configuration values + * @{ + */ +#define CONFIG_ZTIMER_USEC_TYPE ZTIMER_TYPE_PERIPH_TIMER +#define CONFIG_ZTIMER_USEC_DEV (TIMER_DEV(0)) +#define CONFIG_ZTIMER_USEC_FREQ (230400LU) +#define CONFIG_ZTIMER_USEC_WIDTH (16) +/** @} */ + /** * @brief Initialize board specific hardware, including clock, LEDs and std-IO */ diff --git a/makefiles/boards/ztimer_only.dep.mk b/makefiles/boards/ztimer_only.dep.mk new file mode 100644 index 0000000000..f82f98231e --- /dev/null +++ b/makefiles/boards/ztimer_only.dep.mk @@ -0,0 +1,11 @@ +# Include this for boards whose timer periph cannot generate a clock frequency +# suitable for xtimer with the available clock sources and dividers. +# This will use ztimer to perform the required frequency conversion. +# By default, xtimer is still used with ztimer as backed, unless +# ztimer_xtimer_compat is used. + +ifneq (,$(filter xtimer,$(USEMODULE))) + ifeq (,$(filter ztimer_xtimer_compat,$(USEMODULE))) + USEMODULE += xtimer_on_ztimer + endif +endif