diff options
author | Joel Challis <git@zvecr.com> | 2021-08-18 00:11:07 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-08-18 00:11:07 +0100 |
commit | 96e2b13d1de227cdc2b918fb0292bd832d346a25 (patch) | |
tree | 0a558972c834d47728acaa41c043165592c5ceb5 /tmk_core/protocol/lufa/lufa.c | |
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/lufa/lufa.c')
-rw-r--r-- | tmk_core/protocol/lufa/lufa.c | 64 |
1 files changed, 30 insertions, 34 deletions
diff --git a/tmk_core/protocol/lufa/lufa.c b/tmk_core/protocol/lufa/lufa.c index 8ddb8b1c4..e638dbc0f 100644 --- a/tmk_core/protocol/lufa/lufa.c +++ b/tmk_core/protocol/lufa/lufa.c | |||
@@ -1033,18 +1033,16 @@ static void setup_usb(void) { | |||
1033 | USB_Device_EnableSOFEvents(); | 1033 | USB_Device_EnableSOFEvents(); |
1034 | } | 1034 | } |
1035 | 1035 | ||
1036 | /** \brief Main | 1036 | void protocol_setup(void) { |
1037 | * | ||
1038 | * FIXME: Needs doc | ||
1039 | */ | ||
1040 | int main(void) __attribute__((weak)); | ||
1041 | int main(void) { | ||
1042 | #ifdef MIDI_ENABLE | 1037 | #ifdef MIDI_ENABLE |
1043 | setup_midi(); | 1038 | setup_midi(); |
1044 | #endif | 1039 | #endif |
1045 | 1040 | ||
1046 | setup_mcu(); | 1041 | setup_mcu(); |
1047 | keyboard_setup(); | 1042 | keyboard_setup(); |
1043 | } | ||
1044 | |||
1045 | void protocol_init(void) { | ||
1048 | setup_usb(); | 1046 | setup_usb(); |
1049 | sei(); | 1047 | sei(); |
1050 | 1048 | ||
@@ -1078,57 +1076,55 @@ int main(void) { | |||
1078 | #endif | 1076 | #endif |
1079 | 1077 | ||
1080 | print("Keyboard start.\n"); | 1078 | print("Keyboard start.\n"); |
1081 | while (1) { | 1079 | } |
1080 | |||
1081 | void protocol_task(void) { | ||
1082 | #if !defined(NO_USB_STARTUP_CHECK) | 1082 | #if !defined(NO_USB_STARTUP_CHECK) |
1083 | if (USB_DeviceState == DEVICE_STATE_Suspended) { | 1083 | if (USB_DeviceState == DEVICE_STATE_Suspended) { |
1084 | print("[s]"); | 1084 | print("[s]"); |
1085 | while (USB_DeviceState == DEVICE_STATE_Suspended) { | 1085 | while (USB_DeviceState == DEVICE_STATE_Suspended) { |
1086 | suspend_power_down(); | 1086 | suspend_power_down(); |
1087 | if (USB_Device_RemoteWakeupEnabled && suspend_wakeup_condition()) { | 1087 | if (USB_Device_RemoteWakeupEnabled && suspend_wakeup_condition()) { |
1088 | USB_Device_SendRemoteWakeup(); | 1088 | USB_Device_SendRemoteWakeup(); |
1089 | clear_keyboard(); | 1089 | clear_keyboard(); |
1090 | 1090 | ||
1091 | # if USB_SUSPEND_WAKEUP_DELAY > 0 | 1091 | # if USB_SUSPEND_WAKEUP_DELAY > 0 |
1092 | // Some hubs, kvm switches, and monitors do | 1092 | // Some hubs, kvm switches, and monitors do |
1093 | // weird things, with USB device state bouncing | 1093 | // weird things, with USB device state bouncing |
1094 | // around wildly on wakeup, yielding race | 1094 | // around wildly on wakeup, yielding race |
1095 | // conditions that can corrupt the keyboard state. | 1095 | // conditions that can corrupt the keyboard state. |
1096 | // | 1096 | // |
1097 | // Pause for a while to let things settle... | 1097 | // Pause for a while to let things settle... |
1098 | wait_ms(USB_SUSPEND_WAKEUP_DELAY); | 1098 | wait_ms(USB_SUSPEND_WAKEUP_DELAY); |
1099 | # endif | 1099 | # endif |
1100 | } | ||
1101 | } | 1100 | } |
1102 | suspend_wakeup_init(); | ||
1103 | } | 1101 | } |
1102 | suspend_wakeup_init(); | ||
1103 | } | ||
1104 | #endif | 1104 | #endif |
1105 | 1105 | ||
1106 | keyboard_task(); | 1106 | keyboard_task(); |
1107 | 1107 | ||
1108 | #ifdef MIDI_ENABLE | 1108 | #ifdef MIDI_ENABLE |
1109 | MIDI_Device_USBTask(&USB_MIDI_Interface); | 1109 | MIDI_Device_USBTask(&USB_MIDI_Interface); |
1110 | #endif | 1110 | #endif |
1111 | 1111 | ||
1112 | #ifdef MODULE_ADAFRUIT_BLE | 1112 | #ifdef MODULE_ADAFRUIT_BLE |
1113 | adafruit_ble_task(); | 1113 | adafruit_ble_task(); |
1114 | #endif | 1114 | #endif |
1115 | 1115 | ||
1116 | #ifdef VIRTSER_ENABLE | 1116 | #ifdef VIRTSER_ENABLE |
1117 | virtser_task(); | 1117 | virtser_task(); |
1118 | CDC_Device_USBTask(&cdc_device); | 1118 | CDC_Device_USBTask(&cdc_device); |
1119 | #endif | 1119 | #endif |
1120 | 1120 | ||
1121 | #ifdef RAW_ENABLE | 1121 | #ifdef RAW_ENABLE |
1122 | raw_hid_task(); | 1122 | raw_hid_task(); |
1123 | #endif | 1123 | #endif |
1124 | 1124 | ||
1125 | #if !defined(INTERRUPT_CONTROL_ENDPOINT) | 1125 | #if !defined(INTERRUPT_CONTROL_ENDPOINT) |
1126 | USB_USBTask(); | 1126 | USB_USBTask(); |
1127 | #endif | 1127 | #endif |
1128 | |||
1129 | // Run housekeeping | ||
1130 | housekeeping_task(); | ||
1131 | } | ||
1132 | } | 1128 | } |
1133 | 1129 | ||
1134 | uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue, const uint16_t wIndex, const void **const DescriptorAddress) { return get_usb_descriptor(wValue, wIndex, DescriptorAddress); } | 1130 | uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue, const uint16_t wIndex, const void **const DescriptorAddress) { return get_usb_descriptor(wValue, wIndex, DescriptorAddress); } |