USB: fix disconnect
This commit is contained in:
parent
3242c6ba5c
commit
c7d0244f72
|
@ -262,13 +262,16 @@ static void usb_disconnect(void)
|
|||
// enable USB D+ pull-up
|
||||
rcc_periph_clock_enable(RCC_GPIOB);
|
||||
gpio_set_mode(GPIOB, GPIO_MODE_OUTPUT_2_MHZ, GPIO_CNF_OUTPUT_PUSHPULL, GPIO6);
|
||||
gpio_set(GPIOB, GPIO6);
|
||||
gpio_clear(GPIOB, GPIO6);
|
||||
#endif
|
||||
// pull USB D+ low for a short while
|
||||
rcc_periph_clock_enable(RCC_GPIOA);
|
||||
gpio_set_mode(GPIOA, GPIO_MODE_OUTPUT_2_MHZ, GPIO_CNF_OUTPUT_PUSHPULL, GPIO12);
|
||||
gpio_clear(GPIOA, GPIO12);
|
||||
sleep_ms(50); // USB disconnected must be at least 10 ms long, at most 100 ms
|
||||
// USB disconnected must be at least 10 ms long, at most 100 ms
|
||||
for (uint32_t i = 0; i < 0x2000; i++) {
|
||||
__asm__("nop");
|
||||
}
|
||||
}
|
||||
|
||||
/** DFU detach (disconnect USB and perform core reset)
|
||||
|
|
|
@ -143,13 +143,16 @@ static void usb_disconnect(void)
|
|||
// enable USB D+ pull-up
|
||||
rcc_periph_clock_enable(RCC_GPIOB);
|
||||
gpio_set_mode(GPIOB, GPIO_MODE_OUTPUT_2_MHZ, GPIO_CNF_OUTPUT_PUSHPULL, GPIO6);
|
||||
gpio_set(GPIOB, GPIO6);
|
||||
gpio_clear(GPIOB, GPIO6);
|
||||
#endif
|
||||
// pull USB D+ low for a short while
|
||||
rcc_periph_clock_enable(RCC_GPIOA);
|
||||
gpio_set_mode(GPIOA, GPIO_MODE_OUTPUT_2_MHZ, GPIO_CNF_OUTPUT_PUSHPULL, GPIO12);
|
||||
gpio_clear(GPIOA, GPIO12);
|
||||
sleep_ms(50); // USB disconnected must be at least 10 ms long, at most 100 ms
|
||||
// USB disconnected must be at least 10 ms long, at most 100 ms
|
||||
for (uint32_t i = 0; i < 0x2000; i++) {
|
||||
__asm__("nop");
|
||||
}
|
||||
}
|
||||
|
||||
/** flash downloaded data block
|
||||
|
|
Loading…
Reference in New Issue