diff options
author | Joel Challis <[email protected]> | 2021-08-18 00:11:07 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2021-08-18 00:11:07 +0100 |
commit | 96e2b13d1de227cdc2b918fb0292bd832d346a25 (patch) | |
tree | 0a558972c834d47728acaa41c043165592c5ceb5 /tmk_core/protocol/chibios | |
parent | 4c9003b1779b7b404e3bb0ce103db683bd92bccb (diff) | |
download | qmk_firmware-96e2b13d1de227cdc2b918fb0292bd832d346a25.tar.gz qmk_firmware-96e2b13d1de227cdc2b918fb0292bd832d346a25.zip |
Begin to carve out platform/protocol API - Single main loop (#13843)
* Begin to carve out platform/protocol API
* Fix up after rebase
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 e41d6ff195..78a2e3fcbb 100644 --- a/tmk_core/protocol/chibios/main.c +++ b/tmk_core/protocol/chibios/chibios.c @@ -138,18 +138,14 @@ void boardInit(void) { board_init(); } -/* Main thread - */ -int main(void) { - /* ChibiOS/RT init */ - halInit(); - chSysInit(); - +void protocol_setup(void) { // TESTING // chThdCreateStatic(waThread1, sizeof(waThread1), NORMALPRIO, Thread1, NULL); keyboard_setup(); +} +void protocol_init(void) { /* Init USB */ usb_event_queue_init(); init_usb_driver(&USB_DRIVER); @@ -207,57 +203,53 @@ int main(void) { #endif print("Keyboard start.\n"); +} - /* Main loop */ - while (true) { - usb_event_queue_task(); +void protocol_task(void) { + usb_event_queue_task(); #if !defined(NO_USB_STARTUP_CHECK) - if (USB_DRIVER.state == USB_SUSPENDED) { - print("[s]"); + if (USB_DRIVER.state == USB_SUSPENDED) { + print("[s]"); # ifdef VISUALIZER_ENABLE - visualizer_suspend(); + visualizer_suspend(); # endif - while (USB_DRIVER.state == USB_SUSPENDED) { - /* Do this in the suspended state */ + while (USB_DRIVER.state == USB_SUSPENDED) { + /* Do this in the suspended state */ # ifdef SERIAL_LINK_ENABLE - serial_link_update(); + serial_link_update(); # endif - suspend_power_down(); // on AVR this deep sleeps for 15ms - /* Remote wakeup */ - if (suspend_wakeup_condition()) { - usbWakeupHost(&USB_DRIVER); - restart_usb_driver(&USB_DRIVER); - } + suspend_power_down(); // on AVR this deep sleeps for 15ms + /* Remote wakeup */ + if (suspend_wakeup_condition()) { + usbWakeupHost(&USB_DRIVER); + restart_usb_driver(&USB_DRIVER); } - /* Woken up */ - // variables has been already cleared by the wakeup hook - send_keyboard_report(); + } + /* Woken up */ + // variables has been already cleared by the wakeup hook + send_keyboard_report(); # ifdef MOUSEKEY_ENABLE - mousekey_send(); + mousekey_send(); # endif /* MOUSEKEY_ENABLE */ # ifdef VISUALIZER_ENABLE - visualizer_resume(); + visualizer_resume(); # endif - } + } #endif - keyboard_task(); + keyboard_task(); #ifdef CONSOLE_ENABLE - console_task(); + console_task(); #endif #ifdef MIDI_ENABLE - midi_ep_task(); + midi_ep_task(); #endif #ifdef VIRTSER_ENABLE - virtser_task(); + virtser_task(); #endif #ifdef RAW_ENABLE - raw_hid_task(); + raw_hid_task(); #endif - - // Run housekeeping - housekeeping_task(); - } } |