Skip to content

Commit 8c34b37

Browse files
matthijskooijmanfpistm
authored andcommitted
HACK: Do not use USB_DevDisconnect in early startup
This function calls HAL_Delay, which relies on the systick timer to be running, so this results in an infinite loop. This should probably be fixed in HAL_Delay, but for now just remove the calls to USB_DevDisconnect and USB_DevConnect and replace it with the bit twiddles needed for some chip families (e.g. the F4), breaking compilation and/or functionality for others.
1 parent d69a62c commit 8c34b37

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

cores/arduino/stm32/usb/usbd_if.c

+5-2
Original file line numberDiff line numberDiff line change
@@ -194,9 +194,12 @@ WEAK void USBD_reenumerate(void)
194194
digitalWriteFast(USBD_PULLUP_CONTROL_PINNAME, USBD_ATTACH_LEVEL);
195195
#endif /* defined(USBD_PULLUP_CONTROL_FLOATING) */
196196
#elif defined(USBD_HAVE_INTERNAL_PULLUPS)
197-
USB_DevDisconnect(USBD_USB_INSTANCE);
197+
uint32_t USBx_BASE = (uint32_t)USBD_USB_INSTANCE;
198+
USBx_DEVICE->DCTL |= USB_OTG_DCTL_SDIS;
199+
//USB_DevDisconnect(USBD_USB_INSTANCE);
198200
USBD_early_startup_delay_us(USBD_ENUM_DELAY * 1000);
199-
USB_DevConnect(USBD_USB_INSTANCE);
201+
//USB_DevConnect(USBD_USB_INSTANCE);
202+
USBx_DEVICE->DCTL &= ~USB_OTG_DCTL_SDIS;
200203
#else
201204
#warning "No USB attach/detach method, USB might not be reliable through system resets"
202205
#endif

0 commit comments

Comments
 (0)