aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--quantum/main.c15
-rw-r--r--tmk_core/protocol/chibios/chibios.c6
-rw-r--r--tmk_core/protocol/lufa/lufa.c6
-rw-r--r--tmk_core/protocol/vusb/protocol.c5
4 files changed, 21 insertions, 11 deletions
diff --git a/quantum/main.c b/quantum/main.c
index a896a67c6..3814d371c 100644
--- a/quantum/main.c
+++ b/quantum/main.c
@@ -19,11 +19,21 @@
19void platform_setup(void); 19void platform_setup(void);
20 20
21void protocol_setup(void); 21void protocol_setup(void);
22void protocol_init(void); 22void protocol_pre_init(void);
23void protocol_post_init(void);
23void protocol_pre_task(void); 24void protocol_pre_task(void);
24void protocol_post_task(void); 25void protocol_post_task(void);
25 26
26// Bodge as refactoring vusb sucks.... 27// Bodge as refactoring this area sucks....
28void protocol_init(void) __attribute__((weak));
29void protocol_init(void) {
30 protocol_pre_init();
31
32 keyboard_init();
33
34 protocol_post_init();
35}
36
27void protocol_task(void) __attribute__((weak)); 37void protocol_task(void) __attribute__((weak));
28void protocol_task(void) { 38void protocol_task(void) {
29 protocol_pre_task(); 39 protocol_pre_task();
@@ -44,7 +54,6 @@ int main(void) {
44 keyboard_setup(); 54 keyboard_setup();
45 55
46 protocol_init(); 56 protocol_init();
47 keyboard_init();
48 57
49 /* Main loop */ 58 /* Main loop */
50 while (true) { 59 while (true) {
diff --git a/tmk_core/protocol/chibios/chibios.c b/tmk_core/protocol/chibios/chibios.c
index 98b330508..5ba21b3f8 100644
--- a/tmk_core/protocol/chibios/chibios.c
+++ b/tmk_core/protocol/chibios/chibios.c
@@ -140,7 +140,7 @@ void protocol_setup(void) {
140 // chThdCreateStatic(waThread1, sizeof(waThread1), NORMALPRIO, Thread1, NULL); 140 // chThdCreateStatic(waThread1, sizeof(waThread1), NORMALPRIO, Thread1, NULL);
141} 141}
142 142
143void protocol_init(void) { 143void protocol_pre_init(void) {
144 /* Init USB */ 144 /* Init USB */
145 usb_event_queue_init(); 145 usb_event_queue_init();
146 init_usb_driver(&USB_DRIVER); 146 init_usb_driver(&USB_DRIVER);
@@ -173,10 +173,10 @@ void protocol_init(void) {
173 wait_ms(50); 173 wait_ms(50);
174 174
175 print("USB configured.\n"); 175 print("USB configured.\n");
176
177 host_set_driver(driver);
178} 176}
179 177
178void protocol_post_init(void) { host_set_driver(driver); }
179
180void protocol_pre_task(void) { 180void protocol_pre_task(void) {
181 usb_event_queue_task(); 181 usb_event_queue_task();
182 182
diff --git a/tmk_core/protocol/lufa/lufa.c b/tmk_core/protocol/lufa/lufa.c
index 80781d2f3..e3be96d93 100644
--- a/tmk_core/protocol/lufa/lufa.c
+++ b/tmk_core/protocol/lufa/lufa.c
@@ -1072,7 +1072,7 @@ void protocol_setup(void) {
1072 usb_device_state_init(); 1072 usb_device_state_init();
1073} 1073}
1074 1074
1075void protocol_init(void) { 1075void protocol_pre_init(void) {
1076 setup_usb(); 1076 setup_usb();
1077 sei(); 1077 sei();
1078 1078
@@ -1094,10 +1094,10 @@ void protocol_init(void) {
1094#else 1094#else
1095 USB_USBTask(); 1095 USB_USBTask();
1096#endif 1096#endif
1097
1098 host_set_driver(&lufa_driver);
1099} 1097}
1100 1098
1099void protocol_post_init(void) { host_set_driver(&lufa_driver); }
1100
1101void protocol_pre_task(void) { 1101void protocol_pre_task(void) {
1102#if !defined(NO_USB_STARTUP_CHECK) 1102#if !defined(NO_USB_STARTUP_CHECK)
1103 if (USB_DeviceState == DEVICE_STATE_Suspended) { 1103 if (USB_DeviceState == DEVICE_STATE_Suspended) {
diff --git a/tmk_core/protocol/vusb/protocol.c b/tmk_core/protocol/vusb/protocol.c
index 947c3383f..644e77e02 100644
--- a/tmk_core/protocol/vusb/protocol.c
+++ b/tmk_core/protocol/vusb/protocol.c
@@ -113,12 +113,13 @@ void protocol_setup(void) {
113#endif 113#endif
114} 114}
115 115
116void protocol_init(void) { 116void protocol_pre_init(void) {
117 setup_usb(); 117 setup_usb();
118 sei(); 118 sei();
119}
119 120
121void protocol_post_init(void) {
120 host_set_driver(vusb_driver()); 122 host_set_driver(vusb_driver());
121
122 wait_ms(50); 123 wait_ms(50);
123} 124}
124 125