USB Host Shield 2.0
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
message.cpp
Go to the documentation of this file.
1 /* Copyright (C) 2011 Circuits At Home, LTD. All rights reserved.
2 
3 This software may be distributed and modified under the terms of the GNU
4 General Public License version 2 (GPL2) as published by the Free Software
5 Foundation and appearing in the file GPL2.TXT included in the packaging of
6 this file. Please note that GPL2 Section 2[b] requires that all works based
7 on this software must also be made publicly available under the terms of
8 the GPL2 ("Copyleft").
9 
10 Contact information
11 -------------------
12 
13 Circuits At Home, LTD
14 Web : http://www.circuitsathome.com
15 e-mail : support@circuitsathome.com
16  */
17 
18 #include "Usb.h"
19 // 0x80 is the default (i.e. trace) to turn off set this global to something lower.
20 // this allows for 126 other debugging levels.
21 // TO-DO: Allow assignment to a different serial port
22 int UsbDEBUGlvl = 0x80;
23 
24 void E_Notifyc(char c, int lvl) {
25  if (UsbDEBUGlvl < lvl) return;
26 #if defined(ARDUINO) && ARDUINO >=100
27  USB_HOST_SERIAL.print(c);
28 #else
29  USB_HOST_SERIAL.print(c, BYTE);
30 #endif
31  //USB_HOST_SERIAL.flush();
32 }
33 
34 void E_Notify(char const * msg, int lvl) {
35  if (UsbDEBUGlvl < lvl) return;
36  if (!msg) return;
37  char c;
38 
39  while ((c = pgm_read_byte(msg++))) E_Notifyc(c, lvl);
40 }
41 
42 void E_NotifyStr(char const * msg, int lvl) {
43  if (UsbDEBUGlvl < lvl) return;
44  if (!msg) return;
45  char c;
46 
47  while (c = *msg++) E_Notifyc(c, lvl);
48 }
49 
50 void E_Notify(uint8_t b, int lvl) {
51  if (UsbDEBUGlvl < lvl) return;
52 #if defined(ARDUINO) && ARDUINO >=100
53  USB_HOST_SERIAL.print(b);
54 #else
55  USB_HOST_SERIAL.print(b, DEC);
56 #endif
57  //USB_HOST_SERIAL.flush();
58 }
59 
60 void E_Notify(double d, int lvl) {
61  if (UsbDEBUGlvl < lvl) return;
62  USB_HOST_SERIAL.print(d);
63  //USB_HOST_SERIAL.flush();
64 }
65 
66 #ifdef DEBUG_USB_HOST
67 void NotifyFailGetDevDescr(void) {
68  Notify(PSTR("\r\ngetDevDescr "), 0x80);
69 }
70 
71 void NotifyFailSetDevTblEntry(void) {
72  Notify(PSTR("\r\nsetDevTblEn "), 0x80);
73 }
74 void NotifyFailGetConfDescr(void) {
75  Notify(PSTR("\r\ngetConf "), 0x80);
76 }
77 
78 void NotifyFailSetConfDescr(void) {
79  Notify(PSTR("\r\nsetConf "), 0x80);
80 }
81 
82 void NotifyFailGetDevDescr(uint8_t reason) {
84  NotifyFail(reason);
85 }
86 
87 void NotifyFailSetDevTblEntry(uint8_t reason) {
89  NotifyFail(reason);
90 
91 }
92 
93 void NotifyFailGetConfDescr(uint8_t reason) {
95  NotifyFail(reason);
96 }
97 
98 void NotifyFailSetConfDescr(uint8_t reason) {
100  NotifyFail(reason);
101 }
102 
103 void NotifyFailUnknownDevice(uint16_t VID, uint16_t PID) {
104  Notify(PSTR("\r\nUnknown Device Connected - VID: "), 0x80);
105  D_PrintHex<uint16_t > (VID, 0x80);
106  Notify(PSTR(" PID: "), 0x80);
107  D_PrintHex<uint16_t > (PID, 0x80);
108 }
109 
110 void NotifyFail(uint8_t rcode) {
111  D_PrintHex<uint8_t > (rcode, 0x80);
112  Notify(PSTR("\r\n"), 0x80);
113 }
114 #endif
void E_NotifyStr(char const *msg, int lvl)
Definition: message.cpp:42
#define NotifyFail(...)
Definition: message.h:55
#define NotifyFailGetDevDescr(...)
Definition: message.h:50
int UsbDEBUGlvl
Definition: message.cpp:22
void E_Notifyc(char c, int lvl)
Definition: message.cpp:24
#define Notify(...)
Definition: message.h:44
#define USB_HOST_SERIAL
Definition: settings.h:24
#define NotifyFailGetConfDescr(...)
Definition: message.h:52
#define NotifyFailUnknownDevice(...)
Definition: message.h:54
void E_Notify(char const *msg, int lvl)
Definition: message.cpp:34
#define NotifyFailSetConfDescr(...)
Definition: message.h:53
#define NotifyFailSetDevTblEntry(...)
Definition: message.h:51