mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
stdio_rtt: Convert to ztimer
This commit is contained in:
parent
6749b71066
commit
aa17621279
@ -20,7 +20,7 @@ ifneq (,$(filter stdio_cdc_acm,$(USEMODULE)))
|
||||
endif
|
||||
|
||||
ifneq (,$(filter stdio_rtt,$(USEMODULE)))
|
||||
USEMODULE += xtimer
|
||||
USEMODULE += ztimer_msec
|
||||
endif
|
||||
|
||||
ifneq (,$(filter stdio_ethos,$(USEMODULE)))
|
||||
|
@ -79,7 +79,7 @@
|
||||
#include "stdio_rtt.h"
|
||||
#include "thread.h"
|
||||
#include "mutex.h"
|
||||
#include "xtimer.h"
|
||||
#include "ztimer.h"
|
||||
|
||||
#if MODULE_VFS
|
||||
#include "vfs.h"
|
||||
@ -88,7 +88,7 @@
|
||||
/* This parameter affects the bandwidth of both input and output. Decreasing
|
||||
it will significantly improve bandwidth at the cost of CPU time. */
|
||||
#ifndef STDIO_POLL_INTERVAL
|
||||
#define STDIO_POLL_INTERVAL 50000U
|
||||
#define STDIO_POLL_INTERVAL 50U
|
||||
#endif
|
||||
|
||||
#define MIN(a, b) (((a) < (b)) ? (a) : (b))
|
||||
@ -315,9 +315,9 @@ ssize_t stdio_read(void* buffer, size_t count) {
|
||||
/* We only unlock when rtt_stdio_enable_stdin is called
|
||||
Note that we assume only one caller invoked this function */
|
||||
}
|
||||
xtimer_ticks32_t last_wakeup = xtimer_now();
|
||||
uint32_t last_wakeup = ztimer_now(ZTIMER_MSEC);
|
||||
while(1) {
|
||||
xtimer_periodic_wakeup(&last_wakeup, STDIO_POLL_INTERVAL);
|
||||
ztimer_periodic_wakeup(ZTIMER_MSEC, &last_wakeup, STDIO_POLL_INTERVAL);
|
||||
res = rtt_read(buffer, count);
|
||||
if (res > 0)
|
||||
return res;
|
||||
@ -329,9 +329,9 @@ ssize_t stdio_read(void* buffer, size_t count) {
|
||||
ssize_t stdio_write(const void* in, size_t len) {
|
||||
const char *buffer = (const char *)in;
|
||||
int written = rtt_write(buffer, (unsigned)len);
|
||||
xtimer_ticks32_t last_wakeup = xtimer_now();
|
||||
uint32_t last_wakeup = ztimer_now(ZTIMER_MSEC);
|
||||
while (blocking_stdout && ((size_t)written < len)) {
|
||||
xtimer_periodic_wakeup(&last_wakeup, STDIO_POLL_INTERVAL);
|
||||
ztimer_periodic_wakeup(ZTIMER_MSEC, &last_wakeup, STDIO_POLL_INTERVAL);
|
||||
written += rtt_write(&buffer[written], len-written);
|
||||
}
|
||||
return (ssize_t)written;
|
||||
|
Loading…
Reference in New Issue
Block a user