| 
64 | 64 | #endif  | 
65 | 65 | 
 
  | 
66 | 66 | #ifdef __cplusplus  | 
67 |  | - extern "C" {  | 
 | 67 | +extern "C" {  | 
68 | 68 | #endif  | 
69 | 69 | 
 
  | 
70 |  | - static const dwc2_controller_t _dwc2_controller[] = {  | 
71 |  | -{.reg_base = DWC2_OTG1_REG_BASE, .irqnum = OTG1_IRQn, .ep_count = DWC2_EP_MAX, .ep_fifo_size = OTG1_FIFO_SIZE},  | 
 | 70 | +static const dwc2_controller_t _dwc2_controller[] = {  | 
 | 71 | +    {.reg_base = DWC2_OTG1_REG_BASE, .irqnum = OTG1_IRQn, .ep_count = DWC2_EP_MAX, .ep_fifo_size = OTG1_FIFO_SIZE},  | 
72 | 72 | #if defined DWC2_OTG2_REG_BASE  | 
73 |  | -  {.reg_base = DWC2_OTG2_REG_BASE, .irqnum = OTG2_IRQn, .ep_count = DWC2_EP_MAX, .ep_fifo_size = OTG2_FIFO_SIZE}  | 
 | 73 | +    {.reg_base = DWC2_OTG2_REG_BASE, .irqnum = OTG2_IRQn, .ep_count = DWC2_EP_MAX, .ep_fifo_size = OTG2_FIFO_SIZE}  | 
74 | 74 | #endif  | 
75 |  | - };  | 
 | 75 | +};  | 
76 | 76 | 
 
  | 
77 |  | - TU_ATTR_ALWAYS_INLINE static inline void dwc2_int_set(uint8_t rhport, tusb_role_t role, bool enabled) {  | 
78 |  | -   (void) role;  | 
79 |  | -   const IRQn_Type irqn = (IRQn_Type) _dwc2_controller[rhport].irqnum;  | 
80 |  | -   if (enabled) {  | 
81 |  | -     NVIC_EnableIRQ(irqn);  | 
82 |  | -   } else {  | 
83 |  | -     NVIC_DisableIRQ(irqn);  | 
84 |  | -   }  | 
85 |  | - }  | 
 | 77 | +TU_ATTR_ALWAYS_INLINE static inline void dwc2_int_set(uint8_t rhport, tusb_role_t role, bool enabled) {  | 
 | 78 | +  (void) role;  | 
 | 79 | +  const IRQn_Type irqn = (IRQn_Type) _dwc2_controller[rhport].irqnum;  | 
 | 80 | +  if (enabled) {  | 
 | 81 | +    NVIC_EnableIRQ(irqn);  | 
 | 82 | +  } else {  | 
 | 83 | +    NVIC_DisableIRQ(irqn);  | 
 | 84 | +  }  | 
 | 85 | +}  | 
86 | 86 | 
 
  | 
87 |  | - TU_ATTR_ALWAYS_INLINE static inline void dwc2_dcd_int_enable(uint8_t rhport) { NVIC_EnableIRQ(_dwc2_controller[rhport].irqnum);  | 
88 |  | - }  | 
 | 87 | +TU_ATTR_ALWAYS_INLINE static inline void dwc2_dcd_int_enable(uint8_t rhport) {  | 
 | 88 | +  NVIC_EnableIRQ(_dwc2_controller[rhport].irqnum);  | 
 | 89 | +}  | 
89 | 90 | 
 
  | 
90 |  | - TU_ATTR_ALWAYS_INLINE static inline void dwc2_dcd_int_disable(uint8_t rhport) {  | 
91 |  | -   NVIC_DisableIRQ(_dwc2_controller[rhport].irqnum);  | 
92 |  | - }  | 
 | 91 | +TU_ATTR_ALWAYS_INLINE static inline void dwc2_dcd_int_disable(uint8_t rhport) {  | 
 | 92 | +  NVIC_DisableIRQ(_dwc2_controller[rhport].irqnum);  | 
 | 93 | +}  | 
93 | 94 | 
 
  | 
94 |  | - TU_ATTR_ALWAYS_INLINE static inline void dwc2_remote_wakeup_delay(void) {  | 
95 |  | -   // try to delay for 1 ms  | 
96 |  | -   uint32_t count = system_core_clock / 1000;  | 
97 |  | -   while (count--) __asm volatile("nop");  | 
98 |  | - }  | 
 | 95 | +TU_ATTR_ALWAYS_INLINE static inline void dwc2_remote_wakeup_delay(void) {  | 
 | 96 | +  // try to delay for 1 ms  | 
 | 97 | +  uint32_t count = system_core_clock / 1000;  | 
 | 98 | +  while (count--) __asm volatile("nop");  | 
 | 99 | +}  | 
99 | 100 | 
 
  | 
100 |  | - // MCU specific PHY init, called BEFORE core reset  | 
101 |  | - TU_ATTR_ALWAYS_INLINE static inline void dwc2_phy_init(dwc2_regs_t *dwc2, uint8_t hs_phy_type) {  | 
102 |  | -   (void) dwc2;  | 
103 |  | -   // Enable on-chip HS PHY  | 
104 |  | -   if (hs_phy_type == GHWCFG2_HSPHY_UTMI || hs_phy_type == GHWCFG2_HSPHY_UTMI_ULPI) {  | 
105 |  | -   } else if (hs_phy_type == GHWCFG2_HSPHY_NOT_SUPPORTED) {  | 
106 |  | -   }  | 
107 |  | - }  | 
 | 101 | +// MCU specific PHY init, called BEFORE core reset  | 
 | 102 | +TU_ATTR_ALWAYS_INLINE static inline void dwc2_phy_init(dwc2_regs_t *dwc2, uint8_t hs_phy_type) {  | 
 | 103 | +  (void) dwc2;  | 
 | 104 | +  // Enable on-chip HS PHY  | 
 | 105 | +  if (hs_phy_type == GHWCFG2_HSPHY_UTMI || hs_phy_type == GHWCFG2_HSPHY_UTMI_ULPI) {  | 
 | 106 | +  } else if (hs_phy_type == GHWCFG2_HSPHY_NOT_SUPPORTED) {  | 
 | 107 | +  }  | 
 | 108 | +}  | 
108 | 109 | 
 
  | 
109 |  | - // MCU specific PHY update, it is called AFTER init() and core reset  | 
110 |  | - TU_ATTR_ALWAYS_INLINE static inline void dwc2_phy_update(dwc2_regs_t *dwc2, uint8_t hs_phy_type) {  | 
111 |  | -   (void) dwc2;  | 
112 |  | -   (void) hs_phy_type;  | 
 | 110 | +// MCU specific PHY update, it is called AFTER init() and core reset  | 
 | 111 | +TU_ATTR_ALWAYS_INLINE static inline void dwc2_phy_update(dwc2_regs_t *dwc2, uint8_t hs_phy_type) {  | 
 | 112 | +  (void) dwc2;  | 
 | 113 | +  (void) hs_phy_type;  | 
113 | 114 | 
 
  | 
114 |  | -   dwc2->stm32_gccfg |= STM32_GCCFG_PWRDWN | STM32_GCCFG_DCDEN | STM32_GCCFG_PDEN;  | 
115 |  | - }  | 
 | 115 | +  dwc2->stm32_gccfg |= STM32_GCCFG_PWRDWN | STM32_GCCFG_DCDEN | STM32_GCCFG_PDEN;  | 
 | 116 | +}  | 
116 | 117 | 
 
  | 
117 | 118 | #ifdef __cplusplus  | 
118 | 119 | }  | 
119 | 120 | #endif  | 
120 | 121 | 
 
  | 
121 |  | -#endif /* DWC2_GD32_H_ */  | 
 | 122 | +#endif /* DWC2_AT32_H_ */  | 
0 commit comments