diff options
| author | hathach <[email protected]> | 2026-04-03 22:01:21 +0700 |
|---|---|---|
| committer | hathach <[email protected]> | 2026-04-03 22:01:21 +0700 |
| commit | e01f1538b74cf3fa535e7d7f4924905b3cd35b1f (patch) | |
| tree | 848e7376c210472455cd6ecb7da82c9f0a9f3c6c | |
| parent | 81efb78d1655dcab31da5e03fd7e22e91491d186 (diff) | |
fix rp2040 uart read/write non-blocking
| -rw-r--r-- | hw/bsp/rp2040/family.c | 10 |
1 files 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; |
