summaryrefslogtreecommitdiff
path: root/tmk_core/protocol/lufa
diff options
context:
space:
mode:
authorJoel Challis <git@zvecr.com>2021-08-18 00:11:07 +0100
committerGitHub <noreply@github.com>2021-08-18 00:11:07 +0100
commit96e2b13d1de227cdc2b918fb0292bd832d346a25 (patch)
tree0a558972c834d47728acaa41c043165592c5ceb5 /tmk_core/protocol/lufa
parent4c9003b1779b7b404e3bb0ce103db683bd92bccb (diff)
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/lufa')
-rw-r--r--tmk_core/protocol/lufa/lufa.c64
1 files changed, 30 insertions, 34 deletions
diff --git a/tmk_core/protocol/lufa/lufa.c b/tmk_core/protocol/lufa/lufa.c
index 8ddb8b1c4b..e638dbc0fb 100644
--- a/tmk_core/protocol/lufa/lufa.c
+++ b/tmk_core/protocol/lufa/lufa.c
@@ -1033,18 +1033,16 @@ static void setup_usb(void) {
USB_Device_EnableSOFEvents();
}
-/** \brief Main
- *
- * FIXME: Needs doc
- */
-int main(void) __attribute__((weak));
-int main(void) {
+void protocol_setup(void) {
#ifdef MIDI_ENABLE
setup_midi();
#endif
setup_mcu();
keyboard_setup();
+}
+
+void protocol_init(void) {
setup_usb();
sei();
@@ -1078,57 +1076,55 @@ int main(void) {
#endif
print("Keyboard start.\n");
- while (1) {
+}
+
+void protocol_task(void) {
#if !defined(NO_USB_STARTUP_CHECK)
- if (USB_DeviceState == DEVICE_STATE_Suspended) {
- print("[s]");
- while (USB_DeviceState == DEVICE_STATE_Suspended) {
- suspend_power_down();
- if (USB_Device_RemoteWakeupEnabled && suspend_wakeup_condition()) {
- USB_Device_SendRemoteWakeup();
- clear_keyboard();
+ if (USB_DeviceState == DEVICE_STATE_Suspended) {
+ print("[s]");
+ while (USB_DeviceState == DEVICE_STATE_Suspended) {
+ suspend_power_down();
+ if (USB_Device_RemoteWakeupEnabled && suspend_wakeup_condition()) {
+ USB_Device_SendRemoteWakeup();
+ clear_keyboard();
# if USB_SUSPEND_WAKEUP_DELAY > 0
- // Some hubs, kvm switches, and monitors do
- // weird things, with USB device state bouncing
- // around wildly on wakeup, yielding race
- // conditions that can corrupt the keyboard state.
- //
- // Pause for a while to let things settle...
- wait_ms(USB_SUSPEND_WAKEUP_DELAY);
+ // Some hubs, kvm switches, and monitors do
+ // weird things, with USB device state bouncing
+ // around wildly on wakeup, yielding race
+ // conditions that can corrupt the keyboard state.
+ //
+ // Pause for a while to let things settle...
+ wait_ms(USB_SUSPEND_WAKEUP_DELAY);
# endif
- }
}
- suspend_wakeup_init();
}
+ suspend_wakeup_init();
+ }
#endif
- keyboard_task();
+ keyboard_task();
#ifdef MIDI_ENABLE
- MIDI_Device_USBTask(&USB_MIDI_Interface);
+ MIDI_Device_USBTask(&USB_MIDI_Interface);
#endif
#ifdef MODULE_ADAFRUIT_BLE
- adafruit_ble_task();
+ adafruit_ble_task();
#endif
#ifdef VIRTSER_ENABLE
- virtser_task();
- CDC_Device_USBTask(&cdc_device);
+ virtser_task();
+ CDC_Device_USBTask(&cdc_device);
#endif
#ifdef RAW_ENABLE
- raw_hid_task();
+ raw_hid_task();
#endif
#if !defined(INTERRUPT_CONTROL_ENDPOINT)
- USB_USBTask();
+ USB_USBTask();
#endif
-
- // Run housekeeping
- housekeeping_task();
- }
}
uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue, const uint16_t wIndex, const void **const DescriptorAddress) { return get_usb_descriptor(wValue, wIndex, DescriptorAddress); }