ports: Implement simple write polling for stdout.

This is a best-effort implementation of write polling.  It's difficult to
do correctly because if there are multiple output streams (eg UART and USB
CDC) then some may not be writeable while others are.  A full solution
should also have a return value from mp_hal_stdout_tx_strn(), returning the
number of bytes written to the stream(s).  That's also hard to define.

The renesas-ra and stm32 ports already implement a similar best-effort
mechanism for write polling.

Fixes issue #11026.

Signed-off-by: Damien George <damien@micropython.org>
This commit is contained in:
Damien George
2023-03-22 00:14:46 +11:00
parent 6c76248960
commit 38e7b842c6
10 changed files with 39 additions and 0 deletions

View File

@@ -57,6 +57,9 @@ uintptr_t mp_hal_stdio_poll(uintptr_t poll_flags) {
if ((poll_flags & MP_STREAM_POLL_RD) && uart_rx_any()) {
ret |= MP_STREAM_POLL_RD;
}
if (poll_flags & MP_STREAM_POLL_WR) {
ret |= MP_STREAM_POLL_WR;
}
return ret;
}