1-
2-
31#include " Arduino.h"
42#include < usbhub.h>
53#include " wiring_constants.h"
64#include " pgmstrings.h"
7- // Satisfy IDE, which only needs to see the include statment in the ino.
8- #ifdef dobogusinclude
9- #include < spi4teensy3.h>
10- #endif
5+
6+
7+ // on a zero with debug port, use debug port
8+ // #define SerialDebug Serial
9+
10+ // on a feather or non-debug Zero, use Serial1 (since USB is taken!)
11+ #define SerialDebug Serial1
1112
1213USBHost usb;
13- // USBHub Hub1(&Usb);
14- // USBHub Hub2(&Usb);
15- // USBHub Hub3(&Usb);
16- // USBHub Hub4(&Usb);
17- // USBHub Hub5(&Usb);
18- // USBHub Hub6(&Usb);
19- // USBHub Hub7(&Usb);
2014
2115uint32_t next_time;
2216
@@ -33,39 +27,40 @@ void PrintAllAddresses(UsbDeviceDefinition *pdev)
3327{
3428 UsbDeviceAddress adr;
3529 adr.devAddress = pdev->address .devAddress ;
36- SERIAL_PORT_MONITOR .print (" \r\n Addr:" );
37- SERIAL_PORT_MONITOR .print (adr.devAddress , HEX);
38- SERIAL_PORT_MONITOR .print (" (" );
39- SERIAL_PORT_MONITOR .print (adr.bmHub , HEX);
40- SERIAL_PORT_MONITOR .print (" ." );
41- SERIAL_PORT_MONITOR .print (adr.bmParent , HEX);
42- SERIAL_PORT_MONITOR .print (" ." );
43- SERIAL_PORT_MONITOR .print (adr.bmAddress , HEX);
44- SERIAL_PORT_MONITOR .println (" )" );
30+ SerialDebug .print (" \r\n Addr:" );
31+ SerialDebug .print (adr.devAddress , HEX);
32+ SerialDebug .print (" (" );
33+ SerialDebug .print (adr.bmHub , HEX);
34+ SerialDebug .print (" ." );
35+ SerialDebug .print (adr.bmParent , HEX);
36+ SerialDebug .print (" ." );
37+ SerialDebug .print (adr.bmAddress , HEX);
38+ SerialDebug .println (" )" );
4539}
4640
4741void PrintAddress (uint8_t addr)
4842{
4943 UsbDeviceAddress adr;
5044 adr.devAddress = addr;
51- SERIAL_PORT_MONITOR .print (" \r\n ADDR:\t " );
52- SERIAL_PORT_MONITOR .println (adr.devAddress ,HEX);
53- SERIAL_PORT_MONITOR .print (" DEV:\t " );
54- SERIAL_PORT_MONITOR .println (adr.bmAddress ,HEX);
55- SERIAL_PORT_MONITOR .print (" PRNT:\t " );
56- SERIAL_PORT_MONITOR .println (adr.bmParent ,HEX);
57- SERIAL_PORT_MONITOR .print (" HUB:\t " );
58- SERIAL_PORT_MONITOR .println (adr.bmHub ,HEX);
45+ SerialDebug .print (" \r\n ADDR:\t " );
46+ SerialDebug .println (adr.devAddress ,HEX);
47+ SerialDebug .print (" DEV:\t " );
48+ SerialDebug .println (adr.bmAddress ,HEX);
49+ SerialDebug .print (" PRNT:\t " );
50+ SerialDebug .println (adr.bmParent ,HEX);
51+ SerialDebug .print (" HUB:\t " );
52+ SerialDebug .println (adr.bmHub ,HEX);
5953}
6054
6155void setup ()
6256{
63- SERIAL_PORT_MONITOR .begin ( 115200 );
64- while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection
65- SERIAL_PORT_MONITOR .println (" Start USB Desc " );
57+ Serial .begin (115200 );
58+ SerialDebug. begin ( 115200 );
59+ SerialDebug .println (" Starting USB Descriptor test " );
6660
61+ SerialDebug.println (" Initializing USB" );
6762 if (usb.Init () == -1 )
68- SERIAL_PORT_MONITOR .println (" OSC did not start." );
63+ SerialDebug .println (" USBhost did not start." );
6964
7065 delay ( 20 );
7166
@@ -85,7 +80,7 @@ void PrintDescriptors(uint8_t addr)
8580 printProgStr (Gen_Error_str);
8681 print_hex ( rcode, 8 );
8782 }
88- SERIAL_PORT_MONITOR .print (" \r\n " );
83+ SerialDebug .print (" \r\n " );
8984
9085 for (int i=0 ; i<num_conf; i++)
9186 {
@@ -95,15 +90,15 @@ void PrintDescriptors(uint8_t addr)
9590 printProgStr (Gen_Error_str);
9691 print_hex (rcode, 8 );
9792 }
98- SERIAL_PORT_MONITOR .println (" \r\n " );
93+ SerialDebug .println (" \r\n " );
9994 }
10095}
10196
10297void PrintAllDescriptors (UsbDeviceDefinition *pdev)
10398{
104- SERIAL_PORT_MONITOR .println (" \r\n " );
99+ SerialDebug .println (" \r\n " );
105100 print_hex (pdev->address .devAddress , 8 );
106- SERIAL_PORT_MONITOR .println (" \r\n --" );
101+ SerialDebug .println (" \r\n --" );
107102 PrintDescriptors ( pdev->address .devAddress );
108103}
109104
@@ -171,37 +166,37 @@ void printhubdescr(uint8_t *descrptr, uint8_t addr)
171166
172167 printProgStr (PSTR (" \r\n\r\n Hub Descriptor:\r\n " ));
173168 printProgStr (PSTR (" bDescLength:\t\t " ));
174- SERIAL_PORT_MONITOR .println (pHub->bDescLength , HEX);
169+ SerialDebug .println (pHub->bDescLength , HEX);
175170
176171 printProgStr (PSTR (" bDescriptorType:\t " ));
177- SERIAL_PORT_MONITOR .println (pHub->bDescriptorType , HEX);
172+ SerialDebug .println (pHub->bDescriptorType , HEX);
178173
179174 printProgStr (PSTR (" bNbrPorts:\t\t " ));
180- SERIAL_PORT_MONITOR .println (pHub->bNbrPorts , HEX);
175+ SerialDebug .println (pHub->bNbrPorts , HEX);
181176
182177 printProgStr (PSTR (" LogPwrSwitchMode:\t " ));
183- SERIAL_PORT_MONITOR .println (pHub->LogPwrSwitchMode , BIN);
178+ SerialDebug .println (pHub->LogPwrSwitchMode , BIN);
184179
185180 printProgStr (PSTR (" CompoundDevice:\t\t " ));
186- SERIAL_PORT_MONITOR .println (pHub->CompoundDevice , BIN);
181+ SerialDebug .println (pHub->CompoundDevice , BIN);
187182
188183 printProgStr (PSTR (" OverCurrentProtectMode:\t " ));
189- SERIAL_PORT_MONITOR .println (pHub->OverCurrentProtectMode , BIN);
184+ SerialDebug .println (pHub->OverCurrentProtectMode , BIN);
190185
191186 printProgStr (PSTR (" TTThinkTime:\t\t " ));
192- SERIAL_PORT_MONITOR .println (pHub->TTThinkTime , BIN);
187+ SerialDebug .println (pHub->TTThinkTime , BIN);
193188
194189 printProgStr (PSTR (" PortIndicatorsSupported:" ));
195- SERIAL_PORT_MONITOR .println (pHub->PortIndicatorsSupported , BIN);
190+ SerialDebug .println (pHub->PortIndicatorsSupported , BIN);
196191
197192 printProgStr (PSTR (" Reserved:\t\t " ));
198- SERIAL_PORT_MONITOR .println (pHub->Reserved , HEX);
193+ SerialDebug .println (pHub->Reserved , HEX);
199194
200195 printProgStr (PSTR (" bPwrOn2PwrGood:\t\t " ));
201- SERIAL_PORT_MONITOR .println (pHub->bPwrOn2PwrGood , HEX);
196+ SerialDebug .println (pHub->bPwrOn2PwrGood , HEX);
202197
203198 printProgStr (PSTR (" bHubContrCurrent:\t " ));
204- SERIAL_PORT_MONITOR .println (pHub->bHubContrCurrent , HEX);
199+ SerialDebug .println (pHub->bHubContrCurrent , HEX);
205200
206201 for (uint8_t i=7 ; i<len; i++)
207202 print_hex (descrptr[i], 8 );
@@ -271,7 +266,7 @@ void print_hex(int v, int num_places)
271266 }
272267 do {
273268 digit = ((v >> (num_nibbles-1 ) * 4 )) & 0x0f ;
274- SERIAL_PORT_MONITOR .print (digit, HEX);
269+ SerialDebug .print (digit, HEX);
275270 }
276271 while (--num_nibbles);
277272}
@@ -329,7 +324,7 @@ void printHIDdescr( uint8_t* descr_ptr )
329324 printProgStr (PSTR (" \r\n Numb Class Descriptor:\t " ));
330325 print_hex ( ep_ptr->bNumDescriptors , 8 );
331326 printProgStr (PSTR (" \r\n Descriptor Type:\t " ));
332- if ( ep_ptr->bDescrType == 0x22 )
327+ if ( ep_ptr->bDescrType == 0x22 )
333328 printProgStr (PSTR (" REPORT DESCRIPTOR" ));
334329 else
335330 print_hex ( ep_ptr->bDescrType , 8 );
@@ -386,5 +381,4 @@ void printProgStr(const prog_char str[])
386381 char c;
387382 if (!str) return ;
388383 while ((c = pgm_read_byte (str++)))
389- SERIAL_PORT_MONITOR.print (c);
390- }
384+ SerialDebug.print (c);
0 commit comments