diff --git a/boards/common/stm32/include/cfg_rtt_default.h b/boards/common/stm32/include/cfg_rtt_default.h index d58c61d057..eb8e1a4233 100644 --- a/boards/common/stm32/include/cfg_rtt_default.h +++ b/boards/common/stm32/include/cfg_rtt_default.h @@ -31,8 +31,15 @@ extern "C" { * On the STM32Lx platforms, we always utilize the LPTIM1. * @{ */ -#define RTT_FREQUENCY (1024U) /* 32768 / 2^n */ -#define RTT_MAX_VALUE (0x0000ffff) /* 16-bit timer */ +#define RTT_CLOCK_FREQUENCY (32768U) /* in Hz */ + +#define RTT_MAX_VALUE (0x0000ffff) /* 16-bit timer */ +#define RTT_MAX_FREQUENCY (RTT_CLOCK_FREQUENCY) /* 32768Hz at @32768Hz */ +#define RTT_MIN_FREQUENCY (RTT_CLOCK_FREQUENCY / 128) /* 256Hz at @32768Hz */ + +#ifndef RTT_FREQUENCY +#define RTT_FREQUENCY (RTT_MAX_FREQUENCY) /* in Hz */ +#endif /** @} */ #ifdef __cplusplus diff --git a/boards/nucleo-f413zh/include/periph_conf.h b/boards/nucleo-f413zh/include/periph_conf.h index f0b2436e92..046fa56a83 100644 --- a/boards/nucleo-f413zh/include/periph_conf.h +++ b/boards/nucleo-f413zh/include/periph_conf.h @@ -24,6 +24,7 @@ #include "periph_cpu.h" #include "f4/cfg_clock_100_8_1.h" #include "cfg_i2c1_pb8_pb9.h" +#include "cfg_rtt_default.h" #include "cfg_timer_tim5.h" #include "cfg_usb_otg_fs.h" @@ -217,8 +218,9 @@ static const spi_conf_t spi_config[] = { * @name RTT configuration * @{ */ +#ifndef RTT_FREQUENCY #define RTT_FREQUENCY (4096) -#define RTT_MAX_VALUE (0xffff) +#endif /** @} */ #ifdef __cplusplus diff --git a/tests/periph_rtt/Makefile b/tests/periph_rtt/Makefile index e685d5a054..80c2d54209 100644 --- a/tests/periph_rtt/Makefile +++ b/tests/periph_rtt/Makefile @@ -6,3 +6,11 @@ FEATURES_REQUIRED = periph_rtt DISABLE_MODULE += periph_init_rtt include $(RIOTBASE)/Makefile.include + +# Put board specific dependencies here +ifneq (,$(filter-out stm32f1,$(filter stm32%,$(CPU)))) + # all stm32% but stm32f1 RTT are based on a 16 bit LPTIM, if using the default + # 32768KHz configuration TICKS_TO_WAIT will overflow + RTT_FREQUENCY ?= 1024 + CFLAGS += -DRTT_FREQUENCY=$(RTT_FREQUENCY) +endif