You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

76 lines
1.8 KiB

  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. #include "keyboard.h"
  17. void platform_setup(void);
  18. void protocol_setup(void);
  19. void protocol_pre_init(void);
  20. void protocol_post_init(void);
  21. void protocol_pre_task(void);
  22. void protocol_post_task(void);
  23. // Bodge as refactoring this area sucks....
  24. void protocol_init(void) __attribute__((weak));
  25. void protocol_init(void) {
  26. protocol_pre_init();
  27. keyboard_init();
  28. protocol_post_init();
  29. }
  30. void protocol_task(void) __attribute__((weak));
  31. void protocol_task(void) {
  32. protocol_pre_task();
  33. keyboard_task();
  34. protocol_post_task();
  35. }
  36. /** \brief Main
  37. *
  38. * FIXME: Needs doc
  39. */
  40. int main(void) __attribute__((weak));
  41. int main(void) {
  42. platform_setup();
  43. protocol_setup();
  44. keyboard_setup();
  45. protocol_init();
  46. /* Main loop */
  47. while (true) {
  48. protocol_task();
  49. #ifdef QUANTUM_PAINTER_ENABLE
  50. // Run Quantum Painter task
  51. void qp_internal_task(void);
  52. qp_internal_task();
  53. #endif
  54. #ifdef DEFERRED_EXEC_ENABLE
  55. // Run deferred executions
  56. void deferred_exec_task(void);
  57. deferred_exec_task();
  58. #endif // DEFERRED_EXEC_ENABLE
  59. housekeeping_task();
  60. }
  61. }