From 9b03d459533a3164dae3f54c468c443f5dc5c545 Mon Sep 17 00:00:00 2001 From: Francisco Molina Date: Tue, 14 Dec 2021 13:17:19 +0100 Subject: [PATCH 1/3] tests/periph_rtt_min: update CPUs with configurable rtt freq --- tests/periph_rtt_min/Makefile | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/tests/periph_rtt_min/Makefile b/tests/periph_rtt_min/Makefile index 894f3ac1ce..7a738aaed5 100644 --- a/tests/periph_rtt_min/Makefile +++ b/tests/periph_rtt_min/Makefile @@ -11,15 +11,10 @@ RIOT_TERMINAL ?= socat include $(RIOTBASE)/Makefile.include # use highest possible RTT_FREQUENCY for boards that allow it -ifneq (,$(filter stm32 nrf5%,$(CPU))) +ifneq (,$(filter stm32 nrf5% sam% kinetis efm32 fe310,$(CPU))) RTT_FREQUENCY ?= RTT_MAX_FREQUENCY CFLAGS += -DRTT_FREQUENCY=$(RTT_FREQUENCY) endif -# kinetis rtt runs at 1Hz, reduce samples to speed up the test -ifneq (,$(filter kinetis,$(CPU))) - SAMPLES ?= 64 -else - SAMPLES ?= 1024 -endif +SAMPLES ?= 1024 CFLAGS += -DSAMPLES=$(SAMPLES) From d4c84b592f6fcf08a0001701b709720e23532ef7 Mon Sep 17 00:00:00 2001 From: Francisco Molina Date: Tue, 14 Dec 2021 13:18:43 +0100 Subject: [PATCH 2/3] cpu/kinetis/include: fix xtimer backend timer selection --- cpu/kinetis/include/periph_cpu.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cpu/kinetis/include/periph_cpu.h b/cpu/kinetis/include/periph_cpu.h index 7b81bb9c35..6cec6d6c23 100644 --- a/cpu/kinetis/include/periph_cpu.h +++ b/cpu/kinetis/include/periph_cpu.h @@ -500,7 +500,7 @@ enum { #ifndef RTT_FREQUENCY #define RTT_FREQUENCY RTT_MAX_FREQUENCY #endif -#if IS_USED(PERIPH_RTT) +#if IS_USED(MODULE_PERIPH_RTT) /* On kinetis periph_rtt is built on top on an LPTIMER so if used it will conflict with xtimer, if a LPTIMER backend and RTT are needed consider using ztimer */ From bf05468fab08691fed0abfc8da4a71075832c684 Mon Sep 17 00:00:00 2001 From: Francisco Molina Date: Tue, 14 Dec 2021 13:19:01 +0100 Subject: [PATCH 3/3] cpu/kinetis/rtt: remove callback on clear --- cpu/kinetis/periph/rtt.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/cpu/kinetis/periph/rtt.c b/cpu/kinetis/periph/rtt.c index 59079f2a38..d7f57ce9a0 100644 --- a/cpu/kinetis/periph/rtt.c +++ b/cpu/kinetis/periph/rtt.c @@ -31,7 +31,7 @@ #include "debug.h" static rtt_cb_t alarm_cb = NULL; /**< callback called from RTC alarm */ -static void *alarm_arg; /**< argument passed to the callback */ +static void *alarm_arg = NULL; /**< argument passed to the callback */ static uint32_t alarm_value = 0; static void _rtt_cb(void *arg, int channel) @@ -46,7 +46,6 @@ static void _rtt_cb(void *arg, int channel) void rtt_init(void) { timer_init(RTT_DEV, RTT_FREQUENCY, _rtt_cb, NULL); - alarm_value = 0; } uint32_t rtt_get_counter(void) @@ -60,7 +59,7 @@ void rtt_set_alarm(uint32_t alarm, rtt_cb_t cb, void *arg) alarm_arg = arg; alarm_cb = cb; alarm_value = alarm; - timer_set_absolute(RTT_DEV, 0, alarm % RTT_MAX_VALUE); + timer_set_absolute(RTT_DEV, 0, alarm & RTT_MAX_VALUE); irq_restore(state); } @@ -71,7 +70,11 @@ uint32_t rtt_get_alarm(void) void rtt_clear_alarm(void) { + unsigned state = irq_disable(); + alarm_cb = NULL; + alarm_arg = NULL; timer_clear(RTT_DEV, 0); + irq_restore(state); } void rtt_poweron(void)