Prusa MINI Firmware overview
message.h
Go to the documentation of this file.
1 /**
2  * Copyright (C) 2011 Circuits At Home, LTD. All rights reserved.
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  *
18  * Contact information
19  * -------------------
20  *
21  * Circuits At Home, LTD
22  * Web : http://www.circuitsathome.com
23  * e-mail : support@circuitsathome.com
24  */
25 #pragma once
26 
27 #ifndef _usb_h_
28  #error "Never include message.h directly; include Usb.h instead"
29 #endif
30 
31 extern int UsbDEBUGlvl;
32 
33 void E_Notify(char const * msg, int lvl);
34 void E_Notify(uint8_t b, int lvl);
35 void E_NotifyStr(char const * msg, int lvl);
36 void E_Notifyc(char c, int lvl);
37 
38 #ifdef DEBUG_USB_HOST
39  #define Notify E_Notify
40  #define NotifyStr E_NotifyStr
41  #define Notifyc E_Notifyc
42  void NotifyFailGetDevDescr(uint8_t reason);
43  void NotifyFailSetDevTblEntry(uint8_t reason);
44  void NotifyFailGetConfDescr(uint8_t reason);
45  void NotifyFailSetConfDescr(uint8_t reason);
46  void NotifyFailGetDevDescr();
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 __attribute__((unused)), ERROR_TYPE rcode __attribute__((unused)) = 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 }
NotifyFail
#define NotifyFail(...)
Definition: message.h:64
NotifyFailSetDevTblEntry
#define NotifyFailSetDevTblEntry(...)
Definition: message.h:60
USB_HOST_SERIAL
#define USB_HOST_SERIAL
Definition: settings.h:73
__attribute__
bool boolean __attribute__((deprecated))
Definition: wiring_constants.h:110
NotifyFailGetConfDescr
#define NotifyFailGetConfDescr(...)
Definition: message.h:61
UsbDEBUGlvl
int UsbDEBUGlvl
E_Notifyc
void E_Notifyc(char c, int lvl)
Notify
#define Notify(...)
Definition: message.h:53
NotifyFailGetDevDescr
#define NotifyFailGetDevDescr(...)
Definition: message.h:59
E_NotifyStr
void E_NotifyStr(char const *msg, int lvl)
pgm_read_byte
#define pgm_read_byte(addr)
Definition: pgmspace.h:95
PSTR
#define PSTR(str)
Definition: pgmspace.h:31
NotifyFailUnknownDevice
#define NotifyFailUnknownDevice(...)
Definition: message.h:63
uint8_t
const uint8_t[]
Definition: 404_html.c:3
DEC
#define DEC
Definition: Print.h:29
BYTE
unsigned char BYTE
Definition: onboard_sd.h:13
ErrorMessage
void ErrorMessage(uint8_t level, char const *msg, ERROR_TYPE rcode=0)
Definition: message.h:68
Usb.h
NotifyFailSetConfDescr
#define NotifyFailSetConfDescr(...)
Definition: message.h:62
unused
unsigned unused
Definition: masstorage.h:51
UsbDEBUGlvl
int UsbDEBUGlvl
createSpeedLookupTable.b
list b
Definition: createSpeedLookupTable.py:30
E_Notify
void E_Notify(char const *msg, int lvl)