From e01f1538b74cf3fa535e7d7f4924905b3cd35b1f Mon Sep 17 00:00:00 2001 From: hathach Date: Fri, 3 Apr 2026 22:01:21 +0700 Subject: fix rp2040 uart read/write non-blocking --- hw/bsp/rp2040/family.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/hw/bsp/rp2040/family.c b/hw/bsp/rp2040/family.c index c952de03b..b5a1375a2 100644 --- a/hw/bsp/rp2040/family.c +++ b/hw/bsp/rp2040/family.c @@ -273,11 +273,13 @@ int board_uart_read(uint8_t *buf, int len) { int board_uart_write(void const *buf, int len) { #ifdef UART_DEV - char const *bufch = (char const *) buf; - for ( int i = 0; i < len; i++ ) { - uart_putc(uart_inst, bufch[i]); + const uint8_t *p = (const uint8_t *) buf; + int count = 0; + while (count < len && uart_is_writable(uart_inst)) { + uart_putc_raw(uart_inst, p[count]); + count++; } - return len; + return count; #else (void) buf; (void) len; return 0; -- cgit v1.3.1