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.

debug.c 1.4KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /*
  2. * debug.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 <string.h>
  19. #include "pico/stdlib.h"
  20. #include "ff.h"
  21. #include "config.h"
  22. #include "log.h"
  23. #include "debug.h"
  24. static FATFS fs;
  25. static bool mounted = false;
  26. int debug_msc_mount(void) {
  27. if (mounted) {
  28. debug("already mounted");
  29. return 0;
  30. }
  31. FRESULT res = f_mount(&fs, "", 0);
  32. if (res != FR_OK) {
  33. debug("error: f_mount returned %d", res);
  34. mounted = false;
  35. return -1;
  36. }
  37. mounted = true;
  38. return 0;
  39. }
  40. int debug_msc_unmount(void) {
  41. if (!mounted) {
  42. debug("already unmounted");
  43. return 0;
  44. }
  45. FRESULT res = f_mount(0, "", 0);
  46. if (res != FR_OK) {
  47. debug("error: f_mount returned %d", res);
  48. return -1;
  49. }
  50. mounted = false;
  51. return 0;
  52. }