USB Host Shield 2.0
Loading...
Searching...
No Matches
message.cpp
Go to the documentation of this file.
1/* Copyright (C) 2011 Circuits At Home, LTD. All rights reserved.
2
3This program is free software; you can redistribute it and/or modify
4it under the terms of the GNU General Public License as published by
5the Free Software Foundation; either version 2 of the License, or
6(at your option) any later version.
7
8This program is distributed in the hope that it will be useful,
9but WITHOUT ANY WARRANTY; without even the implied warranty of
10MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11GNU General Public License for more details.
12
13You should have received a copy of the GNU General Public License
14along with this program; if not, write to the Free Software
15Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16
17Contact information
18-------------------
19
20Circuits At Home, LTD
21Web : http://www.circuitsathome.com
22e-mail : support@circuitsathome.com
23 */
24
25#include "Usb.h"
26// 0x80 is the default (i.e. trace) to turn off set this global to something lower.
27// this allows for 126 other debugging levels.
28// TO-DO: Allow assignment to a different serial port by software
29int UsbDEBUGlvl = 0x80;
30
31void E_Notifyc(char c, int lvl) {
32 if(UsbDEBUGlvl < lvl) return;
33#if defined(ARDUINO) && ARDUINO >=100
34 USB_HOST_SERIAL.print(c);
35#else
36 USB_HOST_SERIAL.print(c, BYTE);
37#endif
38 //USB_HOST_SERIAL.flush();
39}
40
41void E_Notify(char const * msg, int lvl) {
42 if(UsbDEBUGlvl < lvl) return;
43 if(!msg) return;
44 char c;
45
46 while((c = pgm_read_byte(msg++))) E_Notifyc(c, lvl);
47}
48
49void E_NotifyStr(char const * msg, int lvl) {
50 if(UsbDEBUGlvl < lvl) return;
51 if(!msg) return;
52 char c;
53
54 while((c = *msg++)) E_Notifyc(c, lvl);
55}
56
57void E_Notify(uint8_t b, int lvl) {
58 if(UsbDEBUGlvl < lvl) return;
59#if defined(ARDUINO) && ARDUINO >=100
60 USB_HOST_SERIAL.print(b);
61#else
62 USB_HOST_SERIAL.print(b, DEC);
63#endif
64 //USB_HOST_SERIAL.flush();
65}
66
67void E_Notify(double d, int lvl) {
68 if(UsbDEBUGlvl < lvl) return;
69 USB_HOST_SERIAL.print(d);
70 //USB_HOST_SERIAL.flush();
71}
72
73#ifdef DEBUG_USB_HOST
74
75void NotifyFailGetDevDescr(void) {
76 Notify(PSTR("\r\ngetDevDescr "), 0x80);
77}
78
79void NotifyFailSetDevTblEntry(void) {
80 Notify(PSTR("\r\nsetDevTblEn "), 0x80);
81}
82
83void NotifyFailGetConfDescr(void) {
84 Notify(PSTR("\r\ngetConf "), 0x80);
85}
86
87void NotifyFailSetConfDescr(void) {
88 Notify(PSTR("\r\nsetConf "), 0x80);
89}
90
94}
95
99
100}
101
105}
106
110}
111
113 Notify(PSTR("\r\nUnknown Device Connected - VID: "), 0x80);
114 D_PrintHex<uint16_t > (VID, 0x80);
115 Notify(PSTR(" PID: "), 0x80);
116 D_PrintHex<uint16_t > (PID, 0x80);
117}
118
121 Notify(PSTR("\r\n"), 0x80);
122}
123#endif
int UsbDEBUGlvl
Definition message.cpp:29
void E_NotifyStr(char const *msg, int lvl)
Definition message.cpp:49
void E_Notify(char const *msg, int lvl)
Definition message.cpp:41
void E_Notifyc(char c, int lvl)
Definition message.cpp:31
#define NotifyFailSetConfDescr(...)
Definition message.h:60
#define NotifyFailUnknownDevice(...)
Definition message.h:61
#define NotifyFail(...)
Definition message.h:62
#define Notify(...)
Definition message.h:51
#define NotifyFailGetConfDescr(...)
Definition message.h:56
#define NotifyFailSetDevTblEntry(...)
Definition message.h:55
#define NotifyFailGetDevDescr(...)
Definition message.h:54
#define USB_HOST_SERIAL
Definition settings.h:49
#define pgm_read_byte(addr)
#define PSTR(str)