Zoltan Hudak / UsbHostMAX3421E

Dependents:   UsbHostMAX3421E_Hello

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers message.h Source File

message.h

00001 /* Copyright (C) 2011 Circuits At Home, LTD. All rights reserved.
00002 
00003 This program is free software; you can redistribute it and/or modify
00004 it under the terms of the GNU General Public License as published by
00005 the Free Software Foundation; either version 2 of the License, or
00006 (at your option) any later version.
00007 
00008 This program is distributed in the hope that it will be useful,
00009 but WITHOUT ANY WARRANTY; without even the implied warranty of
00010 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00011 GNU General Public License for more details.
00012 
00013 You should have received a copy of the GNU General Public License
00014 along with this program; if not, write to the Free Software
00015 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00016 
00017 Contact information
00018 -------------------
00019 
00020 Circuits At Home, LTD
00021 Web      :  http://www.circuitsathome.com
00022 e-mail   :  support@circuitsathome.com
00023  */
00024 #if !defined(_usb_h_) || defined(__MESSAGE_H__)
00025 #error "Never include message.h directly; include Usb.h instead"
00026 #else
00027 #define __MESSAGE_H__
00028 
00029 extern int UsbDEBUGlvl;
00030 
00031 void E_Notify(char const * msg, int lvl);
00032 void E_Notify(uint8_t b, int lvl);
00033 void E_NotifyStr(char const * msg, int lvl);
00034 void E_Notifyc(char c, int lvl);
00035 
00036 #ifdef DEBUG_USB_HOST
00037 #define Notify E_Notify
00038 #define NotifyStr E_NotifyStr
00039 #define Notifyc E_Notifyc
00040 void NotifyFailGetDevDescr(uint8_t reason);
00041 void NotifyFailSetDevTblEntry(uint8_t reason);
00042 void NotifyFailGetConfDescr(uint8_t reason);
00043 void NotifyFailSetConfDescr(uint8_t reason);
00044 void NotifyFailGetDevDescr(void);
00045 void NotifyFailSetDevTblEntry(void);
00046 void NotifyFailGetConfDescr(void);
00047 void NotifyFailSetConfDescr(void);
00048 void NotifyFailUnknownDevice(uint16_t VID, uint16_t PID);
00049 void NotifyFail(uint8_t rcode);
00050 #else
00051 #define Notify(...) ((void)0)
00052 #define NotifyStr(...) ((void)0)
00053 #define Notifyc(...) ((void)0)
00054 #define NotifyFailGetDevDescr(...) ((void)0)
00055 #define NotifyFailSetDevTblEntry(...) ((void)0)
00056 #define NotifyFailGetConfDescr(...) ((void)0)
00057 #define NotifyFailGetDevDescr(...) ((void)0)
00058 #define NotifyFailSetDevTblEntry(...) ((void)0)
00059 #define NotifyFailGetConfDescr(...) ((void)0)
00060 #define NotifyFailSetConfDescr(...) ((void)0)
00061 #define NotifyFailUnknownDevice(...) ((void)0)
00062 #define NotifyFail(...) ((void)0)
00063 #endif
00064 
00065 template <class ERROR_TYPE>
00066 void ErrorMessage(uint8_t level, char const * msg, ERROR_TYPE rcode = 0) {
00067 #ifdef DEBUG_USB_HOST
00068         Notify(msg, level);
00069         Notify(PSTR(": "), level);
00070         D_PrintHex<ERROR_TYPE > (rcode, level);
00071         Notify(PSTR("\r\n"), level);
00072 #endif
00073 }
00074 
00075 template <class ERROR_TYPE>
00076 void ErrorMessage(char const * msg __attribute__((unused)), ERROR_TYPE rcode __attribute__((unused)) = 0) {
00077 #ifdef DEBUG_USB_HOST
00078         Notify(msg, 0x80);
00079         Notify(PSTR(": "), 0x80);
00080         D_PrintHex<ERROR_TYPE > (rcode, 0x80);
00081         Notify(PSTR("\r\n"), 0x80);
00082 #endif
00083 }
00084 
00085 #endif // __MESSAGE_H__