diff --git a/src/machine/machine_rp2040_usb_fix_usb_device_enumeration.go b/src/machine/machine_rp2040_usb_fix_usb_device_enumeration.go index c67cfe1d..eedcc4d2 100644 --- a/src/machine/machine_rp2040_usb_fix_usb_device_enumeration.go +++ b/src/machine/machine_rp2040_usb_fix_usb_device_enumeration.go @@ -3,6 +3,7 @@ package machine import ( + "device/arm" "device/rp" ) @@ -87,6 +88,7 @@ func hw_enumeration_fix_force_ls_j() { rp.USBCTRL_REGS.USB_MUXING.Set(rp.USBCTRL_REGS_USB_MUXING_TO_DIGITAL_PAD | rp.USBCTRL_REGS_USB_MUXING_SOFTCON) // LS_J is now forced but while loop here just to check + waitCycles(125000) // if timer pool disabled, or no timer available, have to busy wait. hw_enumeration_fix_finish() @@ -109,3 +111,10 @@ func hw_enumeration_fix_finish() { // Restore the pad ctrl value padsBank0.io[dp].Set(padCtrlPrev) } + +func waitCycles(n int) { + for n > 0 { + arm.Asm("nop") + n-- + } +}