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.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.

message.h 2.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. /* Copyright (C) 2011 Circuits At Home, LTD. All rights reserved.
  2. This software may be distributed and modified under the terms of the GNU
  3. General Public License version 2 (GPL2) as published by the Free Software
  4. Foundation and appearing in the file GPL2.TXT included in the packaging of
  5. this file. Please note that GPL2 Section 2[b] requires that all works based
  6. on this software must also be made publicly available under the terms of
  7. the GPL2 ("Copyleft").
  8. Contact information
  9. -------------------
  10. Circuits At Home, LTD
  11. Web : http://www.circuitsathome.com
  12. e-mail : [email protected]
  13. */
  14. #if !defined(_usb_h_) || defined(__MESSAGE_H__)
  15. #error "Never include message.h directly; include Usb.h instead"
  16. #else
  17. #define __MESSAGE_H__
  18. extern int UsbDEBUGlvl;
  19. void E_Notify(char const * msg, int lvl);
  20. void E_Notify(uint8_t b, int lvl);
  21. void E_NotifyStr(char const * msg, int lvl);
  22. void E_Notifyc(char c, int lvl);
  23. #ifdef DEBUG_USB_HOST
  24. #define Notify E_Notify
  25. #define NotifyStr E_NotifyStr
  26. #define Notifyc E_Notifyc
  27. void NotifyFailGetDevDescr(uint8_t reason);
  28. void NotifyFailSetDevTblEntry(uint8_t reason);
  29. void NotifyFailGetConfDescr(uint8_t reason);
  30. void NotifyFailSetConfDescr(uint8_t reason);
  31. void NotifyFailGetDevDescr(void);
  32. void NotifyFailSetDevTblEntry(void);
  33. void NotifyFailGetConfDescr(void);
  34. void NotifyFailSetConfDescr(void);
  35. void NotifyFailUnknownDevice(uint16_t VID, uint16_t PID);
  36. void NotifyFail(uint8_t rcode);
  37. #else
  38. #define Notify(...) ((void)0)
  39. #define NotifyStr(...) ((void)0)
  40. #define Notifyc(...) ((void)0)
  41. #define NotifyFailGetDevDescr(...) ((void)0)
  42. #define NotifyFailSetDevTblEntry(...) ((void)0)
  43. #define NotifyFailGetConfDescr(...) ((void)0)
  44. #define NotifyFailGetDevDescr(...) ((void)0)
  45. #define NotifyFailSetDevTblEntry(...) ((void)0)
  46. #define NotifyFailGetConfDescr(...) ((void)0)
  47. #define NotifyFailSetConfDescr(...) ((void)0)
  48. #define NotifyFailUnknownDevice(...) ((void)0)
  49. #define NotifyFail(...) ((void)0)
  50. #endif
  51. template <class ERROR_TYPE>
  52. void ErrorMessage(uint8_t level, char const * msg, ERROR_TYPE rcode = 0) {
  53. #ifdef DEBUG_USB_HOST
  54. Notify(msg, level);
  55. Notify(PSTR(": "), level);
  56. D_PrintHex<ERROR_TYPE > (rcode, level);
  57. Notify(PSTR("\r\n"), level);
  58. #endif
  59. }
  60. template <class ERROR_TYPE>
  61. void ErrorMessage(char const * msg, ERROR_TYPE rcode = 0) {
  62. #ifdef DEBUG_USB_HOST
  63. Notify(msg, 0x80);
  64. Notify(PSTR(": "), 0x80);
  65. D_PrintHex<ERROR_TYPE > (rcode, 0x80);
  66. Notify(PSTR("\r\n"), 0x80);
  67. #endif
  68. }
  69. #endif // __MESSAGE_H__