main.c (1919B)
1 /* Copyright 2021 QMK 2 * 3 * This program is free software: you can redistribute it and/or modify 4 * it under the terms of the GNU General Public License as published by 5 * the Free Software Foundation, either version 3 of the License, or 6 * (at your option) any later version. 7 * 8 * This program is distributed in the hope that it will be useful, 9 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 * GNU General Public License for more details. 12 * 13 * You should have received a copy of the GNU General Public License 14 * along with this program. If not, see <http://www.gnu.org/licenses/>. 15 */ 16 17 #include "keyboard.h" 18 19 void platform_setup(void); 20 21 void protocol_setup(void); 22 void protocol_pre_init(void); 23 void protocol_post_init(void); 24 void protocol_pre_task(void); 25 void protocol_post_task(void); 26 27 // Bodge as refactoring this area sucks.... 28 void protocol_keyboard_task(void) __attribute__((weak)); 29 void protocol_keyboard_task(void) { 30 keyboard_task(); 31 } 32 33 /** \brief Main 34 * 35 * FIXME: Needs doc 36 */ 37 int main(void) __attribute__((weak)); 38 int main(void) { 39 platform_setup(); 40 protocol_setup(); 41 keyboard_setup(); 42 43 protocol_pre_init(); 44 keyboard_init(); 45 protocol_post_init(); 46 47 /* Main loop */ 48 while (true) { 49 protocol_pre_task(); 50 protocol_keyboard_task(); 51 protocol_post_task(); 52 53 #ifdef RAW_ENABLE 54 void raw_hid_task(void); 55 raw_hid_task(); 56 #endif 57 58 #ifdef CONSOLE_ENABLE 59 void console_task(void); 60 console_task(); 61 #endif 62 63 #ifdef QUANTUM_PAINTER_ENABLE 64 // Run Quantum Painter task 65 void qp_internal_task(void); 66 qp_internal_task(); 67 #endif 68 69 #ifdef DEFERRED_EXEC_ENABLE 70 // Run deferred executions 71 void deferred_exec_task(void); 72 deferred_exec_task(); 73 #endif // DEFERRED_EXEC_ENABLE 74 75 housekeeping_task(); 76 } 77 }