From 2f0db41fb93ddd220bdf538c39953ac359d82de5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Hru=C5=A1ka?= Date: Wed, 27 Dec 2017 22:57:45 +0100 Subject: [PATCH] add usb re-plug functionality to F072 --- USB/usb_device.h | 1 + platform/platform.c | 10 ++++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/USB/usb_device.h b/USB/usb_device.h index 10791b7..a2aec03 100644 --- a/USB/usb_device.h +++ b/USB/usb_device.h @@ -58,6 +58,7 @@ #include "usbd_def.h" extern USBD_HandleTypeDef hUsbDeviceFS; +extern PCD_HandleTypeDef hpcd_USB_FS; /* USB_Device init function */ void MX_USB_DEVICE_Init(void); diff --git a/platform/platform.c b/platform/platform.c index 2ebd735..c2978aa 100644 --- a/platform/platform.c +++ b/platform/platform.c @@ -247,8 +247,14 @@ void plat_usb_reconnect(void) { // TODO add better reset methods available on different chips - // F103 doesn't have pull-up control, this is probably the best we can do - // This does not seem to trigger descriptors reload. USBD_LL_Reset(&hUsbDeviceFS); + +#if defined(GEX_PLAT_F072_DISCOVERY) + HAL_PCD_DevDisconnect(&hpcd_USB_FS); + osDelay(100); + HAL_PCD_DevConnect(&hpcd_USB_FS); +#else + // F103 doesn't have pull-up control +#endif }