aboutsummaryrefslogtreecommitdiff
path: root/tmk_core/protocol/chibios
diff options
context:
space:
mode:
Diffstat (limited to 'tmk_core/protocol/chibios')
-rw-r--r--tmk_core/protocol/chibios/chibios.c (renamed from tmk_core/protocol/chibios/main.c)66
1 files changed, 29 insertions, 37 deletions
diff --git a/tmk_core/protocol/chibios/main.c b/tmk_core/protocol/chibios/chibios.c
index e41d6ff19..78a2e3fcb 100644
--- a/tmk_core/protocol/chibios/main.c
+++ b/tmk_core/protocol/chibios/chibios.c
@@ -138,18 +138,14 @@ void boardInit(void) {
138 board_init(); 138 board_init();
139} 139}
140 140
141/* Main thread 141void protocol_setup(void) {
142 */
143int main(void) {
144 /* ChibiOS/RT init */
145 halInit();
146 chSysInit();
147
148 // TESTING 142 // TESTING
149 // chThdCreateStatic(waThread1, sizeof(waThread1), NORMALPRIO, Thread1, NULL); 143 // chThdCreateStatic(waThread1, sizeof(waThread1), NORMALPRIO, Thread1, NULL);
150 144
151 keyboard_setup(); 145 keyboard_setup();
146}
152 147
148void protocol_init(void) {
153 /* Init USB */ 149 /* Init USB */
154 usb_event_queue_init(); 150 usb_event_queue_init();
155 init_usb_driver(&USB_DRIVER); 151 init_usb_driver(&USB_DRIVER);
@@ -207,57 +203,53 @@ int main(void) {
207#endif 203#endif
208 204
209 print("Keyboard start.\n"); 205 print("Keyboard start.\n");
206}
210 207
211 /* Main loop */ 208void protocol_task(void) {
212 while (true) { 209 usb_event_queue_task();
213 usb_event_queue_task();
214 210
215#if !defined(NO_USB_STARTUP_CHECK) 211#if !defined(NO_USB_STARTUP_CHECK)
216 if (USB_DRIVER.state == USB_SUSPENDED) { 212 if (USB_DRIVER.state == USB_SUSPENDED) {
217 print("[s]"); 213 print("[s]");
218# ifdef VISUALIZER_ENABLE 214# ifdef VISUALIZER_ENABLE
219 visualizer_suspend(); 215 visualizer_suspend();
220# endif 216# endif
221 while (USB_DRIVER.state == USB_SUSPENDED) { 217 while (USB_DRIVER.state == USB_SUSPENDED) {
222 /* Do this in the suspended state */ 218 /* Do this in the suspended state */
223# ifdef SERIAL_LINK_ENABLE 219# ifdef SERIAL_LINK_ENABLE
224 serial_link_update(); 220 serial_link_update();
225# endif 221# endif
226 suspend_power_down(); // on AVR this deep sleeps for 15ms 222 suspend_power_down(); // on AVR this deep sleeps for 15ms
227 /* Remote wakeup */ 223 /* Remote wakeup */
228 if (suspend_wakeup_condition()) { 224 if (suspend_wakeup_condition()) {
229 usbWakeupHost(&USB_DRIVER); 225 usbWakeupHost(&USB_DRIVER);
230 restart_usb_driver(&USB_DRIVER); 226 restart_usb_driver(&USB_DRIVER);
231 }
232 } 227 }
233 /* Woken up */ 228 }
234 // variables has been already cleared by the wakeup hook 229 /* Woken up */
235 send_keyboard_report(); 230 // variables has been already cleared by the wakeup hook
231 send_keyboard_report();
236# ifdef MOUSEKEY_ENABLE 232# ifdef MOUSEKEY_ENABLE
237 mousekey_send(); 233 mousekey_send();
238# endif /* MOUSEKEY_ENABLE */ 234# endif /* MOUSEKEY_ENABLE */
239 235
240# ifdef VISUALIZER_ENABLE 236# ifdef VISUALIZER_ENABLE
241 visualizer_resume(); 237 visualizer_resume();
242# endif 238# endif
243 } 239 }
244#endif 240#endif
245 241
246 keyboard_task(); 242 keyboard_task();
247#ifdef CONSOLE_ENABLE 243#ifdef CONSOLE_ENABLE
248 console_task(); 244 console_task();
249#endif 245#endif
250#ifdef MIDI_ENABLE 246#ifdef MIDI_ENABLE
251 midi_ep_task(); 247 midi_ep_task();
252#endif 248#endif
253#ifdef VIRTSER_ENABLE 249#ifdef VIRTSER_ENABLE
254 virtser_task(); 250 virtser_task();
255#endif 251#endif
256#ifdef RAW_ENABLE 252#ifdef RAW_ENABLE
257 raw_hid_task(); 253 raw_hid_task();
258#endif 254#endif
259
260 // Run housekeeping
261 housekeeping_task();
262 }
263} 255}