Skip to content

Commit 0459bb3

Browse files
busy_wait_at_least_cycles(32);
1 parent 7ef4119 commit 0459bb3

File tree

2 files changed

+6
-7
lines changed

2 files changed

+6
-7
lines changed

src/portable/raspberrypi/rp2040/hcd_rp2040.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,6 @@ enum {
8383
EPX_CTRL_DEFAULT = EP_CTRL_ENABLE_BITS | EP_CTRL_INTERRUPT_PER_BUFFER | offsetof(usb_host_dpram_t, epx_data)
8484
};
8585

86-
//--------------------------------------------------------------------+
8786
//--------------------------------------------------------------------+
8887
//
8988
//--------------------------------------------------------------------+
@@ -179,10 +178,10 @@ static void __tusb_irq_path_func(sie_start_xfer)(bool send_setup, bool is_rx, bo
179178
}
180179

181180
// START_TRANS bit on SIE_CTRL has the same behavior as the AVAILABLE bit
182-
// described in RP2040 Datasheet, release 2.1, section "4.1.2.5.1. Concurrent access".
181+
// described in RP2040 Datasheet, release 2.1, section "4.1.2.5.1. Concurrent access".!
183182
// We write everything except the START_TRANS bit first, then wait some cycles.
184183
usb_hw->sie_ctrl = sie_ctrl;
185-
busy_wait_us(1);
184+
busy_wait_at_least_cycles(32);
186185
usb_hw->sie_ctrl = sie_ctrl | USB_SIE_CTRL_START_TRANS_BITS;
187186
}
188187

@@ -232,7 +231,7 @@ static void __tusb_irq_path_func(epx_save_context)(hw_endpoint_t *ep) {
232231
static void __tusb_irq_path_func(epx_switch_ep)(hw_endpoint_t *ep) {
233232
const bool is_setup = (ep->state == EPSTATE_PENDING_SETUP);
234233

235-
epx = ep; // switch pointer
234+
epx = ep; // switch pointer
236235
ep->state = EPSTATE_ACTIVE;
237236

238237
if (is_setup) {
@@ -350,7 +349,7 @@ static void __tusb_irq_path_func(hcd_rp2040_irq)(void) {
350349
if (status & USB_INTS_HOST_CONN_DIS_BITS) {
351350
// Clear speed latch first; after settle the re-read reflects the true current state.
352351
usb_hw_clear->sie_status = USB_SIE_STATUS_SPEED_BITS;
353-
busy_wait_us(1);
352+
busy_wait_at_least_cycles(32);
354353
const uint8_t speed = dev_speed();
355354
if (speed == SIE_CTRL_SPEED_DISCONNECT) {
356355
// Stop SIE and silence hardware before emitting remove. Concurrent

src/portable/raspberrypi/rp2040/rp2040_usb.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ void __tusb_irq_path_func(bufctrl_write32)(io_rw_32 *buf_reg, uint32_t value) {
127127
// Don't need delay in host mode as host is in charge of when to start the transaction.
128128
if (value & (USB_BUF_CTRL_AVAIL | (USB_BUF_CTRL_AVAIL << 16))) {
129129
if (!rp2usb_is_host_mode()) {
130-
busy_wait_us(1);
130+
busy_wait_at_least_cycles(32);
131131
}
132132
*buf_reg = value; // then set AVAILABLE bit last
133133
}
@@ -143,7 +143,7 @@ void __tusb_irq_path_func(bufctrl_write16)(io_rw_16 *buf_reg16, uint16_t value)
143143
// Section 4.1.2.7.1 (rp2040) / 12.7.3.7.1 (rp2350) Concurrent access
144144
if (value & USB_BUF_CTRL_AVAIL) {
145145
if (!rp2usb_is_host_mode()) {
146-
busy_wait_us(1);
146+
busy_wait_at_least_cycles(32);
147147
}
148148
*buf_reg16 = value; // then set AVAILABLE bit last
149149
}

0 commit comments

Comments
 (0)