1
0
Fork 0

Begin to carve out platform/protocol API - Single main loop (#13843)

* Begin to carve out platform/protocol API

* Fix up after rebase
This commit is contained in:
Joel Challis 2021-08-18 00:11:07 +01:00 committed by GitHub
parent 4c9003b177
commit 96e2b13d1d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 235 additions and 119 deletions

View file

@ -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();
}
}