diff --git a/boards/xg23-pk6068a/Kconfig b/boards/xg23-pk6068a/Kconfig index 56c75eae81..aa9b82755f 100644 --- a/boards/xg23-pk6068a/Kconfig +++ b/boards/xg23-pk6068a/Kconfig @@ -20,3 +20,4 @@ config BOARD_XG23_PK6068A # Put other features for this board (in alphabetical order) select HAVE_SAUL_GPIO + select HAVE_ZTIMER_PERIPH_LPTIMER diff --git a/boards/xg23-pk6068a/Makefile.dep b/boards/xg23-pk6068a/Makefile.dep index 5472bf8b8d..01d21e3373 100644 --- a/boards/xg23-pk6068a/Makefile.dep +++ b/boards/xg23-pk6068a/Makefile.dep @@ -1,3 +1,7 @@ ifneq (,$(filter saul_default,$(USEMODULE))) USEMODULE += saul_gpio endif + +ifneq (,$(filter ztimer_msec ztimer_sec,$(USEMODULE))) + USEMODULE += ztimer_periph_lptimer +endif diff --git a/boards/xg23-pk6068a/include/board.h b/boards/xg23-pk6068a/include/board.h index 349a011bce..7b0cafa4a9 100644 --- a/boards/xg23-pk6068a/include/board.h +++ b/boards/xg23-pk6068a/include/board.h @@ -35,6 +35,16 @@ extern "C" { */ #define PM_BLOCKER_INITIAL { 0, 0, 0 } +/** + * @name ztimer configuration + * @{ + */ +#define CONFIG_ZTIMER_LPTIMER_DEV TIMER_DEV(1) +#define CONFIG_ZTIMER_LPTIMER_FREQ LFXO_FREQ +#define CONFIG_ZTIMER_LPTIMER_WIDTH 24 +#define CONFIG_ZTIMER_LPTIMER_BLOCK_PM_MODE EFM32_PM_MODE_EM3 +/** @} */ + /** * @brief Power mode required for GPIO IRQs * diff --git a/sys/include/ztimer/config.h b/sys/include/ztimer/config.h index 36ac9c99af..655d6f581b 100644 --- a/sys/include/ztimer/config.h +++ b/sys/include/ztimer/config.h @@ -61,6 +61,13 @@ extern "C" { #define CONFIG_ZTIMER_USEC_DEV (TIMER_DEV(0)) #endif +/** + * @brief Default width of ZTIMER_LPTIMER + */ +#ifndef CONFIG_ZTIMER_LPTIMER_WIDTH +#define CONFIG_ZTIMER_LPTIMER_WIDTH (32) +#endif + /** * @brief ZTIMER_USEC optimal minimum value for ztimer_set() * @@ -114,6 +121,13 @@ extern "C" { # endif #endif +/** + * @brief The minimum pm mode required for ZTIMER_LPTIMER to run + */ +#ifndef CONFIG_ZTIMER_LPTIMER_BLOCK_PM_MODE +# define CONFIG_ZTIMER_LPTIMER_BLOCK_PM_MODE ZTIMER_CLOCK_NO_REQUIRED_PM_MODE +#endif + /** * @brief The minimum pm mode required for ZTIMER_RTT to run */ diff --git a/sys/ztimer/Kconfig b/sys/ztimer/Kconfig index 4f8b5ab5db..6fb51d7aab 100644 --- a/sys/ztimer/Kconfig +++ b/sys/ztimer/Kconfig @@ -5,6 +5,11 @@ # directory for more details. # +config HAVE_ZTIMER_PERIPH_LPTIMER + bool + help + Indicates that ZTIMER_PERIPH_LPTIMER configuration is available. + menu "ztimer - High level timer abstraction layer" config ZTIMER_CUSTOM_BACKEND_CONFIGURATION @@ -39,6 +44,10 @@ config MODULE_ZTIMER_PERIPH_TIMER depends on HAS_PERIPH_TIMER select MODULE_PERIPH_TIMER +config MODULE_ZTIMER_PERIPH_LPTIMER + bool "Low-power Timer peripheral" + select MODULE_ZTIMER_PERIPH_TIMER + endmenu # Backends menu "Clocks" @@ -62,7 +71,9 @@ config MODULE_ZTIMER_MSEC choice ZTIMER_MSEC_BACKEND bool "Backend" depends on MODULE_ZTIMER_MSEC + default ZTIMER_MSEC_BACKEND_LPTIMER if HAVE_ZTIMER_PERIPH_LPTIMER default ZTIMER_MSEC_BACKEND_RTT if !MODULE_ZTIMER_NO_PERIPH_RTT + default ZTIMER_MSEC_BACKEND_TIMER config ZTIMER_MSEC_BACKEND_TIMER bool "Timer" @@ -73,6 +84,11 @@ config ZTIMER_MSEC_BACKEND_RTT depends on HAS_PERIPH_RTT select MODULE_ZTIMER_PERIPH_RTT +config ZTIMER_MSEC_BACKEND_LPTIMER + bool "Low Power Timer" + depends on HAVE_ZTIMER_PERIPH_LPTIMER + select MODULE_ZTIMER_PERIPH_LPTIMER + endchoice config MODULE_ZTIMER_SEC @@ -82,7 +98,9 @@ config MODULE_ZTIMER_SEC choice bool "Backend" depends on MODULE_ZTIMER_SEC + default ZTIMER_SEC_BACKEND_LPTIMER if HAVE_ZTIMER_PERIPH_LPTIMER default ZTIMER_SEC_BACKEND_RTT if !MODULE_ZTIMER_NO_PERIPH_RTT + default ZTIMER_SEC_BACKEND_TIMER config ZTIMER_SEC_BACKEND_TIMER bool "Timer" @@ -98,6 +116,11 @@ config ZTIMER_SEC_BACKEND_RTC depends on HAS_PERIPH_RTC select MODULE_ZTIMER_PERIPH_RTC +config ZTIMER_SEC_BACKEND_LPTIMER + bool "Low Power Timer" + depends on HAVE_ZTIMER_PERIPH_LPTIMER + select MODULE_ZTIMER_PERIPH_LPTIMER + endchoice endmenu # Clocks diff --git a/sys/ztimer/Makefile.dep b/sys/ztimer/Makefile.dep index 4668df9414..2492c212b9 100644 --- a/sys/ztimer/Makefile.dep +++ b/sys/ztimer/Makefile.dep @@ -41,6 +41,10 @@ ifneq (,$(filter ztimer_convert_%,$(USEMODULE))) USEMODULE += ztimer_convert endif +ifneq (,$(filter ztimer_periph_lptimer,$(USEMODULE))) + USEMODULE += ztimer_periph_timer +endif + ifneq (,$(filter ztimer_periph_timer,$(USEMODULE))) FEATURES_REQUIRED += periph_timer endif