summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorHiFiPhile <[email protected]>2025-09-17 22:45:25 +0200
committerHiFiPhile <[email protected]>2025-09-17 22:48:59 +0200
commit73f3900b2da5d00e707078a591067f0329118dcb (patch)
tree1cfcfed3b7b33cf90dc8c942a47af970fa94d4c0 /src
parent369a1ff5153a472327d2847c7bc7386309486b34 (diff)
Replace old delay functions by tusb_time_delay_ms_api
Signed-off-by: HiFiPhile <[email protected]>
Diffstat (limited to 'src')
-rw-r--r--src/class/cdc/cdc_rndis_host.c2
-rw-r--r--src/osal/osal_none.h9
-rw-r--r--src/portable/microchip/pic32mz/dcd_pic32mz.c8
-rw-r--r--src/portable/ohci/ohci.c12
-rw-r--r--src/portable/renesas/rusb2/rusb2_common.c4
-rw-r--r--src/portable/sunxi/dcd_sunxi_musb.c12
-rw-r--r--src/portable/ti/msp430x5xx/dcd_msp430x5xx.c18
7 files changed, 7 insertions, 58 deletions
diff --git a/src/class/cdc/cdc_rndis_host.c b/src/class/cdc/cdc_rndis_host.c
index 11a5355aa..e975ea440 100644
--- a/src/class/cdc/cdc_rndis_host.c
+++ b/src/class/cdc/cdc_rndis_host.c
@@ -103,7 +103,7 @@ static tusb_error_t rndis_body_subtask(void)
}
- osal_task_delay(100);
+ tusb_time_delay_ms_api(100);
OSAL_SUBTASK_END
}
diff --git a/src/osal/osal_none.h b/src/osal/osal_none.h
index a8eb1042b..3e397ef35 100644
--- a/src/osal/osal_none.h
+++ b/src/osal/osal_none.h
@@ -32,15 +32,6 @@ extern "C" {
#endif
//--------------------------------------------------------------------+
-// TASK API
-//--------------------------------------------------------------------+
-
-#if CFG_TUH_ENABLED
-// currently only needed/available in host mode
-TU_ATTR_WEAK void osal_task_delay(uint32_t msec);
-#endif
-
-//--------------------------------------------------------------------+
// Spinlock API
//--------------------------------------------------------------------+
typedef struct {
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..f517e044e 100644
--- a/src/portable/ohci/ohci.c
+++ b/src/portable/ohci/ohci.c
@@ -208,12 +208,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 +236,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));