diff options
| author | Ha Thach <[email protected]> | 2026-05-04 08:57:27 +0700 |
|---|---|---|
| committer | GitHub <[email protected]> | 2026-05-04 08:57:27 +0700 |
| commit | 84e2e6d1186b3dd1d5f88154adce4f5ecb8b403d (patch) | |
| tree | a398be8b016d6e6fdbcdb8ef0fa5faa6796745aa | |
| parent | 939c2f91c200db2bf9874c2e6c50b3530f8a6725 (diff) | |
| parent | 4e7db9c60d9ff77b3e0de14ecdfeb372813c46b7 (diff) | |
Merge pull request #3628 from hathach/fix_uart_write
ensure board_uart_write return -1 on default
35 files changed, 39 insertions, 36 deletions
diff --git a/hw/bsp/at32f402_405/family.c b/hw/bsp/at32f402_405/family.c index 56d4a7bea..aa1a5b484 100644 --- a/hw/bsp/at32f402_405/family.c +++ b/hw/bsp/at32f402_405/family.c @@ -220,7 +220,7 @@ int board_uart_write(void const *buf, int len) #else (void) buf; (void) len; - return 0; + return -1; #endif } diff --git a/hw/bsp/at32f403a_407/family.c b/hw/bsp/at32f403a_407/family.c index 942e15872..cf15ba83a 100644 --- a/hw/bsp/at32f403a_407/family.c +++ b/hw/bsp/at32f403a_407/family.c @@ -238,7 +238,7 @@ int board_uart_write(void const *buf, int len) { #else (void) buf; (void) len; - return 0; + return -1; #endif } diff --git a/hw/bsp/at32f413/family.c b/hw/bsp/at32f413/family.c index d9af0ae4d..69591b2ba 100644 --- a/hw/bsp/at32f413/family.c +++ b/hw/bsp/at32f413/family.c @@ -238,7 +238,7 @@ int board_uart_write(void const *buf, int len) { #else (void) buf; (void) len; - return 0; + return -1; #endif } diff --git a/hw/bsp/at32f415/family.c b/hw/bsp/at32f415/family.c index ca205d480..132e0db31 100644 --- a/hw/bsp/at32f415/family.c +++ b/hw/bsp/at32f415/family.c @@ -212,7 +212,7 @@ int board_uart_write(void const *buf, int len) { #else (void) buf; (void) len; - return 0; + return -1; #endif } diff --git a/hw/bsp/at32f423/family.c b/hw/bsp/at32f423/family.c index 9f13dba07..79ac3fcca 100644 --- a/hw/bsp/at32f423/family.c +++ b/hw/bsp/at32f423/family.c @@ -239,7 +239,7 @@ int board_uart_write(void const *buf, int len) { #else (void) buf; (void) len; - return 0; + return -1; #endif } diff --git a/hw/bsp/at32f425/family.c b/hw/bsp/at32f425/family.c index 1629ad7c0..75e53b1f7 100644 --- a/hw/bsp/at32f425/family.c +++ b/hw/bsp/at32f425/family.c @@ -220,7 +220,7 @@ int board_uart_write(void const *buf, int len) { #else (void) buf; (void) len; - return 0; + return -1; #endif } diff --git a/hw/bsp/at32f435_437/family.c b/hw/bsp/at32f435_437/family.c index 59a4fe120..80e200363 100644 --- a/hw/bsp/at32f435_437/family.c +++ b/hw/bsp/at32f435_437/family.c @@ -265,7 +265,7 @@ int board_uart_write(void const *buf, int len) { #else (void) buf; (void) len; - return 0; + return -1; #endif } diff --git a/hw/bsp/at32f45x/family.c b/hw/bsp/at32f45x/family.c index 27eae861f..42b688b87 100644 --- a/hw/bsp/at32f45x/family.c +++ b/hw/bsp/at32f45x/family.c @@ -216,7 +216,7 @@ int board_uart_write(void const *buf, int len) { #else (void) buf; (void) len; - return 0; + return -1; #endif } diff --git a/hw/bsp/board.c b/hw/bsp/board.c index 65b44e5f2..5093382d9 100644 --- a/hw/bsp/board.c +++ b/hw/bsp/board.c @@ -171,7 +171,7 @@ int board_getchar(void) { } int board_putchar(int c) { - if (board_uart_write((const char *)&c, 1)) { + if (board_uart_write((const char *)&c, 1) > 0) { return c; } else { return -1; diff --git a/hw/bsp/ch32v20x/family.c b/hw/bsp/ch32v20x/family.c index 221f62107..76024cfde 100644 --- a/hw/bsp/ch32v20x/family.c +++ b/hw/bsp/ch32v20x/family.c @@ -220,6 +220,6 @@ int board_uart_write(void const *buf, int len) { return count; #else (void) buf; (void) len; - return 0; + return -1; #endif } diff --git a/hw/bsp/ft9xx/family.c b/hw/bsp/ft9xx/family.c index 5ee134eb0..0ca2663ac 100644 --- a/hw/bsp/ft9xx/family.c +++ b/hw/bsp/ft9xx/family.c @@ -221,8 +221,8 @@ int board_uart_read(uint8_t *buf, int len) // Send characters to UART int board_uart_write(void const *buf, int len) { - int count = 0; #ifdef BOARD_UART + int count = 0; uint8_t const *p = (uint8_t const *) buf; while (count < len) { if (BOARD_UART->LSR_ICR_XON2 & MASK_UART_LSR_THRE) { @@ -232,10 +232,11 @@ int board_uart_write(void const *buf, int len) break; } } + return count; #else (void) buf; (void) len; + return -1; #endif - return count; } // Get current milliseconds diff --git a/hw/bsp/gd32vf103/family.c b/hw/bsp/gd32vf103/family.c index c1dc82bda..8f82b3ada 100644 --- a/hw/bsp/gd32vf103/family.c +++ b/hw/bsp/gd32vf103/family.c @@ -174,7 +174,7 @@ int board_uart_write(void const* buf, int len) { #else (void)buf; (void)len; - return 0; + return -1; #endif } diff --git a/hw/bsp/kinetis_k/family.c b/hw/bsp/kinetis_k/family.c index 8efab2762..a5af83931 100644 --- a/hw/bsp/kinetis_k/family.c +++ b/hw/bsp/kinetis_k/family.c @@ -140,7 +140,7 @@ int board_uart_write(void const *buf, int len) { #else (void) buf; (void) len; - return 0; + return -1; #endif } diff --git a/hw/bsp/mm32/family.c b/hw/bsp/mm32/family.c index 14a17f6c5..1538181dc 100644 --- a/hw/bsp/mm32/family.c +++ b/hw/bsp/mm32/family.c @@ -167,7 +167,7 @@ int board_uart_write(void const* buf, int len) { #else (void) buf; (void) len; - return 0; + return -1; #endif } diff --git a/hw/bsp/pic32mz/family.c b/hw/bsp/pic32mz/family.c index 5805e653f..98038b4f7 100644 --- a/hw/bsp/pic32mz/family.c +++ b/hw/bsp/pic32mz/family.c @@ -102,7 +102,9 @@ TU_ATTR_WEAK int board_uart_read(uint8_t * buf, int len) TU_ATTR_WEAK int board_uart_write(void const * buf, int len) { (void) buf; - return len; + (void) len; + + return -1; } #if CFG_TUSB_OS == OPT_OS_NONE diff --git a/hw/bsp/rp2040/family.c b/hw/bsp/rp2040/family.c index a4642face..55feec159 100644 --- a/hw/bsp/rp2040/family.c +++ b/hw/bsp/rp2040/family.c @@ -282,7 +282,7 @@ int board_uart_write(void const *buf, int len) { return count; #else (void) buf; (void) len; - return 0; + return -1; #endif } diff --git a/hw/bsp/stm32c0/family.c b/hw/bsp/stm32c0/family.c index 72af3ce7f..ac37045fb 100644 --- a/hw/bsp/stm32c0/family.c +++ b/hw/bsp/stm32c0/family.c @@ -193,7 +193,7 @@ int board_uart_write(void const *buf, int len) { return count; #else (void) buf; (void) len; - return 0; + return -1; #endif } diff --git a/hw/bsp/stm32f0/family.c b/hw/bsp/stm32f0/family.c index f413163e5..c77ef4008 100644 --- a/hw/bsp/stm32f0/family.c +++ b/hw/bsp/stm32f0/family.c @@ -206,7 +206,7 @@ int board_uart_write(void const *buf, int len) { return count; #else (void) buf; (void) len; - return 0; + return -1; #endif } diff --git a/hw/bsp/stm32f1/family.c b/hw/bsp/stm32f1/family.c index 74e0f53f2..abde44d21 100644 --- a/hw/bsp/stm32f1/family.c +++ b/hw/bsp/stm32f1/family.c @@ -246,7 +246,7 @@ int board_uart_write(void const *buf, int len) { return count; #else (void) buf; (void) len; - return 0; + return -1; #endif } diff --git a/hw/bsp/stm32f2/family.c b/hw/bsp/stm32f2/family.c index 051a026c5..260e5e067 100644 --- a/hw/bsp/stm32f2/family.c +++ b/hw/bsp/stm32f2/family.c @@ -210,7 +210,7 @@ int board_uart_write(void const* buf, int len) { return count; #else (void) buf; (void) len; - return 0; + return -1; #endif } diff --git a/hw/bsp/stm32f3/family.c b/hw/bsp/stm32f3/family.c index 0864d0fad..35e1852e8 100644 --- a/hw/bsp/stm32f3/family.c +++ b/hw/bsp/stm32f3/family.c @@ -222,7 +222,7 @@ int board_uart_write(void const* buf, int len) { return count; #else (void) buf; (void) len; - return 0; + return -1; #endif } diff --git a/hw/bsp/stm32f4/family.c b/hw/bsp/stm32f4/family.c index f4ef99150..4eea5c7a8 100644 --- a/hw/bsp/stm32f4/family.c +++ b/hw/bsp/stm32f4/family.c @@ -295,7 +295,7 @@ int board_uart_write(void const *buf, int len) { return count; #else (void) buf; (void) len; - return 0; + return -1; #endif } diff --git a/hw/bsp/stm32f7/family.c b/hw/bsp/stm32f7/family.c index 078e372d8..7a322591b 100644 --- a/hw/bsp/stm32f7/family.c +++ b/hw/bsp/stm32f7/family.c @@ -357,7 +357,7 @@ int board_uart_write(const void *buf, int len) { #else (void)buf; (void)len; - return 0; + return -1; #endif } diff --git a/hw/bsp/stm32g0/family.c b/hw/bsp/stm32g0/family.c index d0ff8bac2..cb674ccc9 100644 --- a/hw/bsp/stm32g0/family.c +++ b/hw/bsp/stm32g0/family.c @@ -206,7 +206,7 @@ int board_uart_write(void const *buf, int len) { return count; #else (void) buf; (void) len; - return 0; + return -1; #endif } diff --git a/hw/bsp/stm32g4/family.c b/hw/bsp/stm32g4/family.c index 98739ffd5..433f74e2a 100644 --- a/hw/bsp/stm32g4/family.c +++ b/hw/bsp/stm32g4/family.c @@ -236,7 +236,7 @@ int board_uart_write(void const *buf, int len) { return count; #else (void) buf; (void) len; - return 0; + return -1; #endif } diff --git a/hw/bsp/stm32h5/family.c b/hw/bsp/stm32h5/family.c index 8298dfaab..f52f94f32 100644 --- a/hw/bsp/stm32h5/family.c +++ b/hw/bsp/stm32h5/family.c @@ -238,7 +238,7 @@ int board_uart_write(void const* buf, int len) { return count; #else (void) buf; (void) len; - return 0; + return -1; #endif } diff --git a/hw/bsp/stm32h7/family.c b/hw/bsp/stm32h7/family.c index b32f73754..5173c5401 100644 --- a/hw/bsp/stm32h7/family.c +++ b/hw/bsp/stm32h7/family.c @@ -328,7 +328,7 @@ int board_uart_write(void const *buf, int len) { return count; #else (void) buf; (void) len; - return 0; + return -1; #endif } diff --git a/hw/bsp/stm32h7rs/family.c b/hw/bsp/stm32h7rs/family.c index 7ae9e5532..b0841c947 100644 --- a/hw/bsp/stm32h7rs/family.c +++ b/hw/bsp/stm32h7rs/family.c @@ -490,7 +490,7 @@ int board_uart_write(void const *buf, int len) { return count; #else (void) buf; (void) len; - return 0; + return -1; #endif } diff --git a/hw/bsp/stm32l0/family.c b/hw/bsp/stm32l0/family.c index 930fa2d66..a4a0ebbfe 100644 --- a/hw/bsp/stm32l0/family.c +++ b/hw/bsp/stm32l0/family.c @@ -176,7 +176,7 @@ int board_uart_write(void const* buf, int len) { #else (void) buf; (void) len; - return 0; + return -1; #endif } diff --git a/hw/bsp/stm32l4/family.c b/hw/bsp/stm32l4/family.c index 7a8acb3de..96de82bd5 100644 --- a/hw/bsp/stm32l4/family.c +++ b/hw/bsp/stm32l4/family.c @@ -264,7 +264,7 @@ int board_uart_write(void const *buf, int len) { return count; #else (void) buf; (void) len; - return 0; + return -1; #endif } diff --git a/hw/bsp/stm32n6/family.c b/hw/bsp/stm32n6/family.c index 95578af04..80de20c6a 100644 --- a/hw/bsp/stm32n6/family.c +++ b/hw/bsp/stm32n6/family.c @@ -388,7 +388,7 @@ int board_uart_write(void const *buf, int len) { return count; #else (void) buf; (void) len; - return 0; + return -1; #endif } diff --git a/hw/bsp/stm32u0/family.c b/hw/bsp/stm32u0/family.c index 5cf6e1eb2..7bd99fba6 100644 --- a/hw/bsp/stm32u0/family.c +++ b/hw/bsp/stm32u0/family.c @@ -199,7 +199,7 @@ int board_uart_write(void const *buf, int len) { return count; #else (void) buf; (void) len; - return 0; + return -1; #endif } diff --git a/hw/bsp/stm32u5/family.c b/hw/bsp/stm32u5/family.c index 41e354351..7969b1c70 100644 --- a/hw/bsp/stm32u5/family.c +++ b/hw/bsp/stm32u5/family.c @@ -304,7 +304,7 @@ int board_uart_write(void const *buf, int len) { return count; #else (void) buf; (void) len; - return 0; + return -1; #endif } diff --git a/hw/bsp/stm32wb/family.c b/hw/bsp/stm32wb/family.c index d97be2115..1f1da2271 100644 --- a/hw/bsp/stm32wb/family.c +++ b/hw/bsp/stm32wb/family.c @@ -196,7 +196,7 @@ int board_uart_write(void const* buf, int len) { return count; #else (void) buf; (void) len; - return 0; + return -1; #endif } diff --git a/hw/bsp/xmc4000/family.c b/hw/bsp/xmc4000/family.c index 1325b784b..7e224d092 100644 --- a/hw/bsp/xmc4000/family.c +++ b/hw/bsp/xmc4000/family.c @@ -150,7 +150,7 @@ int board_uart_write(void const* buf, int len) { #else (void) buf; (void) len; - return 0; + return -1; #endif } |
