From 9897a36ac4cf0dcc469f46d381c4b13d72298acb Mon Sep 17 00:00:00 2001 From: hathach Date: Thu, 31 Oct 2024 12:11:47 +0700 Subject: [PATCH] fix f7 ci build --- hw/bsp/stm32f7/boards/stm32f723disco/board.h | 2 +- hw/bsp/stm32f7/family.c | 3 +++ hw/bsp/stm32h7/boards/stm32h743eval/board.h | 15 +++++++-------- hw/bsp/stm32h7/family.c | 10 ++++++---- 4 files changed, 17 insertions(+), 13 deletions(-) diff --git a/hw/bsp/stm32f7/boards/stm32f723disco/board.h b/hw/bsp/stm32f7/boards/stm32f723disco/board.h index 178fd6e5e..37f18fedf 100644 --- a/hw/bsp/stm32f7/boards/stm32f723disco/board.h +++ b/hw/bsp/stm32f7/boards/stm32f723disco/board.h @@ -122,7 +122,7 @@ static board_pindef_t vbus_pindef[] = { }, }; -static inline void board_vbus_set(uint8_t rhport, bool state) { +void board_vbus_set(uint8_t rhport, bool state) { static bool pin_inited[2] = { false, false }; board_pindef_t* pindef = &vbus_pindef[rhport]; if (!pin_inited[rhport]) { diff --git a/hw/bsp/stm32f7/family.c b/hw/bsp/stm32f7/family.c index 1f49d7693..f1671b362 100644 --- a/hw/bsp/stm32f7/family.c +++ b/hw/bsp/stm32f7/family.c @@ -28,6 +28,9 @@ #include "stm32f7xx_hal.h" #include "bsp/board_api.h" + +void board_vbus_set(uint8_t rhport, bool state) TU_ATTR_WEAK; + #include "board.h" //--------------------------------------------------------------------+ diff --git a/hw/bsp/stm32h7/boards/stm32h743eval/board.h b/hw/bsp/stm32h7/boards/stm32h743eval/board.h index 9e2649d14..2e2d4aebd 100644 --- a/hw/bsp/stm32h7/boards/stm32h743eval/board.h +++ b/hw/bsp/stm32h7/boards/stm32h743eval/board.h @@ -60,14 +60,6 @@ {GPIOB, GPIO_PIN_5 }, {GPIOB, GPIO_PIN_10}, {GPIOB, GPIO_PIN_11}, {GPIOB, GPIO_PIN_12}, \ {GPIOB, GPIO_PIN_13}, {GPIOC, GPIO_PIN_0 }, {GPIOH, GPIO_PIN_4 }, {GPIOI, GPIO_PIN_11} -// vbus drive -#define BOARD_VBUS_DRIVE(_rhport, _on) do { \ - if ( mfx_io_drv ) { \ - uint32_t io_pin = (_rhport) ? MFXSTM32L152_GPIO_PIN_9 : MFXSTM32L152_GPIO_PIN_7; \ - mfx_io_drv->IO_WritePin(&Io_CompObj, io_pin, _on); \ - }\ - } while(0) - /* Definition for I2C1 Pins */ #define BUS_I2C1_SCL_PIN GPIO_PIN_6 #define BUS_I2C1_SDA_PIN GPIO_PIN_7 @@ -283,6 +275,13 @@ static inline void board_init2(void) { #endif } +// vbus drive +void board_vbus_set(uint8_t rhport, bool state) { + if ( mfx_io_drv ) { + uint32_t io_pin = (_rhport) ? MFXSTM32L152_GPIO_PIN_9 : MFXSTM32L152_GPIO_PIN_7; + mfx_io_drv->IO_WritePin(&Io_CompObj, io_pin, _on); + } +} #ifdef __cplusplus } diff --git a/hw/bsp/stm32h7/family.c b/hw/bsp/stm32h7/family.c index c8b7c6fe3..27e7d0a49 100644 --- a/hw/bsp/stm32h7/family.c +++ b/hw/bsp/stm32h7/family.c @@ -30,8 +30,8 @@ #include "stm32h7xx_hal.h" #include "bsp/board_api.h" -TU_ATTR_UNUSED static void Error_Handler(void) { -} +TU_ATTR_UNUSED static void Error_Handler(void) { } +void board_vbus_set(uint8_t rhport, bool state) TU_ATTR_WEAK; #include "board.h" @@ -196,6 +196,7 @@ void board_init(void) { #endif // vbus sense //------------- USB HS -------------// +#if (CFG_TUD_ENABLED && BOARD_TUD_RHPORT == 1) || (CFG_TUH_ENABLED && BOARD_TUH_RHPORT == 1) // Despite being call USB2_OTG // OTG_HS is marked as RHPort1 by TinyUSB to be consistent across stm32 port struct { @@ -232,14 +233,15 @@ void board_init(void) { // Force device mode USB_OTG_HS->GUSBCFG &= ~USB_OTG_GUSBCFG_FHMOD; USB_OTG_HS->GUSBCFG |= USB_OTG_GUSBCFG_FDMOD; +#endif HAL_PWREx_EnableUSBVoltageDetector(); // For waveshare openh743 ULPI PHY reset walkaround board_init2(); -#if CFG_TUH_ENABLED && defined(BOARD_VBUS_DRIVE) - BOARD_VBUS_DRIVE(BOARD_TUH_RHPORT, 1); +#if CFG_TUH_ENABLED + board_vbus_set(BOARD_TUH_RHPORT, 1); #endif }