aboutsummaryrefslogtreecommitdiff
path: root/lib/usbhost/USB_Host_Shield_2.0/message.cpp
diff options
context:
space:
mode:
authorRyan <fauxpark@gmail.com>2021-08-18 18:20:25 +1000
committerGitHub <noreply@github.com>2021-08-18 18:20:25 +1000
commitb16091659cc9a724a8800f77e631643b4ab089ad (patch)
treee44933472c6d100bd4fc5d8a693d9d21e3c32f6f /lib/usbhost/USB_Host_Shield_2.0/message.cpp
parentcf5e40c25139ff64ff246f1c6280e983ef75551c (diff)
downloadqmk_firmware-b16091659cc9a724a8800f77e631643b4ab089ad.tar.gz
qmk_firmware-b16091659cc9a724a8800f77e631643b4ab089ad.zip
Move USB Host Shield and Arduino core to `lib/` (#13973)
Diffstat (limited to 'lib/usbhost/USB_Host_Shield_2.0/message.cpp')
-rw-r--r--lib/usbhost/USB_Host_Shield_2.0/message.cpp116
1 files changed, 116 insertions, 0 deletions
diff --git a/lib/usbhost/USB_Host_Shield_2.0/message.cpp b/lib/usbhost/USB_Host_Shield_2.0/message.cpp
new file mode 100644
index 000000000..bdcdd1833
--- /dev/null
+++ b/lib/usbhost/USB_Host_Shield_2.0/message.cpp
@@ -0,0 +1,116 @@
1/* Copyright (C) 2011 Circuits At Home, LTD. All rights reserved.
2
3This software may be distributed and modified under the terms of the GNU
4General Public License version 2 (GPL2) as published by the Free Software
5Foundation and appearing in the file GPL2.TXT included in the packaging of
6this file. Please note that GPL2 Section 2[b] requires that all works based
7on this software must also be made publicly available under the terms of
8the GPL2 ("Copyleft").
9
10Contact information
11-------------------
12
13Circuits At Home, LTD
14Web : http://www.circuitsathome.com
15e-mail : support@circuitsathome.com
16 */
17
18#include "Usb.h"
19// 0x80 is the default (i.e. trace) to turn off set this global to something lower.
20// this allows for 126 other debugging levels.
21// TO-DO: Allow assignment to a different serial port by software
22int UsbDEBUGlvl = 0x80;
23
24void E_Notifyc(char c, int lvl) {
25 if(UsbDEBUGlvl < lvl) return;
26#if defined(ARDUINO) && ARDUINO >=100
27 USB_HOST_SERIAL.print(c);
28#else
29 USB_HOST_SERIAL.print(c, BYTE);
30#endif
31 //USB_HOST_SERIAL.flush();
32}
33
34void E_Notify(char const * msg, int lvl) {
35 if(UsbDEBUGlvl < lvl) return;
36 if(!msg) return;
37 char c;
38
39 while((c = pgm_read_byte(msg++))) E_Notifyc(c, lvl);
40}
41
42void E_NotifyStr(char const * msg, int lvl) {
43 if(UsbDEBUGlvl < lvl) return;
44 if(!msg) return;
45 char c;
46
47 while((c = *msg++)) E_Notifyc(c, lvl);
48}
49
50void E_Notify(uint8_t b, int lvl) {
51 if(UsbDEBUGlvl < lvl) return;
52#if defined(ARDUINO) && ARDUINO >=100
53 USB_HOST_SERIAL.print(b);
54#else
55 USB_HOST_SERIAL.print(b, DEC);
56#endif
57 //USB_HOST_SERIAL.flush();
58}
59
60void E_Notify(double d, int lvl) {
61 if(UsbDEBUGlvl < lvl) return;
62 USB_HOST_SERIAL.print(d);
63 //USB_HOST_SERIAL.flush();
64}
65
66#ifdef DEBUG_USB_HOST
67
68void NotifyFailGetDevDescr(void) {
69 Notify(PSTR("\r\ngetDevDescr "), 0x80);
70}
71
72void NotifyFailSetDevTblEntry(void) {
73 Notify(PSTR("\r\nsetDevTblEn "), 0x80);
74}
75
76void NotifyFailGetConfDescr(void) {
77 Notify(PSTR("\r\ngetConf "), 0x80);
78}
79
80void NotifyFailSetConfDescr(void) {
81 Notify(PSTR("\r\nsetConf "), 0x80);
82}
83
84void NotifyFailGetDevDescr(uint8_t reason) {
85 NotifyFailGetDevDescr();
86 NotifyFail(reason);
87}
88
89void NotifyFailSetDevTblEntry(uint8_t reason) {
90 NotifyFailSetDevTblEntry();
91 NotifyFail(reason);
92
93}
94
95void NotifyFailGetConfDescr(uint8_t reason) {
96 NotifyFailGetConfDescr();
97 NotifyFail(reason);
98}
99
100void NotifyFailSetConfDescr(uint8_t reason) {
101 NotifyFailSetConfDescr();
102 NotifyFail(reason);
103}
104
105void NotifyFailUnknownDevice(uint16_t VID, uint16_t PID) {
106 Notify(PSTR("\r\nUnknown Device Connected - VID: "), 0x80);
107 D_PrintHex<uint16_t > (VID, 0x80);
108 Notify(PSTR(" PID: "), 0x80);
109 D_PrintHex<uint16_t > (PID, 0x80);
110}
111
112void NotifyFail(uint8_t rcode) {
113 D_PrintHex<uint8_t > (rcode, 0x80);
114 Notify(PSTR("\r\n"), 0x80);
115}
116#endif