diff options
| author | Ha Thach <[email protected]> | 2025-09-27 20:38:03 +0700 |
|---|---|---|
| committer | GitHub <[email protected]> | 2025-09-27 20:38:03 +0700 |
| commit | 152d25ed621393a991561b7de61c2f01bbadeb71 (patch) | |
| tree | 7a75a0a3da032421907e26616f67f7f1d55b2d09 /src/portable | |
| parent | 1f9c41566165b23ff573bf1b9bfd077cfbe9067f (diff) | |
| parent | 0655f98359de7e9299d8047d94a1087bdd3618ac (diff) | |
Merge pull request #3256 from hathach/weak_cb
Migrate weak function override to new syntax, update delay api usage
Diffstat (limited to 'src/portable')
| -rw-r--r-- | src/portable/microchip/pic32mz/dcd_pic32mz.c | 8 | ||||
| -rw-r--r-- | src/portable/ohci/ohci.c | 18 | ||||
| -rw-r--r-- | src/portable/renesas/rusb2/rusb2_common.c | 4 | ||||
| -rw-r--r-- | src/portable/sunxi/dcd_sunxi_musb.c | 12 | ||||
| -rw-r--r-- | src/portable/ti/msp430x5xx/dcd_msp430x5xx.c | 18 |
5 files changed, 8 insertions, 52 deletions
diff --git a/src/portable/microchip/pic32mz/dcd_pic32mz.c b/src/portable/microchip/pic32mz/dcd_pic32mz.c index 8709baf67..cbd157d6b 100644 --- a/src/portable/microchip/pic32mz/dcd_pic32mz.c +++ b/src/portable/microchip/pic32mz/dcd_pic32mz.c @@ -162,13 +162,7 @@ void dcd_remote_wakeup(uint8_t rhport) (void) rhport; USB_REGS->POWERbits.RESUME = 1; -#if CFG_TUSB_OS != OPT_OS_NONE - osal_task_delay(10); -#else - // TODO: Wait in non blocking mode - unsigned cnt = 2000; - while (cnt--) __asm__("nop"); -#endif + tusb_time_delay_ms_api(10); USB_REGS->POWERbits.RESUME = 0; } diff --git a/src/portable/ohci/ohci.c b/src/portable/ohci/ohci.c index 81091c9a7..f1689b5b4 100644 --- a/src/portable/ohci/ohci.c +++ b/src/portable/ohci/ohci.c @@ -168,14 +168,12 @@ static gtd_extra_data_t *gtd_get_extra_data(ohci_gtd_t const * const gtd); // tusb_app_virt_to_phys and tusb_app_virt_to_phys in your application. TU_ATTR_ALWAYS_INLINE static inline void *_phys_addr(void *virtual_address) { - if (tusb_app_virt_to_phys) return tusb_app_virt_to_phys(virtual_address); - return virtual_address; + return tusb_app_virt_to_phys(virtual_address); } TU_ATTR_ALWAYS_INLINE static inline void *_virt_addr(void *physical_address) { - if (tusb_app_phys_to_virt) return tusb_app_phys_to_virt(physical_address); - return physical_address; + return tusb_app_phys_to_virt(physical_address); } // Initialization according to 5.1.1.4 @@ -208,12 +206,7 @@ bool hcd_init(uint8_t rhport, const tusb_rhport_init_t* rh_init) { //Wait 20 ms. (Ref Usb spec 7.1.7.7) OHCI_REG->control_bit.hc_functional_state = OHCI_CONTROL_FUNCSTATE_RESUME; -#if CFG_TUSB_OS != OPT_OS_NONE - // os_none implement task delay using usb frame counter which is not started yet - // therefore cause infinite delay. - // TODO find a way to delay in case of os none e.g __nop - osal_task_delay(20); -#endif + tusb_time_delay_ms_api(20); } // reset controller @@ -241,10 +234,7 @@ bool hcd_init(uint8_t rhport, const tusb_rhport_init_t* rh_init) { OHCI_REG->control_bit.hc_functional_state = OHCI_CONTROL_FUNCSTATE_OPERATIONAL; // make HC's state to operational state TODO use this to suspend (save power) OHCI_REG->rh_status_bit.local_power_status_change = 1; // set global power for ports -#if CFG_TUSB_OS != OPT_OS_NONE - // TODO as above delay - osal_task_delay(OHCI_REG->rh_descriptorA_bit.power_on_to_good_time * 2); // Wait POTG after power up -#endif + tusb_time_delay_ms_api(OHCI_REG->rh_descriptorA_bit.power_on_to_good_time * 2); // Wait POTG after power up return true; } diff --git a/src/portable/renesas/rusb2/rusb2_common.c b/src/portable/renesas/rusb2/rusb2_common.c index 72e65736b..856f9714f 100644 --- a/src/portable/renesas/rusb2/rusb2_common.c +++ b/src/portable/renesas/rusb2/rusb2_common.c @@ -50,10 +50,6 @@ void tusb_rusb2_set_irqnum(uint8_t rhport, int32_t irqnum) { rusb2_controller[rhport].irqnum = irqnum; } -// void osal_task_delay(uint32_t msec) { -// R_BSP_SoftwareDelay(msec, BSP_DELAY_UNITS_MILLISECONDS); -// } - #else #error "Unsupported MCU" #endif diff --git a/src/portable/sunxi/dcd_sunxi_musb.c b/src/portable/sunxi/dcd_sunxi_musb.c index 21f13b279..9801a485f 100644 --- a/src/portable/sunxi/dcd_sunxi_musb.c +++ b/src/portable/sunxi/dcd_sunxi_musb.c @@ -99,22 +99,12 @@ static void usb_phy_write(int addr, int data, int len) } } -static void delay_ms(uint32_t ms) -{ -#if CFG_TUSB_OS == OPT_OS_NONE - int now = board_millis(); - while (board_millis() - now <= ms) asm("nop"); -#else - osal_task_delay(ms); -#endif -} - static void USBC_HardwareReset(void) { // Reset phy and controller USBC_REG_set_bit_l(USBPHY_CLK_RST_BIT, USBPHY_CLK_REG); USBC_REG_set_bit_l(BUS_RST_USB_BIT, BUS_CLK_RST_REG); - delay_ms(2); + tusb_time_delay_ms_api(2); USBC_REG_set_bit_l(USBPHY_CLK_GAT_BIT, USBPHY_CLK_REG); USBC_REG_set_bit_l(USBPHY_CLK_RST_BIT, USBPHY_CLK_REG); diff --git a/src/portable/ti/msp430x5xx/dcd_msp430x5xx.c b/src/portable/ti/msp430x5xx/dcd_msp430x5xx.c index 3752ae251..64cbc5087 100644 --- a/src/portable/ti/msp430x5xx/dcd_msp430x5xx.c +++ b/src/portable/ti/msp430x5xx/dcd_msp430x5xx.c @@ -662,24 +662,10 @@ static void handle_setup_packet(void) dcd_event_setup_received(0, (uint8_t*) &_setup_packet[0], true); } -#if CFG_TUSB_OS == OPT_OS_NONE -TU_ATTR_ALWAYS_INLINE static inline void tu_delay(uint32_t ms) { - // msp430 can run up to 25Mhz -> 40ns per cycle. 1 ms = 25000 cycles - // each loop need 4 cycle: 1 sub, 1 cmp, 1 jump, 1 nop - volatile uint32_t cycles = (25000 * ms) >> 2; - while (cycles > 0) { - cycles--; - asm("nop"); - } -} -#else -#define tu_delay(ms) osal_task_delay(ms) -#endif - static void handle_bus_power_event(void *param) { (void) param; - tu_delay(5); // Bus power settling delay. + tusb_time_delay_ms_api(5); // Bus power settling delay. USBKEYPID = USBKEY; @@ -694,7 +680,7 @@ static void handle_bus_power_event(void *param) { uint16_t attempts = 0; do { // Poll the PLL, checking for a successful lock. USBPLLIR = 0; - tu_delay(1); + tusb_time_delay_ms_api(1); attempts++; } while ((attempts < 10) && (USBPLLIR != 0)); |
