aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authordeadprogram <[email protected]>2023-07-04 21:44:20 +0200
committerRon Evans <[email protected]>2023-07-07 22:13:26 +0200
commitc83f712c17b6024d2cc3130db1d7bb0899e7b419 (patch)
tree1752868254210e91b44db3531eb5d462bb4fa5d2
parentfffad84a63488d2ffd6d143229412dc0913d5458 (diff)
downloadtinygo-c83f712c17b6024d2cc3130db1d7bb0899e7b419.tar.gz
tinygo-c83f712c17b6024d2cc3130db1d7bb0899e7b419.zip
machine/rp2040: wait for 1000 us after flash reset to avoid issues with busy USB bus
Signed-off-by: deadprogram <[email protected]>
-rw-r--r--src/machine/machine_rp2040_usb_fix_usb_device_enumeration.go9
1 files changed, 9 insertions, 0 deletions
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 c67cfe1d3..eedcc4d21 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--
+ }
+}