logo

qmk_firmware

custom branch of QMK firmware git clone https://anongit.hacktivis.me/git/qmk_firmware.git

debug.h (1788B)


  1. /*
  2. Copyright 2011 Jun Wako <wakojun@gmail.com>
  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 2 of the License, or
  6. (at your option) any later version.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU General Public License for more details.
  11. You should have received a copy of the GNU General Public License
  12. along with this program. If not, see <http://www.gnu.org/licenses/>.
  13. */
  14. #pragma once
  15. #include <stdio.h>
  16. #include <stdbool.h>
  17. #include "print.h"
  18. #ifdef __cplusplus
  19. extern "C" {
  20. #endif
  21. /*
  22. * Debug output control
  23. */
  24. typedef union debug_config_t {
  25. struct {
  26. bool enable : 1;
  27. bool matrix : 1;
  28. bool keyboard : 1;
  29. bool mouse : 1;
  30. uint8_t reserved : 4;
  31. };
  32. uint8_t raw;
  33. } debug_config_t;
  34. extern debug_config_t debug_config;
  35. #ifdef __cplusplus
  36. }
  37. #endif
  38. /* for backward compatibility */
  39. #define debug_enable (debug_config.enable)
  40. #define debug_matrix (debug_config.matrix)
  41. #define debug_keyboard (debug_config.keyboard)
  42. #define debug_mouse (debug_config.mouse)
  43. /*
  44. * Debug print utils
  45. */
  46. #ifndef NO_DEBUG
  47. # define dprintf(fmt, ...) \
  48. do { \
  49. if (debug_config.enable) xprintf(fmt, ##__VA_ARGS__); \
  50. } while (0)
  51. #else /* NO_DEBUG */
  52. # define dprintf(fmt, ...)
  53. #endif /* NO_DEBUG */
  54. #define dprint(s) dprintf(s)
  55. #define dprintln(s) dprintf(s "\r\n")
  56. #define dmsg(s) dprintf("%s at %d: %s\n", __FILE__, __LINE__, s)