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 #include <inttypes.h>
21 #include <avr/pgmspace.h>
22 
23 extern int UsbDEBUGlvl;
24 
25 #include "printhex.h"
26 
27 void Notify(uint8_t b, int lvl);
28 void Notify(double d, int lvl);
29 void Notify(char const * msg, int lvl);
30 void NotifyStr(char const * msg, int lvl);
31 #ifdef DEBUG
32 void NotifyFailGetDevDescr(void);
33 void NotifyFailSetDevTblEntry(void);
34 void NotifyFailGetConfDescr(void);
35 void NotifyFailSetConfDescr(void);
36 void NotifyFailUnknownDevice(uint16_t VID, uint16_t PID);
37 void NotifyFail(uint8_t rcode);
38 #else
39 #define NotifyFailGetDevDescr()
40 #define NotifyFailSetDevTblEntry()
41 #define NotifyFailGetConfDescr()
42 #define NotifyFailSetConfDescr()
43 #define NotifyFailUnknownDevice(VID, PID)
44 #define NotifyFail(rcode)
45 #endif
46 
47 template <class ERROR_TYPE>
48 void ErrorMessage(char const * msg, ERROR_TYPE rcode = 0) {
49  Notify(msg, 0x80);
50  Notify(PSTR(": "), 0x80);
51  PrintHex<ERROR_TYPE > (rcode, 0x80);
52  Notify(PSTR("\r\n"), 0x80);
53 }
54 
55 #include "hexdump.h"
56 
57 #endif // __MESSAGE_H__