From 3e47f1fcce4d7b445a0ed161cbd860a87eafff30 Mon Sep 17 00:00:00 2001 From: hathach Date: Wed, 18 Mar 2026 00:20:42 +0700 Subject: [PATCH] add board_uart_read() for f7 --- .github/actions/get_deps/action.yml | 8 ++++-- hw/bsp/stm32f7/family.c | 28 ++++++++++++++++++--- hw/bsp/stm32h7/boards/stm32h743eval/board.h | 2 -- 3 files changed, 31 insertions(+), 7 deletions(-) diff --git a/.github/actions/get_deps/action.yml b/.github/actions/get_deps/action.yml index bbe94f0fa..ff6972af6 100644 --- a/.github/actions/get_deps/action.yml +++ b/.github/actions/get_deps/action.yml @@ -9,8 +9,12 @@ runs: using: "composite" steps: - name: Checkout pico-sdk for rp2040 - if: contains(inputs.arg, 'rp2040') || contains(inputs.arg, 'raspberry_pi_pico') - uses: actions/checkout@v4 + if: >- + contains(inputs.arg, 'rp2040') || + contains(inputs.arg, 'rp2350') || + contains(inputs.arg, 'raspberry_pi_pico') || + contains(inputs.arg, 'adafruit_fruit_jam') + uses: actions/checkout@v6 with: repository: raspberrypi/pico-sdk ref: master diff --git a/hw/bsp/stm32f7/family.c b/hw/bsp/stm32f7/family.c index ce9049abe..f8145cd63 100644 --- a/hw/bsp/stm32f7/family.c +++ b/hw/bsp/stm32f7/family.c @@ -289,14 +289,31 @@ size_t board_get_unique_id(uint8_t id[], size_t max_len) { } int board_uart_read(uint8_t *buf, int len) { - (void) buf; - (void) len; +#ifdef UART_DEV + int count = 0; + // clear overrun error if any + if (__HAL_UART_GET_FLAG(&UartHandle, UART_FLAG_ORE)) { + __HAL_UART_CLEAR_FLAG(&UartHandle, UART_CLEAR_OREF); + } + for (int i = 0; i < len; i++) { + if (__HAL_UART_GET_FLAG(&UartHandle, UART_FLAG_RXNE)) { + buf[i] = (uint8_t) UartHandle.Instance->RDR; + count++; + } else { + break; + } + } + return count; +#else + (void) buf; (void) len; return 0; +#endif } int board_uart_write(void const *buf, int len) { #ifdef UART_DEV - HAL_UART_Transmit(&UartHandle, (uint8_t *) (uintptr_t) buf, len, 0xffff); + HAL_UART_Transmit(&UartHandle, (uint8_t * )(uintptr_t) + buf, len, 0xffff); return len; #else (void) buf; (void) len; @@ -316,6 +333,11 @@ uint32_t tusb_time_millis_api(void) { return system_ticks; } +#elif CFG_TUSB_OS == OPT_OS_THREADX +// Keep HAL_GetTick() working for HAL functions called from board_init() +void osal_threadx_tick_cb(void) { + HAL_IncTick(); +} #endif void HardFault_Handler(void) { diff --git a/hw/bsp/stm32h7/boards/stm32h743eval/board.h b/hw/bsp/stm32h7/boards/stm32h743eval/board.h index 3914d7aac..ea91976c8 100644 --- a/hw/bsp/stm32h7/boards/stm32h743eval/board.h +++ b/hw/bsp/stm32h7/boards/stm32h743eval/board.h @@ -211,7 +211,6 @@ static int32_t i2c_readreg(uint16_t DevAddr, uint16_t Reg, uint8_t *pData, uint1 } HAL_Delay(10); } - TU_ASSERT(0); return -1; } @@ -222,7 +221,6 @@ static int32_t i2c_writereg(uint16_t DevAddr, uint16_t Reg, uint8_t *pData, uint } HAL_Delay(10); } - TU_ASSERT(0); return -1; }