From ff3d84922df22dc4cfaa373c48b3b00ad9f672b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Redon?= Date: Mon, 6 Aug 2018 17:57:20 +0200 Subject: USB: increase USB reset time USB reset can be signaled by pulling low USB D+ for at least 10 ms, according to the USB specification. This force a re-enumeration. This time is increased to 20 ms to work with more USB HUBs. Some SAM3S based board have external D+ pull-up mechanism (such as SIMtrace) which needs to be used to pull D+ low. This is a legacy mechanism from SAM7S history. This mechanism is not required anymore on the SAM3S, and the qmod does not use it. When the USB HAL is suspended, the transceiver is disabled, causing D+ and D- to be pulled low. Then the HAL is activated again. This is particularly required when DFU is started (and enumerated), and after flashing the SAM3S switched to the main application (without reset), so it can properly re-enumerate. This board difference is now defined on the board header. Change-Id: I9b58d8101c2fcf5595026b675728826af26127a3 --- firmware/apps/dfu/main.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'firmware/apps') diff --git a/firmware/apps/dfu/main.c b/firmware/apps/dfu/main.c index 74268ad..7f8fbfc 100644 --- a/firmware/apps/dfu/main.c +++ b/firmware/apps/dfu/main.c @@ -22,6 +22,7 @@ #include "usb/device/dfu/dfu.h" #include "usb/common/dfu/usb_dfu.h" #include "manifest.h" +#include "USBD_HAL.h" #include @@ -294,11 +295,18 @@ extern int main(void) TRACE_INFO("USB init...\n\r"); /* Signal USB reset by disabling the pull-up on USB D+ for at least 10 ms */ +#ifdef PIN_USB_PULLUP const Pin usb_dp_pullup = PIN_USB_PULLUP; PIO_Configure(&usb_dp_pullup, 1); PIO_Set(&usb_dp_pullup); - mdelay(15); +#endif + USBD_HAL_Suspend(); + mdelay(20); +#ifdef PIN_USB_PULLUP PIO_Clear(&usb_dp_pullup); +#endif + USBD_HAL_Activate(); + USBDFU_Initialize(&dfu_descriptors); while (USBD_GetState() < USBD_STATE_CONFIGURED) { -- cgit v1.2.3