USB: sleep_ms can't be used for DFU detach (in an interrupt)
This commit is contained in:
parent
d8934dc4c5
commit
41976d0af8
|
@ -250,14 +250,17 @@ static void usb_disconnect(void)
|
|||
rcc_periph_clock_enable(RCC_GPIOB);
|
||||
gpio_set_mode(GPIOB, GPIO_MODE_OUTPUT_2_MHZ, GPIO_CNF_OUTPUT_PUSHPULL, GPIO9);
|
||||
gpio_set(GPIOB, GPIO9);
|
||||
sleep_ms(20); // pull D+ low for at least 10 ms
|
||||
gpio_clear(GPIOB, GPIO9);
|
||||
for (uint32_t i = 0; i < 0x2000; i++) { // wait for at least 10 ms
|
||||
__asm__("nop");
|
||||
}
|
||||
#else
|
||||
// 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(20); // pull D+ low for at least 10 ms
|
||||
for (uint32_t i = 0; i < 0x2000; i++) { // wait for at least 10 ms
|
||||
__asm__("nop");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue