Skip to content

Commit c83f712

Browse files
committed
machine/rp2040: wait for 1000 us after flash reset to avoid issues with busy USB bus
Signed-off-by: deadprogram <[email protected]>
1 parent fffad84 commit c83f712

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/machine/machine_rp2040_usb_fix_usb_device_enumeration.go

+9
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
package machine
44

55
import (
6+
"device/arm"
67
"device/rp"
78
)
89

@@ -87,6 +88,7 @@ func hw_enumeration_fix_force_ls_j() {
8788
rp.USBCTRL_REGS.USB_MUXING.Set(rp.USBCTRL_REGS_USB_MUXING_TO_DIGITAL_PAD | rp.USBCTRL_REGS_USB_MUXING_SOFTCON)
8889

8990
// LS_J is now forced but while loop here just to check
91+
waitCycles(125000)
9092

9193
// if timer pool disabled, or no timer available, have to busy wait.
9294
hw_enumeration_fix_finish()
@@ -109,3 +111,10 @@ func hw_enumeration_fix_finish() {
109111
// Restore the pad ctrl value
110112
padsBank0.io[dp].Set(padCtrlPrev)
111113
}
114+
115+
func waitCycles(n int) {
116+
for n > 0 {
117+
arm.Asm("nop")
118+
n--
119+
}
120+
}

0 commit comments

Comments
 (0)