sys/ztimer: add 'ztimer_no_periph_rtt'
This is a temporary fix for Issue #17060. It allows to disable auto inclusion of `ztimer_periph_rtt` in cases where another module or application requires direct access. Limitations: - as ifeq are involved order of inclusion matters, therefore these modules should be included early in the build at application level and not in modules `Makefile.dep` - this does not disallow direct inclusions of `ztimer_periph_rtt`, since this only disables auto inclusion of these modules This is a temporary solution since this is already possible with Kconfig, but not in make.
This commit is contained in:
parent
0ddbe042eb
commit
7c3360e4d6
@ -22,6 +22,10 @@
|
|||||||
* On many CPUs, certain power states might need to be blocked in rtt_init(), so
|
* On many CPUs, certain power states might need to be blocked in rtt_init(), so
|
||||||
* that it is ensured that the RTT will function properly while it is enabled.
|
* that it is ensured that the RTT will function properly while it is enabled.
|
||||||
*
|
*
|
||||||
|
* @warning This module will be automatically be used as a backend for
|
||||||
|
* ZTIMER_SEC and ZTIMER_MSEC. If direct access to RTT is needed
|
||||||
|
* then include `ztimer_no_periph_rtt` to avoid auto-selection,
|
||||||
|
* i.e.: `USEMODULE += ztimer_no_periph_rtt`.
|
||||||
* @{
|
* @{
|
||||||
* @file
|
* @file
|
||||||
* @brief Low-level RTT (Real Time Timer) peripheral driver interface
|
* @brief Low-level RTT (Real Time Timer) peripheral driver interface
|
||||||
|
|||||||
@ -197,6 +197,11 @@
|
|||||||
* if if these are missing it will use same basic timer
|
* if if these are missing it will use same basic timer
|
||||||
* as ZTIMER_USEC does.
|
* as ZTIMER_USEC does.
|
||||||
*
|
*
|
||||||
|
* If `periph_rtt` is required with direct access by another MODULE or
|
||||||
|
* application, `ztimer_no_periph_rtt` can be included to avoid automatic
|
||||||
|
* selection of `ztimer_periph_rtt` as a backend for ZTIMER_SEC and ZTIMER_MSEC.
|
||||||
|
* i.e.: `USEMODULE += ztimer_no_periph_rtt`.
|
||||||
|
*
|
||||||
* These pointers are defined in `ztimer.h` and can be used like this:
|
* These pointers are defined in `ztimer.h` and can be used like this:
|
||||||
*
|
*
|
||||||
* ztimer_now(ZTIMER_USEC);
|
* ztimer_now(ZTIMER_USEC);
|
||||||
|
|||||||
@ -10,6 +10,12 @@ menu "ztimer - High level timer abstraction layer"
|
|||||||
config ZTIMER_CUSTOM_BACKEND_CONFIGURATION
|
config ZTIMER_CUSTOM_BACKEND_CONFIGURATION
|
||||||
bool "Override default backend selection"
|
bool "Override default backend selection"
|
||||||
|
|
||||||
|
config MODULE_ZTIMER_NO_PERIPH_RTT
|
||||||
|
bool "Disable ztimer_periph_rtt auto-inclusion"
|
||||||
|
help
|
||||||
|
This module disables the auto-inclusion of ztimer_periph_rtt as a backend
|
||||||
|
for ztimer_msec and ztimer_sec.
|
||||||
|
|
||||||
menu "Backends"
|
menu "Backends"
|
||||||
visible if ZTIMER_CUSTOM_BACKEND_CONFIGURATION
|
visible if ZTIMER_CUSTOM_BACKEND_CONFIGURATION
|
||||||
|
|
||||||
@ -56,7 +62,7 @@ config MODULE_ZTIMER_MSEC
|
|||||||
choice
|
choice
|
||||||
bool "Backend"
|
bool "Backend"
|
||||||
depends on MODULE_ZTIMER_MSEC
|
depends on MODULE_ZTIMER_MSEC
|
||||||
default ZTIMER_MSEC_BACKEND_RTT
|
default ZTIMER_MSEC_BACKEND_RTT if !MODULE_ZTIMER_NO_PERIPH_RTT
|
||||||
|
|
||||||
config ZTIMER_MSEC_BACKEND_TIMER
|
config ZTIMER_MSEC_BACKEND_TIMER
|
||||||
bool "Timer"
|
bool "Timer"
|
||||||
@ -85,7 +91,7 @@ config ZTIMER_SEC_BACKEND_TIMER
|
|||||||
config ZTIMER_SEC_BACKEND_RTT
|
config ZTIMER_SEC_BACKEND_RTT
|
||||||
bool "RTT"
|
bool "RTT"
|
||||||
depends on HAS_PERIPH_RTT
|
depends on HAS_PERIPH_RTT
|
||||||
select MODULE_ZTIMER_PERIPH_RTT
|
select MODULE_ZTIMER_PERIPH_RTT if !MODULE_ZTIMER_NO_PERIPH_RTT
|
||||||
|
|
||||||
config ZTIMER_SEC_BACKEND_RTC
|
config ZTIMER_SEC_BACKEND_RTC
|
||||||
bool "RTC"
|
bool "RTC"
|
||||||
|
|||||||
@ -87,35 +87,26 @@ ifneq (,$(filter ztimer_usec,$(USEMODULE)))
|
|||||||
USEMODULE += ztimer_periph_timer
|
USEMODULE += ztimer_periph_timer
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifneq (,$(filter ztimer_msec,$(USEMODULE)))
|
ifneq (,$(filter ztimer_msec ztimer_sec,$(USEMODULE)))
|
||||||
USEMODULE += ztimer
|
USEMODULE += ztimer
|
||||||
FEATURES_OPTIONAL += periph_rtt
|
ifeq (,$(filter ztimer_no_periph_rtt,$(USEMODULE)))
|
||||||
# HACK: periph_rtt will get used only in the next iteration but an updated
|
FEATURES_OPTIONAL += periph_rtt
|
||||||
# state for FEATURES_USED is needed here so include `features_check.inc.mk`
|
# HACK: periph_rtt will get used only in the next iteration but an updated
|
||||||
# here instead.
|
# state for FEATURES_USED is needed here so include `features_check.inc.mk`
|
||||||
# An other option would be to check FEATURES_PROVIDED this would avoid the
|
# here instead.
|
||||||
# order of inclusion problem but it would no take into account possible conflicts
|
# An other option would be to check FEATURES_PROVIDED this would avoid the
|
||||||
# and is also currently not allowed in the build system.
|
# order of inclusion problem but it would no take into account possible conflicts
|
||||||
# An other alternative would be to delay to the next loop, but this produce a
|
# and is also currently not allowed in the build system.
|
||||||
# case where another loop is not executed and the conditional not evaluated
|
# An other alternative would be to delay to the next loop, but this produce a
|
||||||
# If these kind of usecases pop up before Kconfig migration is completed
|
# case where another loop is not executed and the conditional not evaluated
|
||||||
# then another alternative would be introduce a variable to require an extra
|
# If these kind of usecases pop up before Kconfig migration is completed
|
||||||
# loop independent of USEMODULE, FEATURES_REQUIRED and USEPKG
|
# then another alternative would be introduce a variable to require an extra
|
||||||
include $(RIOTMAKE)/features_check.inc.mk
|
# loop independent of USEMODULE, FEATURES_REQUIRED and USEPKG
|
||||||
ifneq (,$(filter periph_rtt,$(FEATURES_USED)))
|
include $(RIOTMAKE)/features_check.inc.mk
|
||||||
USEMODULE += ztimer_periph_rtt
|
ifneq (,$(filter periph_rtt,$(FEATURES_USED)))
|
||||||
else
|
USEMODULE += ztimer_periph_rtt
|
||||||
USEMODULE += ztimer_periph_timer
|
else
|
||||||
endif
|
USEMODULE += ztimer_periph_timer
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifneq (,$(filter ztimer_sec,$(USEMODULE)))
|
|
||||||
USEMODULE += ztimer
|
|
||||||
FEATURES_OPTIONAL += periph_rtt
|
|
||||||
# HACK: see above
|
|
||||||
ifneq (,$(filter periph_rtt,$(FEATURES_USED)))
|
|
||||||
USEMODULE += ztimer_periph_rtt
|
|
||||||
else
|
|
||||||
USEMODULE += ztimer_periph_timer
|
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user