stm32f1: ubshid: add re-enumeration forcing.
This makes the demo reliably work on "generic" "other" style f1 boards out of the box.
This commit is contained in:
@@ -279,6 +279,21 @@ int main(void)
|
|||||||
rcc_clock_setup_in_hsi_out_48mhz();
|
rcc_clock_setup_in_hsi_out_48mhz();
|
||||||
|
|
||||||
rcc_periph_clock_enable(RCC_GPIOA);
|
rcc_periph_clock_enable(RCC_GPIOA);
|
||||||
|
/*
|
||||||
|
* This is a somewhat common cheap hack to trigger device re-enumeration
|
||||||
|
* on startup. Assuming a fixed external pullup on D+, (For USB-FS)
|
||||||
|
* setting the pin to output, and driving it explicitly low effectively
|
||||||
|
* "removes" the pullup. The subsequent USB init will "take over" the
|
||||||
|
* pin, and it will appear as a proper pullup to the host.
|
||||||
|
* The magic delay is somewhat arbitrary, no guarantees on USBIF
|
||||||
|
* compliance here, but "it works" in most places.
|
||||||
|
*/
|
||||||
|
gpio_set_mode(GPIOA, GPIO_MODE_OUTPUT_2_MHZ,
|
||||||
|
GPIO_CNF_OUTPUT_PUSHPULL, GPIO12);
|
||||||
|
gpio_clear(GPIOA, GPIO12);
|
||||||
|
for (unsigned i = 0; i < 800000; i++) {
|
||||||
|
__asm__("nop");
|
||||||
|
}
|
||||||
|
|
||||||
usbd_dev = usbd_init(&st_usbfs_v1_usb_driver, &dev_descr, &config, usb_strings, 3, usbd_control_buffer, sizeof(usbd_control_buffer));
|
usbd_dev = usbd_init(&st_usbfs_v1_usb_driver, &dev_descr, &config, usb_strings, 3, usbd_control_buffer, sizeof(usbd_control_buffer));
|
||||||
usbd_register_set_config_callback(usbd_dev, hid_set_config);
|
usbd_register_set_config_callback(usbd_dev, hid_set_config);
|
||||||
|
|||||||
Reference in New Issue
Block a user