USB Host Shield 2.0
message.h
Go to the documentation of this file.
1 /* Copyright (C) 2011 Circuits At Home, LTD. All rights reserved.
2 
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License as published by
5 the Free Software Foundation; either version 2 of the License, or
6 (at your option) any later version.
7 
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
12 
13 You should have received a copy of the GNU General Public License
14 along with this program; if not, write to the Free Software
15 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 
17 Contact information
18 -------------------
19 
20 Circuits At Home, LTD
21 Web : http://www.circuitsathome.com
22 e-mail : support@circuitsathome.com
23  */
24 #if !defined(_usb_h_) || defined(__MESSAGE_H__)
25 #error "Never include message.h directly; include Usb.h instead"
26 #else
27 #define __MESSAGE_H__
28 
29 extern int UsbDEBUGlvl;
30 
31 void E_Notify(char const * msg, int lvl);
32 void E_Notify(uint8_t b, int lvl);
33 void E_NotifyStr(char const * msg, int lvl);
34 void E_Notifyc(char c, int lvl);
35 
36 #ifdef DEBUG_USB_HOST
37 #define Notify E_Notify
38 #define NotifyStr E_NotifyStr
39 #define Notifyc E_Notifyc
40 void NotifyFailGetDevDescr(uint8_t reason);
41 void NotifyFailSetDevTblEntry(uint8_t reason);
42 void NotifyFailGetConfDescr(uint8_t reason);
43 void NotifyFailSetConfDescr(uint8_t reason);
44 void NotifyFailGetDevDescr(void);
45 void NotifyFailSetDevTblEntry(void);
46 void NotifyFailGetConfDescr(void);
47 void NotifyFailSetConfDescr(void);
48 void NotifyFailUnknownDevice(uint16_t VID, uint16_t PID);
49 void NotifyFail(uint8_t rcode);
50 #else
51 #define Notify(...) ((void)0)
52 #define NotifyStr(...) ((void)0)
53 #define Notifyc(...) ((void)0)
54 #define NotifyFailGetDevDescr(...) ((void)0)
55 #define NotifyFailSetDevTblEntry(...) ((void)0)
56 #define NotifyFailGetConfDescr(...) ((void)0)
57 #define NotifyFailGetDevDescr(...) ((void)0)
58 #define NotifyFailSetDevTblEntry(...) ((void)0)
59 #define NotifyFailGetConfDescr(...) ((void)0)
60 #define NotifyFailSetConfDescr(...) ((void)0)
61 #define NotifyFailUnknownDevice(...) ((void)0)
62 #define NotifyFail(...) ((void)0)
63 #endif
64 
65 template <class ERROR_TYPE>
66 void ErrorMessage(uint8_t level, char const * msg, ERROR_TYPE rcode = 0) {
67 #ifdef DEBUG_USB_HOST
68  Notify(msg, level);
69  Notify(PSTR(": "), level);
70  D_PrintHex<ERROR_TYPE > (rcode, level);
71  Notify(PSTR("\r\n"), level);
72 #endif
73 }
74 
75 template <class ERROR_TYPE>
76 void ErrorMessage(char const * msg __attribute__((unused)), ERROR_TYPE rcode __attribute__((unused)) = 0) {
77 #ifdef DEBUG_USB_HOST
78  Notify(msg, 0x80);
79  Notify(PSTR(": "), 0x80);
80  D_PrintHex<ERROR_TYPE > (rcode, 0x80);
81  Notify(PSTR("\r\n"), 0x80);
82 #endif
83 }
84 
85 #endif // __MESSAGE_H__
#define NotifyFailSetConfDescr(...)
Definition: message.h:60
#define NotifyFailUnknownDevice(...)
Definition: message.h:61
#define NotifyFail(...)
Definition: message.h:62
int UsbDEBUGlvl
Definition: message.cpp:29
#define Notify(...)
Definition: message.h:51
#define NotifyFailGetConfDescr(...)
Definition: message.h:59
void E_NotifyStr(char const *msg, int lvl)
Definition: message.cpp:49
void ErrorMessage(uint8_t level, char const *msg, ERROR_TYPE rcode=0)
Definition: message.h:66
#define NotifyFailSetDevTblEntry(...)
Definition: message.h:58
void E_Notify(char const *msg, int lvl)
Definition: message.cpp:41
void E_Notifyc(char c, int lvl)
Definition: message.cpp:31
#define NotifyFailGetDevDescr(...)
Definition: message.h:57
#define PSTR(str)