Skip to content

Commit e01f153

Browse files
committed
fix rp2040 uart read/write non-blocking
1 parent 81efb78 commit e01f153

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

hw/bsp/rp2040/family.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -273,11 +273,13 @@ int board_uart_read(uint8_t *buf, int len) {
273273

274274
int board_uart_write(void const *buf, int len) {
275275
#ifdef UART_DEV
276-
char const *bufch = (char const *) buf;
277-
for ( int i = 0; i < len; i++ ) {
278-
uart_putc(uart_inst, bufch[i]);
276+
const uint8_t *p = (const uint8_t *) buf;
277+
int count = 0;
278+
while (count < len && uart_is_writable(uart_inst)) {
279+
uart_putc_raw(uart_inst, p[count]);
280+
count++;
279281
}
280-
return len;
282+
return count;
281283
#else
282284
(void) buf; (void) len;
283285
return 0;

0 commit comments

Comments
 (0)