mirror of
https://github.com/felis/USB_Host_Shield_2.0.git
synced 2024-03-22 11:31:26 +01:00
Allow change of debug port
This commit is contained in:
parent
3f7d052b2e
commit
3740adc947
12 changed files with 69 additions and 64 deletions
2
Usb.h
2
Usb.h
|
@ -58,7 +58,7 @@ typedef MAX3421e<P20, P19> MAX3421E; // Balanduino
|
||||||
typedef MAX3421e<P10, P9> MAX3421E; // Official Arduinos (UNO, Duemilanove, Mega, 2560, Leonardo etc.)
|
typedef MAX3421e<P10, P9> MAX3421E; // Official Arduinos (UNO, Duemilanove, Mega, 2560, Leonardo etc.)
|
||||||
#endif
|
#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 USBTRACE(s) (Notify(PSTR(s), 0x80))
|
||||||
#define USBTRACE2(s,r) (Notify(PSTR(s), 0x80), PrintHex((r), 0x80), Notify(PSTR("\r\n"), 0x80))
|
#define USBTRACE2(s,r) (Notify(PSTR(s), 0x80), PrintHex((r), 0x80), Notify(PSTR("\r\n"), 0x80))
|
||||||
|
|
||||||
|
|
14
address.h
14
address.h
|
@ -194,7 +194,7 @@ public:
|
||||||
|
|
||||||
virtual uint8_t AllocAddress(uint8_t parent, bool is_hub = false, uint8_t port = 0) {
|
virtual uint8_t AllocAddress(uint8_t parent, bool is_hub = false, uint8_t port = 0) {
|
||||||
/* if (parent != 0 && port == 0)
|
/* if (parent != 0 && port == 0)
|
||||||
Serial.println("PRT:0"); */
|
USB_HOST_SERIAL.println("PRT:0"); */
|
||||||
|
|
||||||
if(parent > 127 || port > 7)
|
if(parent > 127 || port > 7)
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -231,12 +231,12 @@ public:
|
||||||
}
|
}
|
||||||
thePool[index].address = *((uint8_t*) & addr);
|
thePool[index].address = *((uint8_t*) & addr);
|
||||||
/*
|
/*
|
||||||
Serial.print("Addr:");
|
USB_HOST_SERIAL.print("Addr:");
|
||||||
Serial.print(addr.bmHub, HEX);
|
USB_HOST_SERIAL.print(addr.bmHub, HEX);
|
||||||
Serial.print(".");
|
USB_HOST_SERIAL.print(".");
|
||||||
Serial.print(addr.bmParent, HEX);
|
USB_HOST_SERIAL.print(addr.bmParent, HEX);
|
||||||
Serial.print(".");
|
USB_HOST_SERIAL.print(".");
|
||||||
Serial.println(addr.bmAddress, HEX);
|
USB_HOST_SERIAL.println(addr.bmAddress, HEX);
|
||||||
*/
|
*/
|
||||||
return thePool[index].address;
|
return thePool[index].address;
|
||||||
};
|
};
|
||||||
|
|
|
@ -288,7 +288,7 @@ uint8_t ACM::Poll() {
|
||||||
// for (uint8_t i=0; i<read; i++)
|
// for (uint8_t i=0; i<read; i++)
|
||||||
// {
|
// {
|
||||||
// PrintHex<uint8_t>(buf[i]);
|
// PrintHex<uint8_t>(buf[i]);
|
||||||
// Serial.print(" ");
|
// USB_HOST_SERIAL.print(" ");
|
||||||
// }
|
// }
|
||||||
// USBTRACE("\r\n");
|
// USBTRACE("\r\n");
|
||||||
//}
|
//}
|
||||||
|
|
|
@ -259,7 +259,7 @@ uint8_t FTDI::Poll() {
|
||||||
|
|
||||||
//if (qNextPollTime <= millis())
|
//if (qNextPollTime <= millis())
|
||||||
//{
|
//{
|
||||||
// Serial.println(bAddress, HEX);
|
// USB_HOST_SERIAL.println(bAddress, HEX);
|
||||||
|
|
||||||
// qNextPollTime = millis() + 100;
|
// qNextPollTime = millis() + 100;
|
||||||
//}
|
//}
|
||||||
|
|
|
@ -200,7 +200,7 @@ Fail:
|
||||||
//
|
//
|
||||||
// //if (qNextPollTime <= millis())
|
// //if (qNextPollTime <= millis())
|
||||||
// //{
|
// //{
|
||||||
// // Serial.println(bAddress, HEX);
|
// // USB_HOST_SERIAL.println(bAddress, HEX);
|
||||||
//
|
//
|
||||||
// // qNextPollTime = millis() + 100;
|
// // qNextPollTime = millis() + 100;
|
||||||
// //}
|
// //}
|
||||||
|
|
|
@ -497,7 +497,7 @@ uint8_t HIDBoot<BOOT_PROTOCOL>::Poll() {
|
||||||
//for (uint8_t i=0; i<read; i++)
|
//for (uint8_t i=0; i<read; i++)
|
||||||
// PrintHex<uint8_t>(buf[i]);
|
// PrintHex<uint8_t>(buf[i]);
|
||||||
//if (read)
|
//if (read)
|
||||||
// Serial.println("");
|
// USB_HOST_SERIAL.println("");
|
||||||
|
|
||||||
if(pRptParser)
|
if(pRptParser)
|
||||||
pRptParser->Parse((HID*)this, 0, (uint8_t) read, buf);
|
pRptParser->Parse((HID*)this, 0, (uint8_t) read, buf);
|
||||||
|
|
|
@ -981,9 +981,9 @@ void ReportDescParserBase::Parse(const uint16_t len, const uint8_t *pbuf, const
|
||||||
totalSize = 0;
|
totalSize = 0;
|
||||||
|
|
||||||
while (cntdn) {
|
while (cntdn) {
|
||||||
//Serial.println("");
|
//USB_HOST_SERIAL.println("");
|
||||||
//PrintHex<uint16_t>(offset + len - cntdn);
|
//PrintHex<uint16_t>(offset + len - cntdn);
|
||||||
//Serial.print(":");
|
//USB_HOST_SERIAL.print(":");
|
||||||
|
|
||||||
ParseItem(&p, &cntdn);
|
ParseItem(&p, &cntdn);
|
||||||
|
|
||||||
|
@ -1267,7 +1267,7 @@ void ReportDescParserBase::PrintButtonPageUsage(uint16_t usage) {
|
||||||
Notify(PSTR("Btn"), 0x80);
|
Notify(PSTR("Btn"), 0x80);
|
||||||
PrintHex<uint16_t > (usage, 0x80);
|
PrintHex<uint16_t > (usage, 0x80);
|
||||||
Notify(PSTR("\r\n"), 0x80);
|
Notify(PSTR("\r\n"), 0x80);
|
||||||
//Serial.print(usage, HEX);
|
//USB_HOST_SERIAL.print(usage, HEX);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ReportDescParserBase::PrintOrdinalPageUsage(uint16_t usage) {
|
void ReportDescParserBase::PrintOrdinalPageUsage(uint16_t usage) {
|
||||||
|
@ -1276,7 +1276,7 @@ void ReportDescParserBase::PrintOrdinalPageUsage(uint16_t usage) {
|
||||||
// Sorry, HEX for now...
|
// Sorry, HEX for now...
|
||||||
PrintHex<uint16_t > (usage, 0x80);
|
PrintHex<uint16_t > (usage, 0x80);
|
||||||
Notify(PSTR("\r\n"), 0x80);
|
Notify(PSTR("\r\n"), 0x80);
|
||||||
//Serial.print(usage, DEC);
|
//USB_HOST_SERIAL.print(usage, DEC);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ReportDescParserBase::PrintGenericDesktopPageUsage(uint16_t usage) {
|
void ReportDescParserBase::PrintGenericDesktopPageUsage(uint16_t usage) {
|
||||||
|
|
16
message.cpp
16
message.cpp
|
@ -24,11 +24,11 @@ int UsbDEBUGlvl = 0x80;
|
||||||
void E_Notifyc(char c, int lvl) {
|
void E_Notifyc(char c, int lvl) {
|
||||||
if (UsbDEBUGlvl < lvl) return;
|
if (UsbDEBUGlvl < lvl) return;
|
||||||
#if defined(ARDUINO) && ARDUINO >=100
|
#if defined(ARDUINO) && ARDUINO >=100
|
||||||
Serial.print(c);
|
USB_HOST_SERIAL.print(c);
|
||||||
#else
|
#else
|
||||||
Serial.print(c, BYTE);
|
USB_HOST_SERIAL.print(c, BYTE);
|
||||||
#endif
|
#endif
|
||||||
Serial.flush();
|
USB_HOST_SERIAL.flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
void E_Notify(char const * msg, int lvl) {
|
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) {
|
void E_Notify(uint8_t b, int lvl) {
|
||||||
if (UsbDEBUGlvl < lvl) return;
|
if (UsbDEBUGlvl < lvl) return;
|
||||||
#if defined(ARDUINO) && ARDUINO >=100
|
#if defined(ARDUINO) && ARDUINO >=100
|
||||||
Serial.print(b);
|
USB_HOST_SERIAL.print(b);
|
||||||
#else
|
#else
|
||||||
Serial.print(b, DEC);
|
USB_HOST_SERIAL.print(b, DEC);
|
||||||
#endif
|
#endif
|
||||||
Serial.flush();
|
USB_HOST_SERIAL.flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
void E_Notify(double d, int lvl) {
|
void E_Notify(double d, int lvl) {
|
||||||
if (UsbDEBUGlvl < lvl) return;
|
if (UsbDEBUGlvl < lvl) return;
|
||||||
Serial.print(d);
|
USB_HOST_SERIAL.print(d);
|
||||||
Serial.flush();
|
USB_HOST_SERIAL.flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef DEBUG_USB_HOST
|
#ifdef DEBUG_USB_HOST
|
||||||
|
|
|
@ -20,6 +20,11 @@ e-mail : support@circuitsathome.com
|
||||||
// uncomment to activate
|
// uncomment to activate
|
||||||
//#define DEBUG_USB_HOST
|
//#define DEBUG_USB_HOST
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef USB_HOST_SERIAL
|
||||||
|
#define USB_HOST_SERIAL Serial
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
#include <avr/pgmspace.h>
|
#include <avr/pgmspace.h>
|
||||||
|
|
||||||
|
|
|
@ -57,7 +57,7 @@ void SerialPrintHex(T val) {
|
||||||
do {
|
do {
|
||||||
char v = 48 + (((val >> (num_nibbles - 1) * 4)) & 0x0f);
|
char v = 48 + (((val >> (num_nibbles - 1) * 4)) & 0x0f);
|
||||||
if(v > 57) v += 7;
|
if(v > 57) v += 7;
|
||||||
Serial.print(v);
|
USB_HOST_SERIAL.print(v);
|
||||||
} while(--num_nibbles);
|
} while(--num_nibbles);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
|
@ -273,8 +273,8 @@ template< typename SS, typename INTR >
|
||||||
uint8_t MAX3421e< SS, INTR >::Task(void) {
|
uint8_t MAX3421e< SS, INTR >::Task(void) {
|
||||||
uint8_t rcode = 0;
|
uint8_t rcode = 0;
|
||||||
uint8_t pinvalue;
|
uint8_t pinvalue;
|
||||||
//Serial.print("Vbus state: ");
|
//USB_HOST_SERIAL.print("Vbus state: ");
|
||||||
//Serial.println( vbusState, HEX );
|
//USB_HOST_SERIAL.println( vbusState, HEX );
|
||||||
pinvalue = INTR::IsSet(); //Read();
|
pinvalue = INTR::IsSet(); //Read();
|
||||||
//pinvalue = digitalRead( MAX_INT );
|
//pinvalue = digitalRead( MAX_INT );
|
||||||
if(pinvalue == 0) {
|
if(pinvalue == 0) {
|
||||||
|
|
74
usbhub.cpp
74
usbhub.cpp
|
@ -247,8 +247,8 @@ uint8_t USBHub::CheckHubStatus() {
|
||||||
//rcode = GetHubStatus(1, 0, 1, 4, buf);
|
//rcode = GetHubStatus(1, 0, 1, 4, buf);
|
||||||
//if (rcode)
|
//if (rcode)
|
||||||
//{
|
//{
|
||||||
// Serial.print("GetHubStatus Error");
|
// USB_HOST_SERIAL.print("GetHubStatus Error");
|
||||||
// Serial.println(rcode, HEX);
|
// USB_HOST_SERIAL.println(rcode, HEX);
|
||||||
// return rcode;
|
// 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);
|
rcode = hubptr->GetPortStatus(port, 4, evt.evtBuff);
|
||||||
|
|
||||||
if (rcode) {
|
if (rcode) {
|
||||||
Serial.println("ERROR!");
|
USB_HOST_SERIAL.println("ERROR!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Serial.print("\r\nPort ");
|
USB_HOST_SERIAL.print("\r\nPort ");
|
||||||
Serial.println(port, DEC);
|
USB_HOST_SERIAL.println(port, DEC);
|
||||||
|
|
||||||
Serial.println("Status");
|
USB_HOST_SERIAL.println("Status");
|
||||||
Serial.print("CONNECTION:\t");
|
USB_HOST_SERIAL.print("CONNECTION:\t");
|
||||||
Serial.println((evt.bmStatus & bmHUB_PORT_STATUS_PORT_CONNECTION) > 0, DEC);
|
USB_HOST_SERIAL.println((evt.bmStatus & bmHUB_PORT_STATUS_PORT_CONNECTION) > 0, DEC);
|
||||||
Serial.print("ENABLE:\t\t");
|
USB_HOST_SERIAL.print("ENABLE:\t\t");
|
||||||
Serial.println((evt.bmStatus & bmHUB_PORT_STATUS_PORT_ENABLE) > 0, DEC);
|
USB_HOST_SERIAL.println((evt.bmStatus & bmHUB_PORT_STATUS_PORT_ENABLE) > 0, DEC);
|
||||||
Serial.print("SUSPEND:\t");
|
USB_HOST_SERIAL.print("SUSPEND:\t");
|
||||||
Serial.println((evt.bmStatus & bmHUB_PORT_STATUS_PORT_SUSPEND) > 0, DEC);
|
USB_HOST_SERIAL.println((evt.bmStatus & bmHUB_PORT_STATUS_PORT_SUSPEND) > 0, DEC);
|
||||||
Serial.print("OVER_CURRENT:\t");
|
USB_HOST_SERIAL.print("OVER_CURRENT:\t");
|
||||||
Serial.println((evt.bmStatus & bmHUB_PORT_STATUS_PORT_OVER_CURRENT) > 0, DEC);
|
USB_HOST_SERIAL.println((evt.bmStatus & bmHUB_PORT_STATUS_PORT_OVER_CURRENT) > 0, DEC);
|
||||||
Serial.print("RESET:\t\t");
|
USB_HOST_SERIAL.print("RESET:\t\t");
|
||||||
Serial.println((evt.bmStatus & bmHUB_PORT_STATUS_PORT_RESET) > 0, DEC);
|
USB_HOST_SERIAL.println((evt.bmStatus & bmHUB_PORT_STATUS_PORT_RESET) > 0, DEC);
|
||||||
Serial.print("POWER:\t\t");
|
USB_HOST_SERIAL.print("POWER:\t\t");
|
||||||
Serial.println((evt.bmStatus & bmHUB_PORT_STATUS_PORT_POWER) > 0, DEC);
|
USB_HOST_SERIAL.println((evt.bmStatus & bmHUB_PORT_STATUS_PORT_POWER) > 0, DEC);
|
||||||
Serial.print("LOW_SPEED:\t");
|
USB_HOST_SERIAL.print("LOW_SPEED:\t");
|
||||||
Serial.println((evt.bmStatus & bmHUB_PORT_STATUS_PORT_LOW_SPEED) > 0, DEC);
|
USB_HOST_SERIAL.println((evt.bmStatus & bmHUB_PORT_STATUS_PORT_LOW_SPEED) > 0, DEC);
|
||||||
Serial.print("HIGH_SPEED:\t");
|
USB_HOST_SERIAL.print("HIGH_SPEED:\t");
|
||||||
Serial.println((evt.bmStatus & bmHUB_PORT_STATUS_PORT_HIGH_SPEED) > 0, DEC);
|
USB_HOST_SERIAL.println((evt.bmStatus & bmHUB_PORT_STATUS_PORT_HIGH_SPEED) > 0, DEC);
|
||||||
Serial.print("TEST:\t\t");
|
USB_HOST_SERIAL.print("TEST:\t\t");
|
||||||
Serial.println((evt.bmStatus & bmHUB_PORT_STATUS_PORT_TEST) > 0, DEC);
|
USB_HOST_SERIAL.println((evt.bmStatus & bmHUB_PORT_STATUS_PORT_TEST) > 0, DEC);
|
||||||
Serial.print("INDICATOR:\t");
|
USB_HOST_SERIAL.print("INDICATOR:\t");
|
||||||
Serial.println((evt.bmStatus & bmHUB_PORT_STATUS_PORT_INDICATOR) > 0, DEC);
|
USB_HOST_SERIAL.println((evt.bmStatus & bmHUB_PORT_STATUS_PORT_INDICATOR) > 0, DEC);
|
||||||
|
|
||||||
if (!print_changes)
|
if (!print_changes)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Serial.println("\r\nChange");
|
USB_HOST_SERIAL.println("\r\nChange");
|
||||||
Serial.print("CONNECTION:\t");
|
USB_HOST_SERIAL.print("CONNECTION:\t");
|
||||||
Serial.println((evt.bmChange & bmHUB_PORT_STATUS_C_PORT_CONNECTION) > 0, DEC);
|
USB_HOST_SERIAL.println((evt.bmChange & bmHUB_PORT_STATUS_C_PORT_CONNECTION) > 0, DEC);
|
||||||
Serial.print("ENABLE:\t\t");
|
USB_HOST_SERIAL.print("ENABLE:\t\t");
|
||||||
Serial.println((evt.bmChange & bmHUB_PORT_STATUS_C_PORT_ENABLE) > 0, DEC);
|
USB_HOST_SERIAL.println((evt.bmChange & bmHUB_PORT_STATUS_C_PORT_ENABLE) > 0, DEC);
|
||||||
Serial.print("SUSPEND:\t");
|
USB_HOST_SERIAL.print("SUSPEND:\t");
|
||||||
Serial.println((evt.bmChange & bmHUB_PORT_STATUS_C_PORT_SUSPEND) > 0, DEC);
|
USB_HOST_SERIAL.println((evt.bmChange & bmHUB_PORT_STATUS_C_PORT_SUSPEND) > 0, DEC);
|
||||||
Serial.print("OVER_CURRENT:\t");
|
USB_HOST_SERIAL.print("OVER_CURRENT:\t");
|
||||||
Serial.println((evt.bmChange & bmHUB_PORT_STATUS_C_PORT_OVER_CURRENT) > 0, DEC);
|
USB_HOST_SERIAL.println((evt.bmChange & bmHUB_PORT_STATUS_C_PORT_OVER_CURRENT) > 0, DEC);
|
||||||
Serial.print("RESET:\t\t");
|
USB_HOST_SERIAL.print("RESET:\t\t");
|
||||||
Serial.println((evt.bmChange & bmHUB_PORT_STATUS_C_PORT_RESET) > 0, DEC);
|
USB_HOST_SERIAL.println((evt.bmChange & bmHUB_PORT_STATUS_C_PORT_RESET) > 0, DEC);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue