1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

stdio_semihosting: Convert to ztimer

This commit is contained in:
Koen Zandberg 2021-11-03 11:30:51 +01:00
parent 49cecdbc44
commit 2b696fd770
No known key found for this signature in database
GPG Key ID: 0895A893E6D2985B
2 changed files with 6 additions and 5 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"
@ -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;