|
20 | 20 |
|
21 | 21 | #include "USBPhyHw.h" |
22 | 22 | #include "pinmap.h" |
| 23 | +#if defined(TARGET_STM32L1) && defined(SYSCFG_PMC_USB_PU) |
| 24 | +#include "stm32l1xx_ll_system.h" |
| 25 | +#endif |
23 | 26 |
|
24 | 27 | /* endpoint conversion macros */ |
25 | 28 | #define EP_TO_LOG(ep) ((ep) & 0xF) |
@@ -189,15 +192,22 @@ USBPhyHw::~USBPhyHw() |
189 | 192 |
|
190 | 193 | } |
191 | 194 |
|
192 | | -#if defined(TARGET_STM32F1) |
| 195 | +#if defined(TARGET_STM32F1) || defined(SYSCFG_PMC_USB_PU) |
193 | 196 |
|
194 | 197 | #include "drivers/DigitalOut.h" |
195 | 198 |
|
196 | 199 | void USB_reenumerate() |
197 | 200 | { |
| 201 | +#if defined(SYSCFG_PMC_USB_PU) |
| 202 | + // Manage internal pullups manually |
| 203 | + LL_SYSCFG_DisableUSBPullUp(); |
| 204 | + wait_us(10000); // 10ms |
| 205 | + LL_SYSCFG_EnableUSBPullUp(); |
| 206 | +#else |
198 | 207 | // Force USB_DP pin (with external pull up) to 0 |
199 | 208 | mbed::DigitalOut usb_dp_pin(USB_DP, 0) ; |
200 | 209 | wait_us(10000); // 10ms |
| 210 | +#endif |
201 | 211 | } |
202 | 212 | #endif |
203 | 213 |
|
@@ -282,9 +292,10 @@ void USBPhyHw::init(USBPhyEvents *events) |
282 | 292 | hpcd.Init.speed = PCD_SPEED_FULL; |
283 | 293 |
|
284 | 294 | __HAL_RCC_USB_CLK_ENABLE(); |
| 295 | + |
285 | 296 | map = PinMap_USB_FS; |
286 | 297 |
|
287 | | -#if defined(TARGET_STM32F1) |
| 298 | +#if defined(TARGET_STM32F1) || defined(SYSCFG_PMC_USB_PU) |
288 | 299 | // USB_DevConnect is empty |
289 | 300 | USB_reenumerate(); |
290 | 301 | #endif |
@@ -407,7 +418,7 @@ void USBPhyHw::connect() |
407 | 418 | // Initializes the USB controller registers |
408 | 419 | USB_DevInit(hpcd.Instance, hpcd.Init); // hpcd.Init not used |
409 | 420 |
|
410 | | -#if defined(TARGET_STM32F1) |
| 421 | +#if defined(TARGET_STM32F1) || defined(SYSCFG_PMC_USB_PU) |
411 | 422 | // USB_DevConnect is empty |
412 | 423 | USB_reenumerate(); |
413 | 424 | #endif |
|
0 commit comments