diff options
| author | hathach <[email protected]> | 2026-04-04 13:20:58 +0700 |
|---|---|---|
| committer | hathach <[email protected]> | 2026-04-04 13:20:58 +0700 |
| commit | 3c6c87479be6a9fdd04240b8bb1267ef80b1a0e8 (patch) | |
| tree | 2f0d2aecb4360c71fc760dc8afbe4ac92618b73f /hw/bsp/samg | |
| parent | e01f1538b74cf3fa535e7d7f4924905b3cd35b1f (diff) | |
implement board_uart_read()/write() as non-blocking for all families
Diffstat (limited to 'hw/bsp/samg')
| -rw-r--r-- | hw/bsp/samg/family.c | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/hw/bsp/samg/family.c b/hw/bsp/samg/family.c index b27134305..519068986 100644 --- a/hw/bsp/samg/family.c +++ b/hw/bsp/samg/family.c @@ -134,11 +134,16 @@ int board_uart_read(uint8_t* buf, int len) { int board_uart_write(void const* buf, int len) { uint8_t const* buf8 = (uint8_t const*) buf; - for (int i = 0; i < len; i++) { - while (!_usart_sync_is_ready_to_send(&edbg_com)) {} - _usart_sync_write_byte(&edbg_com, buf8[i]); + int count = 0; + while (count < len) { + if (_usart_sync_is_ready_to_send(&edbg_com)) { + _usart_sync_write_byte(&edbg_com, buf8[count]); + count++; + } else { + break; + } } - return len; + return count; } #if CFG_TUSB_OS == OPT_OS_NONE |
