No Description
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.

main.c 1.6KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. /*
  2. * main.c
  3. *
  4. * Copyright (c) 2022 - 2023 Thomas Buck (thomas@xythobuz.de)
  5. *
  6. * This program is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation, either version 3 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * See <http://www.gnu.org/licenses/>.
  17. */
  18. #include "pico/stdlib.h"
  19. #include "hardware/watchdog.h"
  20. #include "config.h"
  21. #include "util.h"
  22. #include "console.h"
  23. #include "log.h"
  24. #include "usb.h"
  25. #include "pmw3360.h"
  26. #include "fat_disk.h"
  27. #include "buttons.h"
  28. #include "controls.h"
  29. int main(void) {
  30. heartbeat_init();
  31. buttons_init();
  32. controls_init();
  33. cnsl_init();
  34. usb_init();
  35. if (watchdog_caused_reboot()) {
  36. debug("reset by watchdog");
  37. }
  38. debug("fat_disk_init");
  39. fat_disk_init();
  40. debug("pmw_init");
  41. bool use_pmw = true;
  42. if (pmw_init() != 0) {
  43. debug("error initializing PMW3360");
  44. use_pmw = false;
  45. }
  46. // trigger after 500ms
  47. // (PMW3360 initialization takes ~160ms)
  48. watchdog_enable(500, 1);
  49. debug("init done");
  50. while (1) {
  51. watchdog_update();
  52. heartbeat_run();
  53. buttons_run();
  54. usb_run();
  55. cnsl_run();
  56. if (use_pmw) {
  57. pmw_run();
  58. }
  59. }
  60. return 0;
  61. }