Align ChibiOS USB_WAIT_FOR_ENUMERATION implementation (#25184)

This commit is contained in:
Joel Challis 2025-04-22 05:31:42 +01:00 committed by GitHub
parent 0c4124c1c0
commit b5f8f4d6a2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -134,8 +134,6 @@ void protocol_setup(void) {
// chThdCreateStatic(waThread1, sizeof(waThread1), NORMALPRIO, Thread1, NULL); // chThdCreateStatic(waThread1, sizeof(waThread1), NORMALPRIO, Thread1, NULL);
} }
static host_driver_t *driver = NULL;
void protocol_pre_init(void) { void protocol_pre_init(void) {
/* Init USB */ /* Init USB */
usb_event_queue_init(); usb_event_queue_init();
@ -146,18 +144,11 @@ void protocol_pre_init(void) {
#endif #endif
/* Wait until USB is active */ /* Wait until USB is active */
while (true) { #ifdef USB_WAIT_FOR_ENUMERATION
#if defined(USB_WAIT_FOR_ENUMERATION) while (USB_DRIVER.state != USB_ACTIVE) {
if (USB_DRIVER.state == USB_ACTIVE) {
driver = &chibios_driver;
break;
}
#else
driver = &chibios_driver;
break;
#endif
wait_ms(50); wait_ms(50);
} }
#endif
/* Do need to wait here! /* Do need to wait here!
* Otherwise the next print might start a transfer on console EP * Otherwise the next print might start a transfer on console EP
@ -170,7 +161,7 @@ void protocol_pre_init(void) {
} }
void protocol_post_init(void) { void protocol_post_init(void) {
host_set_driver(driver); host_set_driver(&chibios_driver);
} }
void protocol_pre_task(void) { void protocol_pre_task(void) {