From 634e42b2b47d32ae8aa933599e63e3761939e3f5 Mon Sep 17 00:00:00 2001 From: Joel Challis Date: Tue, 2 Nov 2021 18:53:46 +0000 Subject: [PATCH] Revert to old init order for host driver (#15029) * Partially revert 14888 --- quantum/main.c | 15 ++++++++++++--- tmk_core/protocol/chibios/chibios.c | 6 +++--- tmk_core/protocol/lufa/lufa.c | 6 +++--- tmk_core/protocol/vusb/protocol.c | 5 +++-- 4 files changed, 21 insertions(+), 11 deletions(-) diff --git a/quantum/main.c b/quantum/main.c index a896a67c6674..3814d371c124 100644 --- a/quantum/main.c +++ b/quantum/main.c @@ -19,11 +19,21 @@ void platform_setup(void); void protocol_setup(void); -void protocol_init(void); +void protocol_pre_init(void); +void protocol_post_init(void); void protocol_pre_task(void); void protocol_post_task(void); -// Bodge as refactoring vusb sucks.... +// Bodge as refactoring this area sucks.... +void protocol_init(void) __attribute__((weak)); +void protocol_init(void) { + protocol_pre_init(); + + keyboard_init(); + + protocol_post_init(); +} + void protocol_task(void) __attribute__((weak)); void protocol_task(void) { protocol_pre_task(); @@ -44,7 +54,6 @@ int main(void) { keyboard_setup(); protocol_init(); - keyboard_init(); /* Main loop */ while (true) { diff --git a/tmk_core/protocol/chibios/chibios.c b/tmk_core/protocol/chibios/chibios.c index 98b3305089e7..5ba21b3f8eed 100644 --- a/tmk_core/protocol/chibios/chibios.c +++ b/tmk_core/protocol/chibios/chibios.c @@ -140,7 +140,7 @@ void protocol_setup(void) { // chThdCreateStatic(waThread1, sizeof(waThread1), NORMALPRIO, Thread1, NULL); } -void protocol_init(void) { +void protocol_pre_init(void) { /* Init USB */ usb_event_queue_init(); init_usb_driver(&USB_DRIVER); @@ -173,10 +173,10 @@ void protocol_init(void) { wait_ms(50); print("USB configured.\n"); - - host_set_driver(driver); } +void protocol_post_init(void) { host_set_driver(driver); } + void protocol_pre_task(void) { usb_event_queue_task(); diff --git a/tmk_core/protocol/lufa/lufa.c b/tmk_core/protocol/lufa/lufa.c index 80781d2f370b..e3be96d93dad 100644 --- a/tmk_core/protocol/lufa/lufa.c +++ b/tmk_core/protocol/lufa/lufa.c @@ -1072,7 +1072,7 @@ void protocol_setup(void) { usb_device_state_init(); } -void protocol_init(void) { +void protocol_pre_init(void) { setup_usb(); sei(); @@ -1094,10 +1094,10 @@ void protocol_init(void) { #else USB_USBTask(); #endif - - host_set_driver(&lufa_driver); } +void protocol_post_init(void) { host_set_driver(&lufa_driver); } + void protocol_pre_task(void) { #if !defined(NO_USB_STARTUP_CHECK) if (USB_DeviceState == DEVICE_STATE_Suspended) { diff --git a/tmk_core/protocol/vusb/protocol.c b/tmk_core/protocol/vusb/protocol.c index 947c3383f1c1..644e77e021a4 100644 --- a/tmk_core/protocol/vusb/protocol.c +++ b/tmk_core/protocol/vusb/protocol.c @@ -113,12 +113,13 @@ void protocol_setup(void) { #endif } -void protocol_init(void) { +void protocol_pre_init(void) { setup_usb(); sei(); +} +void protocol_post_init(void) { host_set_driver(vusb_driver()); - wait_ms(50); }