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 */ 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) 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)