diff --git a/tests/ztimer_msg/Makefile b/tests/ztimer_msg/Makefile index e198e2c38e..7289b23ccd 100644 --- a/tests/ztimer_msg/Makefile +++ b/tests/ztimer_msg/Makefile @@ -5,4 +5,7 @@ USEMODULE += ztimer_usec # uncomment this to test using ztimer msec on rtt #USEMODULE += ztimer_msec ztimer_periph_rtt +# uncomment this to test using ztimer sec on rtc +#USEMODULE += ztimer_sec ztimer_periph_rtc + include $(RIOTBASE)/Makefile.include diff --git a/tests/ztimer_msg/main.c b/tests/ztimer_msg/main.c index f4bbf1fce8..24e52a0bcb 100644 --- a/tests/ztimer_msg/main.c +++ b/tests/ztimer_msg/main.c @@ -31,7 +31,10 @@ #include "test_utils/expect.h" -#ifdef MODULE_ZTIMER_MSEC +#ifdef MODULE_ZTIMER_SEC +#define ZTIMER ZTIMER_SEC +#define TICKS_PER_SEC 1 +#elif MODULE_ZTIMER_MSEC #define ZTIMER ZTIMER_MSEC #define TICKS_PER_SEC MS_PER_SEC #else @@ -71,11 +74,14 @@ void *timer_thread(void *arg) msg_receive(&m); struct timer_msg *tmsg = m.content.ptr; uint32_t now = ztimer_now(ZTIMER); - printf("now=%lu:%lu -> every %lu.%lus: %s\n", - (now / TICKS_PER_SEC), - (now % TICKS_PER_SEC), - tmsg->interval / TICKS_PER_SEC, - tmsg->interval % TICKS_PER_SEC, + /* casts are needed to solve for sometimes TICKS_PER_SEC being UL + * result of / and % of uint32_t will always fit into uint32_t + */ + printf("now=%"PRIu32":%"PRIu32" -> every %"PRIu32".%"PRIu32"s: %s\n", + (uint32_t)(now / TICKS_PER_SEC), + (uint32_t)(now % TICKS_PER_SEC), + (uint32_t)(tmsg->interval / TICKS_PER_SEC), + (uint32_t)(tmsg->interval % TICKS_PER_SEC), tmsg->text); tmsg->msg.type = 12345;