add USB disconnect functionnality for maple mini to force re-enumerate
This commit is contained in:
parent
3a76222050
commit
9c19273ecd
|
@ -295,12 +295,24 @@ static void cdcacm_set_config(usbd_device *usbd_dev, uint16_t wValue)
|
|||
void cdcacm_setup(void)
|
||||
{
|
||||
/* short USB disconnect to force re-enumerate */
|
||||
#ifdef SYSTEM_BOARD
|
||||
// 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);
|
||||
for (uint32_t i = 0; i < 0x1000; i++) {
|
||||
for (uint32_t i = 0; i < 0x8000; i++) {
|
||||
__asm__("nop");
|
||||
}
|
||||
#elif MAPLE_MINI
|
||||
// disconnect USB D+ using dedicated DISC line/circuit on PB9
|
||||
rcc_periph_clock_enable(RCC_GPIOB);
|
||||
gpio_set_mode(GPIOA, GPIO_MODE_OUTPUT_2_MHZ, GPIO_CNF_OUTPUT_PUSHPULL, GPIO9);
|
||||
gpio_set(GPIOB, GPIO9);
|
||||
for (uint32_t i = 0; i < 0x800; i++) {
|
||||
__asm__("nop");
|
||||
}
|
||||
gpio_clear(GPIOB, GPIO9);
|
||||
#endif
|
||||
|
||||
/* initialize USB */
|
||||
usb_device = usbd_init(&st_usbfs_v1_usb_driver, &device_descriptor, &config, usb_strings, 3, usbd_control_buffer, sizeof(usbd_control_buffer));
|
||||
|
|
Loading…
Reference in New Issue