Merge pull request #17123 from bergzand/pr/stdio_semihosting/ztimer

stdio_semihosting: Convert to ztimer
This commit is contained in:
Koen Zandberg 2021-11-03 16:22:45 +01:00 committed by GitHub
commit 1fa8bcc9d2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 6 deletions

View File

@ -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

View File

@ -25,7 +25,7 @@
#include <string.h>
#include "stdio_semihosting.h"
#include "xtimer.h"
#include "ztimer.h"
#if MODULE_VFS
#include "vfs.h"
@ -33,9 +33,9 @@
/**
* @brief Rate at which the stdin read polls (breaks) the debugger for input
* data
* data in milliseconds
*/
#define STDIO_SEMIHOSTING_POLL_RATE (10 * US_PER_MS)
#define STDIO_SEMIHOSTING_POLL_RATE_MS (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_MS);
bytes_read = _semihosting_read(buffer, count);
}
return bytes_read;