dfu: minor, improve disconnect

This commit is contained in:
King Kévin 2020-11-27 16:39:51 +01:00
parent ced714129c
commit 31079d95dd
1 changed files with 1 additions and 2 deletions

View File

@ -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