Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion cores/arduino/stm32/usb/usbd_if.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

#include "usbd_if.h"
#include "usbd_cdc_if.h"
#include "stm32yyxx_ll_system.h"

#if !defined(USBD_REENUM_DISABLED)

Expand Down Expand Up @@ -73,7 +74,7 @@
#endif /* (defined(USBD_DETACH_PIN) || defined(USBD_ATTACH_PIN)) && defined(USBD_FIXED_PULLUP) */

/* Either of these bits indicate that there are internal pullups */
#if defined(USB_BCDR_DPPU) || defined(USB_OTG_DCTL_SDIS)
#if defined(USB_BCDR_DPPU) || defined(USB_OTG_DCTL_SDIS) || defined(SYSCFG_PMC_USB_PU)
#define USBD_HAVE_INTERNAL_PULLUPS
#endif /* defined(USB_BCDR_DPPU) || defined(USB_OTG_DCTL_SDIS) */

Expand Down Expand Up @@ -144,9 +145,22 @@ 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)
#if defined(SYSCFG_PMC_USB_PU)
/**
* STM32L1xx USB_DevDisconnect() and USB_DevConnect()
* do not manage the internal pull-up, so manage
* internal pull-up manually.
*/
__HAL_RCC_SYSCFG_CLK_ENABLE();
LL_SYSCFG_DisableUSBPullUp();
delay(USBD_ENUM_DELAY);
LL_SYSCFG_EnableUSBPullUp();

#else
USB_DevDisconnect(USBD_USB_INSTANCE);
delay(USBD_ENUM_DELAY);
USB_DevConnect(USBD_USB_INSTANCE);
#endif
#else
#warning "No USB attach/detach method, USB might not be reliable through system resets"
#endif
Expand Down