From 2f148bfb69959df6e996a509b510a019a64a7d85 Mon Sep 17 00:00:00 2001 From: Matthijs Kooijman Date: Wed, 16 Sep 2020 10:27:19 +0200 Subject: [PATCH] HACK: Extend HACK to boards with DPPU-based pullup control (e.g. F0) --- cores/arduino/stm32/usb/usbd_if.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/cores/arduino/stm32/usb/usbd_if.c b/cores/arduino/stm32/usb/usbd_if.c index 08f920c616..8a8c60301a 100644 --- a/cores/arduino/stm32/usb/usbd_if.c +++ b/cores/arduino/stm32/usb/usbd_if.c @@ -194,12 +194,18 @@ WEAK void USBD_reenumerate(void) digitalWriteFast(USBD_PULLUP_CONTROL_PINNAME, USBD_ATTACH_LEVEL); #endif /* defined(USBD_PULLUP_CONTROL_FLOATING) */ #elif defined(USBD_HAVE_INTERNAL_PULLUPS) +#ifdef USB_OTG_DCTL_SDIS uint32_t USBx_BASE = (uint32_t)USBD_USB_INSTANCE; USBx_DEVICE->DCTL |= USB_OTG_DCTL_SDIS; //USB_DevDisconnect(USBD_USB_INSTANCE); USBD_early_startup_delay_us(USBD_ENUM_DELAY * 1000); //USB_DevConnect(USBD_USB_INSTANCE); USBx_DEVICE->DCTL &= ~USB_OTG_DCTL_SDIS; +#else + USBD_USB_INSTANCE->BCDR &= (uint16_t)(~(USB_BCDR_DPPU)); + USBD_early_startup_delay_us(USBD_ENUM_DELAY * 1000); + USBD_USB_INSTANCE->BCDR |= (uint16_t)(USB_BCDR_DPPU); +#endif #else #warning "No USB attach/detach method, USB might not be reliable through system resets" #endif