|
9 | 9 |
|
10 | 10 | #include "usbd_if.h"
|
11 | 11 | #include "usbd_cdc_if.h"
|
| 12 | +#include "stm32yyxx_ll_system.h" |
12 | 13 |
|
13 | 14 | #if !defined(USBD_REENUM_DISABLED)
|
14 | 15 |
|
|
73 | 74 | #endif /* (defined(USBD_DETACH_PIN) || defined(USBD_ATTACH_PIN)) && defined(USBD_FIXED_PULLUP) */
|
74 | 75 |
|
75 | 76 | /* Either of these bits indicate that there are internal pullups */
|
76 |
| -#if defined(USB_BCDR_DPPU) || defined(USB_OTG_DCTL_SDIS) |
| 77 | +#if defined(USB_BCDR_DPPU) || defined(USB_OTG_DCTL_SDIS) || defined(SYSCFG_PMC_USB_PU) |
77 | 78 | #define USBD_HAVE_INTERNAL_PULLUPS
|
78 | 79 | #endif /* defined(USB_BCDR_DPPU) || defined(USB_OTG_DCTL_SDIS) */
|
79 | 80 |
|
@@ -144,9 +145,22 @@ WEAK void USBD_reenumerate(void)
|
144 | 145 | digitalWriteFast(USBD_PULLUP_CONTROL_PINNAME, USBD_ATTACH_LEVEL);
|
145 | 146 | #endif /* defined(USBD_PULLUP_CONTROL_FLOATING) */
|
146 | 147 | #elif defined(USBD_HAVE_INTERNAL_PULLUPS)
|
| 148 | +#if defined(SYSCFG_PMC_USB_PU) |
| 149 | + /** |
| 150 | + * STM32L1xx USB_DevDisconnect() and USB_DevConnect() |
| 151 | + * do not manage the internal pull-up, so manage |
| 152 | + * internal pull-up manually. |
| 153 | + */ |
| 154 | + __HAL_RCC_SYSCFG_CLK_ENABLE(); |
| 155 | + LL_SYSCFG_DisableUSBPullUp(); |
| 156 | + delay(USBD_ENUM_DELAY); |
| 157 | + LL_SYSCFG_EnableUSBPullUp(); |
| 158 | + |
| 159 | +#else |
147 | 160 | USB_DevDisconnect(USBD_USB_INSTANCE);
|
148 | 161 | delay(USBD_ENUM_DELAY);
|
149 | 162 | USB_DevConnect(USBD_USB_INSTANCE);
|
| 163 | +#endif |
150 | 164 | #else
|
151 | 165 | #warning "No USB attach/detach method, USB might not be reliable through system resets"
|
152 | 166 | #endif
|
|
0 commit comments