summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/portable/analog/max3421/hcd_max3421.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/portable/analog/max3421/hcd_max3421.c b/src/portable/analog/max3421/hcd_max3421.c
index 971dbd62e..621d0d86c 100644
--- a/src/portable/analog/max3421/hcd_max3421.c
+++ b/src/portable/analog/max3421/hcd_max3421.c
@@ -504,8 +504,15 @@ bool hcd_init(uint8_t rhport, const tusb_rhport_init_t* rh_init) {
// reset
reg_write(rhport, USBCTL_ADDR, USBCTL_CHIPRES, false);
reg_write(rhport, USBCTL_ADDR, 0, false);
+ // Bound the oscillator-OK wait. On boards where the MAX3421E is only
+ // soft-reset (CHIPRES) rather than hardware-reset via nRST, OSCOK may never
+ // latch, which would otherwise hang the host forever (adafruit/circuitpython#10053).
+ // The oscillator is generally running regardless, so proceed after a timeout.
+ uint32_t oscok_retries = 200000;
while( !(reg_read(rhport, USBIRQ_ADDR, false) & USBIRQ_OSCOK_IRQ) ) {
- // wait for oscillator to stabilize
+ if (--oscok_retries == 0) {
+ break;
+ }
}
// Mode: Host and DP/DM pull down