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
|
endif
|
||||||
|
|
||||||
ifneq (,$(filter stdio_rtt,$(USEMODULE)))
|
ifneq (,$(filter stdio_rtt,$(USEMODULE)))
|
||||||
USEMODULE += xtimer
|
USEMODULE += ztimer_msec
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifneq (,$(filter stdio_ethos,$(USEMODULE)))
|
ifneq (,$(filter stdio_ethos,$(USEMODULE)))
|
||||||
|
|||||||
@ -79,7 +79,7 @@
|
|||||||
#include "stdio_rtt.h"
|
#include "stdio_rtt.h"
|
||||||
#include "thread.h"
|
#include "thread.h"
|
||||||
#include "mutex.h"
|
#include "mutex.h"
|
||||||
#include "xtimer.h"
|
#include "ztimer.h"
|
||||||
|
|
||||||
#if MODULE_VFS
|
#if MODULE_VFS
|
||||||
#include "vfs.h"
|
#include "vfs.h"
|
||||||
@ -88,7 +88,7 @@
|
|||||||
/* This parameter affects the bandwidth of both input and output. Decreasing
|
/* This parameter affects the bandwidth of both input and output. Decreasing
|
||||||
it will significantly improve bandwidth at the cost of CPU time. */
|
it will significantly improve bandwidth at the cost of CPU time. */
|
||||||
#ifndef STDIO_POLL_INTERVAL
|
#ifndef STDIO_POLL_INTERVAL
|
||||||
#define STDIO_POLL_INTERVAL 50000U
|
#define STDIO_POLL_INTERVAL 50U
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define MIN(a, b) (((a) < (b)) ? (a) : (b))
|
#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
|
/* We only unlock when rtt_stdio_enable_stdin is called
|
||||||
Note that we assume only one caller invoked this function */
|
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) {
|
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);
|
res = rtt_read(buffer, count);
|
||||||
if (res > 0)
|
if (res > 0)
|
||||||
return res;
|
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) {
|
ssize_t stdio_write(const void* in, size_t len) {
|
||||||
const char *buffer = (const char *)in;
|
const char *buffer = (const char *)in;
|
||||||
int written = rtt_write(buffer, (unsigned)len);
|
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)) {
|
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);
|
written += rtt_write(&buffer[written], len-written);
|
||||||
}
|
}
|
||||||
return (ssize_t)written;
|
return (ssize_t)written;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user