diff options
Diffstat (limited to 'tmk_core/protocol/chibios/main.c')
-rw-r--r-- | tmk_core/protocol/chibios/main.c | 30 |
1 files changed, 27 insertions, 3 deletions
diff --git a/tmk_core/protocol/chibios/main.c b/tmk_core/protocol/chibios/main.c index 54bb6a8f5..aeb11752f 100644 --- a/tmk_core/protocol/chibios/main.c +++ b/tmk_core/protocol/chibios/main.c | |||
@@ -35,6 +35,9 @@ | |||
35 | #ifdef SLEEP_LED_ENABLE | 35 | #ifdef SLEEP_LED_ENABLE |
36 | #include "sleep_led.h" | 36 | #include "sleep_led.h" |
37 | #endif | 37 | #endif |
38 | #ifdef SERIAL_LINK_ENABLE | ||
39 | #include "serial_link/system/serial_link.h" | ||
40 | #endif | ||
38 | #include "suspend.h" | 41 | #include "suspend.h" |
39 | 42 | ||
40 | 43 | ||
@@ -98,9 +101,27 @@ int main(void) { | |||
98 | /* init printf */ | 101 | /* init printf */ |
99 | init_printf(NULL,sendchar_pf); | 102 | init_printf(NULL,sendchar_pf); |
100 | 103 | ||
101 | /* Wait until the USB is active */ | 104 | #ifdef SERIAL_LINK_ENABLE |
102 | while(USB_DRIVER.state != USB_ACTIVE) | 105 | init_serial_link(); |
106 | #endif | ||
107 | |||
108 | host_driver_t* driver = NULL; | ||
109 | |||
110 | /* Wait until the USB or serial link is active */ | ||
111 | while (true) { | ||
112 | if(USB_DRIVER.state == USB_ACTIVE) { | ||
113 | driver = &chibios_driver; | ||
114 | break; | ||
115 | } | ||
116 | #ifdef SERIAL_LINK_ENABLE | ||
117 | if(is_serial_link_connected()) { | ||
118 | driver = get_serial_link_driver(); | ||
119 | break; | ||
120 | } | ||
121 | serial_link_update(); | ||
122 | #endif | ||
103 | chThdSleepMilliseconds(50); | 123 | chThdSleepMilliseconds(50); |
124 | } | ||
104 | 125 | ||
105 | /* Do need to wait here! | 126 | /* Do need to wait here! |
106 | * Otherwise the next print might start a transfer on console EP | 127 | * Otherwise the next print might start a transfer on console EP |
@@ -113,7 +134,7 @@ int main(void) { | |||
113 | 134 | ||
114 | /* init TMK modules */ | 135 | /* init TMK modules */ |
115 | keyboard_init(); | 136 | keyboard_init(); |
116 | host_set_driver(&chibios_driver); | 137 | host_set_driver(driver); |
117 | 138 | ||
118 | #ifdef SLEEP_LED_ENABLE | 139 | #ifdef SLEEP_LED_ENABLE |
119 | sleep_led_init(); | 140 | sleep_led_init(); |
@@ -128,6 +149,9 @@ int main(void) { | |||
128 | print("[s]"); | 149 | print("[s]"); |
129 | while(USB_DRIVER.state == USB_SUSPENDED) { | 150 | while(USB_DRIVER.state == USB_SUSPENDED) { |
130 | /* Do this in the suspended state */ | 151 | /* Do this in the suspended state */ |
152 | #ifdef SERIAL_LINK_ENABLE | ||
153 | serial_link_update(); | ||
154 | #endif | ||
131 | suspend_power_down(); // on AVR this deep sleeps for 15ms | 155 | suspend_power_down(); // on AVR this deep sleeps for 15ms |
132 | /* Remote wakeup */ | 156 | /* Remote wakeup */ |
133 | if((USB_DRIVER.status & 2) && suspend_wakeup_condition()) { | 157 | if((USB_DRIVER.status & 2) && suspend_wakeup_condition()) { |