Allow change of debug port

This commit is contained in:
Andrew J. Kroll 2013-06-10 14:55:44 -04:00
parent 3f7d052b2e
commit 3740adc947
12 changed files with 69 additions and 64 deletions

2
Usb.h
View file

@ -58,7 +58,7 @@ typedef MAX3421e<P20, P19> MAX3421E; // Balanduino
typedef MAX3421e<P10, P9> MAX3421E; // Official Arduinos (UNO, Duemilanove, Mega, 2560, Leonardo etc.)
#endif
//Debug macros. In 1.0 it is possible to move strings to PROGMEM by defining USBTRACE (Serial.print(F(s)))
//Debug macros. In 1.0 it is possible to move strings to PROGMEM by defining USBTRACE (USB_HOST_SERIAL.print(F(s)))
#define USBTRACE(s) (Notify(PSTR(s), 0x80))
#define USBTRACE2(s,r) (Notify(PSTR(s), 0x80), PrintHex((r), 0x80), Notify(PSTR("\r\n"), 0x80))

View file

@ -194,7 +194,7 @@ public:
virtual uint8_t AllocAddress(uint8_t parent, bool is_hub = false, uint8_t port = 0) {
/* if (parent != 0 && port == 0)
Serial.println("PRT:0"); */
USB_HOST_SERIAL.println("PRT:0"); */
if(parent > 127 || port > 7)
return 0;
@ -231,12 +231,12 @@ public:
}
thePool[index].address = *((uint8_t*) & addr);
/*
Serial.print("Addr:");
Serial.print(addr.bmHub, HEX);
Serial.print(".");
Serial.print(addr.bmParent, HEX);
Serial.print(".");
Serial.println(addr.bmAddress, HEX);
USB_HOST_SERIAL.print("Addr:");
USB_HOST_SERIAL.print(addr.bmHub, HEX);
USB_HOST_SERIAL.print(".");
USB_HOST_SERIAL.print(addr.bmParent, HEX);
USB_HOST_SERIAL.print(".");
USB_HOST_SERIAL.println(addr.bmAddress, HEX);
*/
return thePool[index].address;
};

View file

@ -288,7 +288,7 @@ uint8_t ACM::Poll() {
// for (uint8_t i=0; i<read; i++)
// {
// PrintHex<uint8_t>(buf[i]);
// Serial.print(" ");
// USB_HOST_SERIAL.print(" ");
// }
// USBTRACE("\r\n");
//}

View file

@ -259,7 +259,7 @@ uint8_t FTDI::Poll() {
//if (qNextPollTime <= millis())
//{
// Serial.println(bAddress, HEX);
// USB_HOST_SERIAL.println(bAddress, HEX);
// qNextPollTime = millis() + 100;
//}

View file

@ -200,7 +200,7 @@ Fail:
//
// //if (qNextPollTime <= millis())
// //{
// // Serial.println(bAddress, HEX);
// // USB_HOST_SERIAL.println(bAddress, HEX);
//
// // qNextPollTime = millis() + 100;
// //}

View file

@ -497,7 +497,7 @@ uint8_t HIDBoot<BOOT_PROTOCOL>::Poll() {
//for (uint8_t i=0; i<read; i++)
// PrintHex<uint8_t>(buf[i]);
//if (read)
// Serial.println("");
// USB_HOST_SERIAL.println("");
if(pRptParser)
pRptParser->Parse((HID*)this, 0, (uint8_t) read, buf);

View file

@ -981,9 +981,9 @@ void ReportDescParserBase::Parse(const uint16_t len, const uint8_t *pbuf, const
totalSize = 0;
while (cntdn) {
//Serial.println("");
//USB_HOST_SERIAL.println("");
//PrintHex<uint16_t>(offset + len - cntdn);
//Serial.print(":");
//USB_HOST_SERIAL.print(":");
ParseItem(&p, &cntdn);
@ -1267,7 +1267,7 @@ void ReportDescParserBase::PrintButtonPageUsage(uint16_t usage) {
Notify(PSTR("Btn"), 0x80);
PrintHex<uint16_t > (usage, 0x80);
Notify(PSTR("\r\n"), 0x80);
//Serial.print(usage, HEX);
//USB_HOST_SERIAL.print(usage, HEX);
}
void ReportDescParserBase::PrintOrdinalPageUsage(uint16_t usage) {
@ -1276,7 +1276,7 @@ void ReportDescParserBase::PrintOrdinalPageUsage(uint16_t usage) {
// Sorry, HEX for now...
PrintHex<uint16_t > (usage, 0x80);
Notify(PSTR("\r\n"), 0x80);
//Serial.print(usage, DEC);
//USB_HOST_SERIAL.print(usage, DEC);
}
void ReportDescParserBase::PrintGenericDesktopPageUsage(uint16_t usage) {

View file

@ -24,11 +24,11 @@ int UsbDEBUGlvl = 0x80;
void E_Notifyc(char c, int lvl) {
if (UsbDEBUGlvl < lvl) return;
#if defined(ARDUINO) && ARDUINO >=100
Serial.print(c);
USB_HOST_SERIAL.print(c);
#else
Serial.print(c, BYTE);
USB_HOST_SERIAL.print(c, BYTE);
#endif
Serial.flush();
USB_HOST_SERIAL.flush();
}
void E_Notify(char const * msg, int lvl) {
@ -50,17 +50,17 @@ void E_NotifyStr(char const * msg, int lvl) {
void E_Notify(uint8_t b, int lvl) {
if (UsbDEBUGlvl < lvl) return;
#if defined(ARDUINO) && ARDUINO >=100
Serial.print(b);
USB_HOST_SERIAL.print(b);
#else
Serial.print(b, DEC);
USB_HOST_SERIAL.print(b, DEC);
#endif
Serial.flush();
USB_HOST_SERIAL.flush();
}
void E_Notify(double d, int lvl) {
if (UsbDEBUGlvl < lvl) return;
Serial.print(d);
Serial.flush();
USB_HOST_SERIAL.print(d);
USB_HOST_SERIAL.flush();
}
#ifdef DEBUG_USB_HOST

View file

@ -20,6 +20,11 @@ e-mail : support@circuitsathome.com
// uncomment to activate
//#define DEBUG_USB_HOST
#ifndef USB_HOST_SERIAL
#define USB_HOST_SERIAL Serial
#endif
#include <inttypes.h>
#include <avr/pgmspace.h>

View file

@ -57,7 +57,7 @@ void SerialPrintHex(T val) {
do {
char v = 48 + (((val >> (num_nibbles - 1) * 4)) & 0x0f);
if(v > 57) v += 7;
Serial.print(v);
USB_HOST_SERIAL.print(v);
} while(--num_nibbles);
#endif
}

View file

@ -273,8 +273,8 @@ template< typename SS, typename INTR >
uint8_t MAX3421e< SS, INTR >::Task(void) {
uint8_t rcode = 0;
uint8_t pinvalue;
//Serial.print("Vbus state: ");
//Serial.println( vbusState, HEX );
//USB_HOST_SERIAL.print("Vbus state: ");
//USB_HOST_SERIAL.println( vbusState, HEX );
pinvalue = INTR::IsSet(); //Read();
//pinvalue = digitalRead( MAX_INT );
if(pinvalue == 0) {

View file

@ -247,8 +247,8 @@ uint8_t USBHub::CheckHubStatus() {
//rcode = GetHubStatus(1, 0, 1, 4, buf);
//if (rcode)
//{
// Serial.print("GetHubStatus Error");
// Serial.println(rcode, HEX);
// USB_HOST_SERIAL.print("GetHubStatus Error");
// USB_HOST_SERIAL.println(rcode, HEX);
// return rcode;
//}
}
@ -350,46 +350,46 @@ void PrintHubPortStatus(USBHub *hubptr, uint8_t addr, uint8_t port, bool print_c
rcode = hubptr->GetPortStatus(port, 4, evt.evtBuff);
if (rcode) {
Serial.println("ERROR!");
USB_HOST_SERIAL.println("ERROR!");
return;
}
Serial.print("\r\nPort ");
Serial.println(port, DEC);
USB_HOST_SERIAL.print("\r\nPort ");
USB_HOST_SERIAL.println(port, DEC);
Serial.println("Status");
Serial.print("CONNECTION:\t");
Serial.println((evt.bmStatus & bmHUB_PORT_STATUS_PORT_CONNECTION) > 0, DEC);
Serial.print("ENABLE:\t\t");
Serial.println((evt.bmStatus & bmHUB_PORT_STATUS_PORT_ENABLE) > 0, DEC);
Serial.print("SUSPEND:\t");
Serial.println((evt.bmStatus & bmHUB_PORT_STATUS_PORT_SUSPEND) > 0, DEC);
Serial.print("OVER_CURRENT:\t");
Serial.println((evt.bmStatus & bmHUB_PORT_STATUS_PORT_OVER_CURRENT) > 0, DEC);
Serial.print("RESET:\t\t");
Serial.println((evt.bmStatus & bmHUB_PORT_STATUS_PORT_RESET) > 0, DEC);
Serial.print("POWER:\t\t");
Serial.println((evt.bmStatus & bmHUB_PORT_STATUS_PORT_POWER) > 0, DEC);
Serial.print("LOW_SPEED:\t");
Serial.println((evt.bmStatus & bmHUB_PORT_STATUS_PORT_LOW_SPEED) > 0, DEC);
Serial.print("HIGH_SPEED:\t");
Serial.println((evt.bmStatus & bmHUB_PORT_STATUS_PORT_HIGH_SPEED) > 0, DEC);
Serial.print("TEST:\t\t");
Serial.println((evt.bmStatus & bmHUB_PORT_STATUS_PORT_TEST) > 0, DEC);
Serial.print("INDICATOR:\t");
Serial.println((evt.bmStatus & bmHUB_PORT_STATUS_PORT_INDICATOR) > 0, DEC);
USB_HOST_SERIAL.println("Status");
USB_HOST_SERIAL.print("CONNECTION:\t");
USB_HOST_SERIAL.println((evt.bmStatus & bmHUB_PORT_STATUS_PORT_CONNECTION) > 0, DEC);
USB_HOST_SERIAL.print("ENABLE:\t\t");
USB_HOST_SERIAL.println((evt.bmStatus & bmHUB_PORT_STATUS_PORT_ENABLE) > 0, DEC);
USB_HOST_SERIAL.print("SUSPEND:\t");
USB_HOST_SERIAL.println((evt.bmStatus & bmHUB_PORT_STATUS_PORT_SUSPEND) > 0, DEC);
USB_HOST_SERIAL.print("OVER_CURRENT:\t");
USB_HOST_SERIAL.println((evt.bmStatus & bmHUB_PORT_STATUS_PORT_OVER_CURRENT) > 0, DEC);
USB_HOST_SERIAL.print("RESET:\t\t");
USB_HOST_SERIAL.println((evt.bmStatus & bmHUB_PORT_STATUS_PORT_RESET) > 0, DEC);
USB_HOST_SERIAL.print("POWER:\t\t");
USB_HOST_SERIAL.println((evt.bmStatus & bmHUB_PORT_STATUS_PORT_POWER) > 0, DEC);
USB_HOST_SERIAL.print("LOW_SPEED:\t");
USB_HOST_SERIAL.println((evt.bmStatus & bmHUB_PORT_STATUS_PORT_LOW_SPEED) > 0, DEC);
USB_HOST_SERIAL.print("HIGH_SPEED:\t");
USB_HOST_SERIAL.println((evt.bmStatus & bmHUB_PORT_STATUS_PORT_HIGH_SPEED) > 0, DEC);
USB_HOST_SERIAL.print("TEST:\t\t");
USB_HOST_SERIAL.println((evt.bmStatus & bmHUB_PORT_STATUS_PORT_TEST) > 0, DEC);
USB_HOST_SERIAL.print("INDICATOR:\t");
USB_HOST_SERIAL.println((evt.bmStatus & bmHUB_PORT_STATUS_PORT_INDICATOR) > 0, DEC);
if (!print_changes)
return;
Serial.println("\r\nChange");
Serial.print("CONNECTION:\t");
Serial.println((evt.bmChange & bmHUB_PORT_STATUS_C_PORT_CONNECTION) > 0, DEC);
Serial.print("ENABLE:\t\t");
Serial.println((evt.bmChange & bmHUB_PORT_STATUS_C_PORT_ENABLE) > 0, DEC);
Serial.print("SUSPEND:\t");
Serial.println((evt.bmChange & bmHUB_PORT_STATUS_C_PORT_SUSPEND) > 0, DEC);
Serial.print("OVER_CURRENT:\t");
Serial.println((evt.bmChange & bmHUB_PORT_STATUS_C_PORT_OVER_CURRENT) > 0, DEC);
Serial.print("RESET:\t\t");
Serial.println((evt.bmChange & bmHUB_PORT_STATUS_C_PORT_RESET) > 0, DEC);
USB_HOST_SERIAL.println("\r\nChange");
USB_HOST_SERIAL.print("CONNECTION:\t");
USB_HOST_SERIAL.println((evt.bmChange & bmHUB_PORT_STATUS_C_PORT_CONNECTION) > 0, DEC);
USB_HOST_SERIAL.print("ENABLE:\t\t");
USB_HOST_SERIAL.println((evt.bmChange & bmHUB_PORT_STATUS_C_PORT_ENABLE) > 0, DEC);
USB_HOST_SERIAL.print("SUSPEND:\t");
USB_HOST_SERIAL.println((evt.bmChange & bmHUB_PORT_STATUS_C_PORT_SUSPEND) > 0, DEC);
USB_HOST_SERIAL.print("OVER_CURRENT:\t");
USB_HOST_SERIAL.println((evt.bmChange & bmHUB_PORT_STATUS_C_PORT_OVER_CURRENT) > 0, DEC);
USB_HOST_SERIAL.print("RESET:\t\t");
USB_HOST_SERIAL.println((evt.bmChange & bmHUB_PORT_STATUS_C_PORT_RESET) > 0, DEC);
}