S&B Volcano vaporizer remote control with Pi Pico W
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 "pico/cyw43_arch.h"
  20. #include "hardware/watchdog.h"
  21. #include "hardware/adc.h"
  22. #include "config.h"
  23. #include "util.h"
  24. #include "console.h"
  25. #include "log.h"
  26. #include "usb.h"
  27. #include "fat_disk.h"
  28. #include "buttons.h"
  29. #include "ble.h"
  30. int main(void) {
  31. heartbeat_init();
  32. buttons_init();
  33. cnsl_init();
  34. usb_init();
  35. if (watchdog_caused_reboot()) {
  36. debug("reset by watchdog");
  37. }
  38. // required for LiPo voltage reading
  39. adc_init();
  40. // required for BLE and LiPo voltage reading
  41. debug("cyw43_arch_init");
  42. if (cyw43_arch_init()) {
  43. debug("cyw43_arch_init failed");
  44. }
  45. debug("ble_init");
  46. ble_init();
  47. debug("fat_disk_init");
  48. fat_disk_init();
  49. // trigger after 1000ms
  50. watchdog_enable(1000, 1);
  51. debug("init done");
  52. while (1) {
  53. watchdog_update();
  54. heartbeat_run();
  55. buttons_run();
  56. usb_run();
  57. cnsl_run();
  58. }
  59. return 0;
  60. }