From 31079d95ddbb0355a5393705104070857d91c0c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?King=20K=C3=A9vin?= Date: Fri, 27 Nov 2020 16:39:51 +0100 Subject: [PATCH] dfu: minor, improve disconnect --- lib/usb_dfu.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/usb_dfu.c b/lib/usb_dfu.c index c1bd6c6..2c324ca 100644 --- a/lib/usb_dfu.c +++ b/lib/usb_dfu.c @@ -136,7 +136,7 @@ static void usb_disconnect(void) gpio_set_output_options(GPIOA, GPIO_OTYPE_PP, GPIO_OSPEED_2MHZ, GPIO12); gpio_clear(GPIOA, GPIO12); // USB disconnected must be at least 10 ms long, at most 100 ms - for (volatile uint32_t i = 0; i < 0x8000; i++); + for (volatile uint32_t i = 0; i < 0x2000; i++); } /** disconnect USB and perform system reset @@ -361,7 +361,6 @@ void usb_dfu_setup(void) } rcc_periph_reset_pulse(RST_OTGFS); // reset USB peripheral - usb_disconnect(); // disconnect to force re-enumeration rcc_periph_clock_enable(RCC_GPIOA); // enable clock for GPIO used for USB gpio_mode_setup(GPIOA, GPIO_MODE_AF, GPIO_PUPD_NONE, GPIO11 | GPIO12); // set pin to alternate function gpio_set_af(GPIOA, GPIO_AF10, GPIO11 | GPIO12); // set alternate function to USB