debug.h 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. #ifndef DEBUG_INTERFACE_H_
  2. #define DEBUG_INTERFACE_H_
  3. #include "machine_interface_internal.h"
  4. #include "util.h"
  5. #include <avr/pgmspace.h>
  6. void debug_init(void);
  7. void do_debug_printf(const char PROGPTR *fmt, ...);
  8. #define _debug_printf(pfmt, ...) do { \
  9. if (debug_enabled()) \
  10. do_debug_printf(pfmt ,##__VA_ARGS__); \
  11. } while (0)
  12. #define debug_printf(fmt, ...) do { \
  13. if (debug_enabled()) \
  14. do_debug_printf(PSTR(fmt) ,##__VA_ARGS__); \
  15. } while (0)
  16. void debug_dumpmem(const void *_mem, uint8_t size);
  17. static inline bool debug_enabled(void)
  18. {
  19. return unlikely(!devflag_is_set(DEVICE_FLG_NODEBUG));
  20. }
  21. static inline bool debug_verbose(void)
  22. {
  23. return unlikely(devflag_is_set(DEVICE_FLG_VERBOSEDBG));
  24. }
  25. /** debug_ringbuf_count -- Get an approximate count of bytes
  26. * currently in the ring buffer. */
  27. uint8_t debug_ringbuf_count(void);
  28. /** debug_ringbuf_get - Get bytes from the ringbuffer.
  29. * @buf: Target buffer
  30. * @size: Target buffer size
  31. * Returns the number of bytes copied to the target buffer. */
  32. uint8_t debug_ringbuf_get(void *buf, uint8_t size);
  33. #endif /* DEBUG_INTERFACE_H_ */