USB Host Shield 2.0
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
message.h
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 #if !defined(__MESSAGE_H__)
18 #define __MESSAGE_H__
19 
20 // uncomment to activate
21 #define DEBUG_USB_HOST
22 
23 
24 #ifndef USB_HOST_SERIAL
25 #define USB_HOST_SERIAL Serial
26 #endif
27 
28 #include <inttypes.h>
29 #include <avr/pgmspace.h>
30 
31 extern int UsbDEBUGlvl;
32 
33 #include "printhex.h"
34 void E_Notify(char const * msg, int lvl);
35 void E_Notify(uint8_t b, int lvl);
36 void E_NotifyStr(char const * msg, int lvl);
37 void E_Notifyc(char c, int lvl);
38 
39 #ifdef DEBUG_USB_HOST
40 #define Notify E_Notify
41 #define NotifyStr E_NotifyStr
42 #define Notifyc E_Notifyc
43 void NotifyFailGetDevDescr(uint8_t reason);
44 void NotifyFailSetDevTblEntry(uint8_t reason);
45 void NotifyFailGetConfDescr(uint8_t reason);
46 void NotifyFailGetDevDescr(void);
47 void NotifyFailSetDevTblEntry(void);
48 void NotifyFailGetConfDescr(void);
49 void NotifyFailSetConfDescr(void);
50 void NotifyFailUnknownDevice(uint16_t VID, uint16_t PID);
51 void NotifyFail(uint8_t rcode);
52 #else
53 #define Notify(...) ((void)0)
54 #define NotifyStr(...) ((void)0)
55 #define Notifyc(...) ((void)0)
56 #define NotifyFailGetDevDescr(...) ((void)0)
57 #define NotifyFailSetDevTblEntry(...) ((void)0)
58 #define NotifyFailGetConfDescr(...) ((void)0)
59 #define NotifyFailGetDevDescr(...) ((void)0)
60 #define NotifyFailSetDevTblEntry(...) ((void)0)
61 #define NotifyFailGetConfDescr(...) ((void)0)
62 #define NotifyFailSetConfDescr(...) ((void)0)
63 #define NotifyFailUnknownDevice(...) ((void)0)
64 #define NotifyFail(...) ((void)0)
65 #endif
66 
67 template <class ERROR_TYPE>
68 void ErrorMessage(uint8_t level, char const * msg, ERROR_TYPE rcode = 0) {
69 #ifdef DEBUG_USB_HOST
70  Notify(msg, level);
71  Notify(PSTR(": "), level);
72  D_PrintHex<ERROR_TYPE > (rcode, level);
73  Notify(PSTR("\r\n"), level);
74 #endif
75 }
76 
77 template <class ERROR_TYPE>
78 void ErrorMessage(char const * msg, ERROR_TYPE rcode = 0) {
79 #ifdef DEBUG_USB_HOST
80  Notify(msg, 0x80);
81  Notify(PSTR(": "), 0x80);
82  D_PrintHex<ERROR_TYPE > (rcode, 0x80);
83  Notify(PSTR("\r\n"), 0x80);
84 #endif
85 }
86 
87 #include "hexdump.h"
88 
89 #endif // __MESSAGE_H__