This commit is contained in:
hathach
2025-07-31 23:26:27 +07:00
parent b67e00892c
commit e0f2343954
3 changed files with 117 additions and 139 deletions

View File

@@ -120,13 +120,9 @@ static void phy_hs_init(dwc2_regs_t* dwc2) {
// Set 16-bit interface if supported
if (ghwcfg4.phy_data_width) {
#if CFG_TUSB_MCU != OPT_MCU_AT32F402_405 // at32f402_405 does not actually support 16-bit
gusbcfg |= GUSBCFG_PHYIF16; // 16 bit
/* at32f402_405 does not actually support 16-bit */
#if CFG_TUSB_MCU == OPT_MCU_AT32F402_405
gusbcfg &= ~GUSBCFG_PHYIF16; // 8 bit
#endif
} else {
gusbcfg &= ~GUSBCFG_PHYIF16; // 8 bit
}
@@ -145,12 +141,12 @@ static void phy_hs_init(dwc2_regs_t* dwc2) {
// - 9 if using 8-bit PHY interface
// - 5 if using 16-bit PHY interface
gusbcfg &= ~GUSBCFG_TRDT_Msk;
gusbcfg |= (dwc2->ghwcfg4_bm.phy_data_width ? 5u : 9u) << GUSBCFG_TRDT_Pos;
/* at32f402_405 does not actually support 16-bit */
#if CFG_TUSB_MCU == OPT_MCU_AT32F402_405
gusbcfg |= (dwc2->ghwcfg4_bm.phy_data_width ? 9u : 9u) << GUSBCFG_TRDT_Pos;
#endif
#if CFG_TUSB_MCU == OPT_MCU_AT32F402_405 // at32f402_405 does not actually support 16-bit
gusbcfg |= 9u << GUSBCFG_TRDT_Pos;
#else
gusbcfg |= (dwc2->ghwcfg4_bm.phy_data_width ? 5u : 9u) << GUSBCFG_TRDT_Pos;
#endif
dwc2->gusbcfg = gusbcfg;