From 2b696fd770f6d367193f8c38fcf0398a71b5939f Mon Sep 17 00:00:00 2001 From: Koen Zandberg Date: Wed, 3 Nov 2021 11:30:51 +0100 Subject: [PATCH] stdio_semihosting: Convert to ztimer --- makefiles/stdio.inc.mk | 2 +- sys/stdio_semihosting/stdio_semihosting.c | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/makefiles/stdio.inc.mk b/makefiles/stdio.inc.mk index d5d10bce68..7d75fa7083 100644 --- a/makefiles/stdio.inc.mk +++ b/makefiles/stdio.inc.mk @@ -45,7 +45,7 @@ ifneq (,$(filter stdio_uart,$(USEMODULE))) endif ifneq (,$(filter stdio_semihosting,$(USEMODULE))) - USEMODULE += xtimer + USEMODULE += ztimer_msec FEATURES_REQUIRED_ANY += cpu_core_cortexm|arch_riscv endif diff --git a/sys/stdio_semihosting/stdio_semihosting.c b/sys/stdio_semihosting/stdio_semihosting.c index 5f7cb316e4..191eb33654 100644 --- a/sys/stdio_semihosting/stdio_semihosting.c +++ b/sys/stdio_semihosting/stdio_semihosting.c @@ -25,7 +25,7 @@ #include #include "stdio_semihosting.h" -#include "xtimer.h" +#include "ztimer.h" #if MODULE_VFS #include "vfs.h" @@ -35,7 +35,7 @@ * @brief Rate at which the stdin read polls (breaks) the debugger for input * data */ -#define STDIO_SEMIHOSTING_POLL_RATE (10 * US_PER_MS) +#define STDIO_SEMIHOSTING_POLL_RATE (10) /** * @brief ARM Semihosting STDIN file descriptor. Also used with RISC-V @@ -157,10 +157,11 @@ void stdio_init(void) ssize_t stdio_read(void* buffer, size_t count) { if (STDIO_SEMIHOSTING_RX) { - xtimer_ticks32_t last_wakeup = xtimer_now(); + uint32_t last_wakeup = ztimer_now(ZTIMER_MSEC); ssize_t bytes_read = _semihosting_read(buffer, count); while (bytes_read == 0) { - xtimer_periodic_wakeup(&last_wakeup, STDIO_SEMIHOSTING_POLL_RATE); + ztimer_periodic_wakeup(ZTIMER_MSEC, &last_wakeup, + STDIO_SEMIHOSTING_POLL_RATE); bytes_read = _semihosting_read(buffer, count); } return bytes_read;