Skip to content

Commit f096704

Browse files
committed
STM32 USB FS: force enumeration
1 parent 6dd3e05 commit f096704

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

targets/TARGET_STM/USBPhy_STM32.cpp

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,14 @@ USBPhyHw::~USBPhyHw()
173173

174174
}
175175

176+
void USB_reenumerate()
177+
{
178+
DigitalInOut usb_disc_pin(USB_DP, PIN_OUTPUT, PullNone, 0);
179+
wait_us(10000);
180+
usb_disc_pin.input();
181+
}
182+
183+
176184
void USBPhyHw::init(USBPhyEvents *events)
177185
{
178186
const PinMap *map = NULL;
@@ -225,6 +233,8 @@ void USBPhyHw::init(USBPhyEvents *events)
225233

226234
__HAL_RCC_USB_CLK_ENABLE();
227235
map = PinMap_USB_FS;
236+
237+
USB_reenumerate();
228238
#endif
229239

230240
// Pass instance for usage inside call back
@@ -334,9 +344,7 @@ bool USBPhyHw::powered()
334344
void USBPhyHw::connect()
335345
{
336346
#if (MBED_CONF_TARGET_USB_SPEED == USE_USB_NO_OTG)
337-
DigitalOut usb_disc_pin(USB_DP, 1) ;
338-
wait_ns(1000);
339-
usb_disc_pin = 0;
347+
USB_reenumerate();
340348

341349
uint32_t wInterrupt_Mask = USB_CNTR_CTRM | USB_CNTR_WKUPM | USB_CNTR_SUSPM | USB_CNTR_ERRM |
342350
USB_CNTR_SOFM | USB_CNTR_ESOFM | USB_CNTR_RESETM;

0 commit comments

Comments
 (0)