Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.
Repozitorijs ir arhivēts. Tam var aplūkot failus un to var klonēt, bet nevar iesūtīt jaunas izmaiņas, kā arī atvērt jaunas problēmas/izmaiņu pieprasījumus.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  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. #include "Usb.h"
  15. // 0x80 is the default (i.e. trace) to turn off set this global to something lower.
  16. // this allows for 126 other debugging levels.
  17. // TO-DO: Allow assignment to a different serial port by software
  18. int UsbDEBUGlvl = 0x80;
  19. void E_Notifyc(char c, int lvl) {
  20. if(UsbDEBUGlvl < lvl) return;
  21. #if defined(ARDUINO) && ARDUINO >=100
  22. USB_HOST_SERIAL.print(c);
  23. #else
  24. USB_HOST_SERIAL.print(c, BYTE);
  25. #endif
  26. //USB_HOST_SERIAL.flush();
  27. }
  28. void E_Notify(char const * msg, int lvl) {
  29. if(UsbDEBUGlvl < lvl) return;
  30. if(!msg) return;
  31. char c;
  32. while((c = pgm_read_byte(msg++))) E_Notifyc(c, lvl);
  33. }
  34. void E_NotifyStr(char const * msg, int lvl) {
  35. if(UsbDEBUGlvl < lvl) return;
  36. if(!msg) return;
  37. char c;
  38. while((c = *msg++)) E_Notifyc(c, lvl);
  39. }
  40. void E_Notify(uint8_t b, int lvl) {
  41. if(UsbDEBUGlvl < lvl) return;
  42. #if defined(ARDUINO) && ARDUINO >=100
  43. USB_HOST_SERIAL.print(b);
  44. #else
  45. USB_HOST_SERIAL.print(b, DEC);
  46. #endif
  47. //USB_HOST_SERIAL.flush();
  48. }
  49. void E_Notify(double d, int lvl) {
  50. if(UsbDEBUGlvl < lvl) return;
  51. USB_HOST_SERIAL.print(d);
  52. //USB_HOST_SERIAL.flush();
  53. }
  54. #ifdef DEBUG_USB_HOST
  55. void NotifyFailGetDevDescr(void) {
  56. Notify(PSTR("\r\ngetDevDescr "), 0x80);
  57. }
  58. void NotifyFailSetDevTblEntry(void) {
  59. Notify(PSTR("\r\nsetDevTblEn "), 0x80);
  60. }
  61. void NotifyFailGetConfDescr(void) {
  62. Notify(PSTR("\r\ngetConf "), 0x80);
  63. }
  64. void NotifyFailSetConfDescr(void) {
  65. Notify(PSTR("\r\nsetConf "), 0x80);
  66. }
  67. void NotifyFailGetDevDescr(uint8_t reason) {
  68. NotifyFailGetDevDescr();
  69. NotifyFail(reason);
  70. }
  71. void NotifyFailSetDevTblEntry(uint8_t reason) {
  72. NotifyFailSetDevTblEntry();
  73. NotifyFail(reason);
  74. }
  75. void NotifyFailGetConfDescr(uint8_t reason) {
  76. NotifyFailGetConfDescr();
  77. NotifyFail(reason);
  78. }
  79. void NotifyFailSetConfDescr(uint8_t reason) {
  80. NotifyFailSetConfDescr();
  81. NotifyFail(reason);
  82. }
  83. void NotifyFailUnknownDevice(uint16_t VID, uint16_t PID) {
  84. Notify(PSTR("\r\nUnknown Device Connected - VID: "), 0x80);
  85. D_PrintHex<uint16_t > (VID, 0x80);
  86. Notify(PSTR(" PID: "), 0x80);
  87. D_PrintHex<uint16_t > (PID, 0x80);
  88. }
  89. void NotifyFail(uint8_t rcode) {
  90. D_PrintHex<uint8_t > (rcode, 0x80);
  91. Notify(PSTR("\r\n"), 0x80);
  92. }
  93. #endif