mirror of
https://github.com/felis/USB_Host_Shield_2.0.git
synced 2024-03-22 11:31:26 +01:00
refactor entire library for hex printing
This commit is contained in:
parent
080a8e256d
commit
e01df49bf3
23 changed files with 220 additions and 213 deletions
58
BTD.cpp
58
BTD.cpp
|
@ -116,12 +116,12 @@ uint8_t BTD::Init(uint8_t parent, uint8_t port, bool lowspeed) {
|
||||||
#ifdef DEBUG_USB_HOST
|
#ifdef DEBUG_USB_HOST
|
||||||
Notify(PSTR("\r\nsetAddr: "), 0x80);
|
Notify(PSTR("\r\nsetAddr: "), 0x80);
|
||||||
#endif
|
#endif
|
||||||
PrintHex<uint8_t > (rcode, 0x80);
|
D_PrintHex<uint8_t > (rcode, 0x80);
|
||||||
return rcode;
|
return rcode;
|
||||||
}
|
}
|
||||||
#ifdef EXTRADEBUG
|
#ifdef EXTRADEBUG
|
||||||
Notify(PSTR("\r\nAddr: "), 0x80);
|
Notify(PSTR("\r\nAddr: "), 0x80);
|
||||||
PrintHex<uint8_t > (bAddress, 0x80);
|
D_PrintHex<uint8_t > (bAddress, 0x80);
|
||||||
#endif
|
#endif
|
||||||
p->lowspeed = false;
|
p->lowspeed = false;
|
||||||
|
|
||||||
|
@ -167,10 +167,10 @@ uint8_t BTD::Init(uint8_t parent, uint8_t port, bool lowspeed) {
|
||||||
#ifdef DEBUG_USB_HOST
|
#ifdef DEBUG_USB_HOST
|
||||||
Notify(PSTR("\r\nBluetooth Address was set to: "), 0x80);
|
Notify(PSTR("\r\nBluetooth Address was set to: "), 0x80);
|
||||||
for (int8_t i = 5; i > 0; i--) {
|
for (int8_t i = 5; i > 0; i--) {
|
||||||
PrintHex<uint8_t > (my_bdaddr[i], 0x80);
|
D_PrintHex<uint8_t > (my_bdaddr[i], 0x80);
|
||||||
Notify(PSTR(":"), 0x80);
|
Notify(PSTR(":"), 0x80);
|
||||||
}
|
}
|
||||||
PrintHex<uint8_t > (my_bdaddr[0], 0x80);
|
D_PrintHex<uint8_t > (my_bdaddr[0], 0x80);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -297,17 +297,17 @@ void BTD::PrintEndpointDescriptor(const USB_ENDPOINT_DESCRIPTOR* ep_ptr) {
|
||||||
#ifdef EXTRADEBUG
|
#ifdef EXTRADEBUG
|
||||||
Notify(PSTR("\r\nEndpoint descriptor:"), 0x80);
|
Notify(PSTR("\r\nEndpoint descriptor:"), 0x80);
|
||||||
Notify(PSTR("\r\nLength:\t\t"), 0x80);
|
Notify(PSTR("\r\nLength:\t\t"), 0x80);
|
||||||
PrintHex<uint8_t > (ep_ptr->bLength, 0x80);
|
D_PrintHex<uint8_t > (ep_ptr->bLength, 0x80);
|
||||||
Notify(PSTR("\r\nType:\t\t"), 0x80);
|
Notify(PSTR("\r\nType:\t\t"), 0x80);
|
||||||
PrintHex<uint8_t > (ep_ptr->bDescriptorType, 0x80);
|
D_PrintHex<uint8_t > (ep_ptr->bDescriptorType, 0x80);
|
||||||
Notify(PSTR("\r\nAddress:\t"), 0x80);
|
Notify(PSTR("\r\nAddress:\t"), 0x80);
|
||||||
PrintHex<uint8_t > (ep_ptr->bEndpointAddress, 0x80);
|
D_PrintHex<uint8_t > (ep_ptr->bEndpointAddress, 0x80);
|
||||||
Notify(PSTR("\r\nAttributes:\t"), 0x80);
|
Notify(PSTR("\r\nAttributes:\t"), 0x80);
|
||||||
PrintHex<uint8_t > (ep_ptr->bmAttributes, 0x80);
|
D_PrintHex<uint8_t > (ep_ptr->bmAttributes, 0x80);
|
||||||
Notify(PSTR("\r\nMaxPktSize:\t"), 0x80);
|
Notify(PSTR("\r\nMaxPktSize:\t"), 0x80);
|
||||||
PrintHex<uint16_t > (ep_ptr->wMaxPacketSize, 0x80);
|
D_PrintHex<uint16_t > (ep_ptr->wMaxPacketSize, 0x80);
|
||||||
Notify(PSTR("\r\nPoll Intrv:\t"), 0x80);
|
Notify(PSTR("\r\nPoll Intrv:\t"), 0x80);
|
||||||
PrintHex<uint8_t > (ep_ptr->bInterval, 0x80);
|
D_PrintHex<uint8_t > (ep_ptr->bInterval, 0x80);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -362,11 +362,11 @@ void BTD::HCI_event_task() {
|
||||||
if (hcibuf[2]) { // show status on serial if not OK
|
if (hcibuf[2]) { // show status on serial if not OK
|
||||||
#ifdef DEBUG_USB_HOST
|
#ifdef DEBUG_USB_HOST
|
||||||
Notify(PSTR("\r\nHCI Command Failed: "), 0x80);
|
Notify(PSTR("\r\nHCI Command Failed: "), 0x80);
|
||||||
PrintHex<uint8_t > (hcibuf[2], 0x80);
|
D_PrintHex<uint8_t > (hcibuf[2], 0x80);
|
||||||
Notify(PSTR(" "), 0x80);
|
Notify(PSTR(" "), 0x80);
|
||||||
PrintHex<uint8_t > (hcibuf[4], 0x80);
|
D_PrintHex<uint8_t > (hcibuf[4], 0x80);
|
||||||
Notify(PSTR(" "), 0x80);
|
Notify(PSTR(" "), 0x80);
|
||||||
PrintHex<uint8_t > (hcibuf[5], 0x80);
|
D_PrintHex<uint8_t > (hcibuf[5], 0x80);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -408,11 +408,11 @@ void BTD::HCI_event_task() {
|
||||||
#ifdef EXTRADEBUG
|
#ifdef EXTRADEBUG
|
||||||
else {
|
else {
|
||||||
Notify(PSTR("\r\nClass of device: "), 0x80);
|
Notify(PSTR("\r\nClass of device: "), 0x80);
|
||||||
PrintHex<uint8_t > (hcibuf[6 + 8 * hcibuf[2] + 3 * i], 0x80);
|
D_PrintHex<uint8_t > (hcibuf[6 + 8 * hcibuf[2] + 3 * i], 0x80);
|
||||||
Notify(PSTR(" "), 0x80);
|
Notify(PSTR(" "), 0x80);
|
||||||
PrintHex<uint8_t > (hcibuf[5 + 8 * hcibuf[2] + 3 * i], 0x80);
|
D_PrintHex<uint8_t > (hcibuf[5 + 8 * hcibuf[2] + 3 * i], 0x80);
|
||||||
Notify(PSTR(" "), 0x80);
|
Notify(PSTR(" "), 0x80);
|
||||||
PrintHex<uint8_t > (hcibuf[4 + 8 * hcibuf[2] + 3 * i], 0x80);
|
D_PrintHex<uint8_t > (hcibuf[4 + 8 * hcibuf[2] + 3 * i], 0x80);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -457,11 +457,11 @@ void BTD::HCI_event_task() {
|
||||||
disc_bdaddr[5] = hcibuf[7];
|
disc_bdaddr[5] = hcibuf[7];
|
||||||
#ifdef EXTRADEBUG
|
#ifdef EXTRADEBUG
|
||||||
Notify(PSTR("\r\nClass of device: "), 0x80);
|
Notify(PSTR("\r\nClass of device: "), 0x80);
|
||||||
PrintHex<uint8_t > (hcibuf[10], 0x80);
|
D_PrintHex<uint8_t > (hcibuf[10], 0x80);
|
||||||
Notify(PSTR(" "), 0x80);
|
Notify(PSTR(" "), 0x80);
|
||||||
PrintHex<uint8_t > (hcibuf[9], 0x80);
|
D_PrintHex<uint8_t > (hcibuf[9], 0x80);
|
||||||
Notify(PSTR(" "), 0x80);
|
Notify(PSTR(" "), 0x80);
|
||||||
PrintHex<uint8_t > (hcibuf[8], 0x80);
|
D_PrintHex<uint8_t > (hcibuf[8], 0x80);
|
||||||
#endif
|
#endif
|
||||||
hci_event_flag |= HCI_FLAG_INCOMING_REQUEST;
|
hci_event_flag |= HCI_FLAG_INCOMING_REQUEST;
|
||||||
break;
|
break;
|
||||||
|
@ -518,7 +518,7 @@ void BTD::HCI_event_task() {
|
||||||
default:
|
default:
|
||||||
if (hcibuf[0] != 0x00) {
|
if (hcibuf[0] != 0x00) {
|
||||||
Notify(PSTR("\r\nUnmanaged HCI Event: "), 0x80);
|
Notify(PSTR("\r\nUnmanaged HCI Event: "), 0x80);
|
||||||
PrintHex<uint8_t > (hcibuf[0], 0x80);
|
D_PrintHex<uint8_t > (hcibuf[0], 0x80);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
|
@ -527,7 +527,7 @@ void BTD::HCI_event_task() {
|
||||||
#ifdef EXTRADEBUG
|
#ifdef EXTRADEBUG
|
||||||
else if (rcode != hrNAK) {
|
else if (rcode != hrNAK) {
|
||||||
Notify(PSTR("\r\nHCI event error: "), 0x80);
|
Notify(PSTR("\r\nHCI event error: "), 0x80);
|
||||||
PrintHex<uint8_t > (rcode, 0x80);
|
D_PrintHex<uint8_t > (rcode, 0x80);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
HCI_task();
|
HCI_task();
|
||||||
|
@ -581,10 +581,10 @@ void BTD::HCI_task() {
|
||||||
#ifdef DEBUG_USB_HOST
|
#ifdef DEBUG_USB_HOST
|
||||||
Notify(PSTR("\r\nLocal Bluetooth Address: "), 0x80);
|
Notify(PSTR("\r\nLocal Bluetooth Address: "), 0x80);
|
||||||
for (int8_t i = 5; i > 0; i--) {
|
for (int8_t i = 5; i > 0; i--) {
|
||||||
PrintHex<uint8_t > (my_bdaddr[i], 0x80);
|
D_PrintHex<uint8_t > (my_bdaddr[i], 0x80);
|
||||||
Notify(PSTR(":"), 0x80);
|
Notify(PSTR(":"), 0x80);
|
||||||
}
|
}
|
||||||
PrintHex<uint8_t > (my_bdaddr[0], 0x80);
|
D_PrintHex<uint8_t > (my_bdaddr[0], 0x80);
|
||||||
#endif
|
#endif
|
||||||
hci_read_local_version_information();
|
hci_read_local_version_information();
|
||||||
hci_state = HCI_LOCAL_VERSION_STATE;
|
hci_state = HCI_LOCAL_VERSION_STATE;
|
||||||
|
@ -734,10 +734,10 @@ void BTD::HCI_task() {
|
||||||
#ifdef DEBUG_USB_HOST
|
#ifdef DEBUG_USB_HOST
|
||||||
Notify(PSTR("\r\nConnected to Device: "), 0x80);
|
Notify(PSTR("\r\nConnected to Device: "), 0x80);
|
||||||
for (int8_t i = 5; i > 0; i--) {
|
for (int8_t i = 5; i > 0; i--) {
|
||||||
PrintHex<uint8_t > (disc_bdaddr[i], 0x80);
|
D_PrintHex<uint8_t > (disc_bdaddr[i], 0x80);
|
||||||
Notify(PSTR(":"), 0x80);
|
Notify(PSTR(":"), 0x80);
|
||||||
}
|
}
|
||||||
PrintHex<uint8_t > (disc_bdaddr[0], 0x80);
|
D_PrintHex<uint8_t > (disc_bdaddr[0], 0x80);
|
||||||
#endif
|
#endif
|
||||||
// Clear these flags for a new connection
|
// Clear these flags for a new connection
|
||||||
l2capConnectionClaimed = false;
|
l2capConnectionClaimed = false;
|
||||||
|
@ -789,7 +789,7 @@ void BTD::ACL_event_task() {
|
||||||
#ifdef EXTRADEBUG
|
#ifdef EXTRADEBUG
|
||||||
else if (rcode != hrNAK) {
|
else if (rcode != hrNAK) {
|
||||||
Notify(PSTR("\r\nACL data in error: "), 0x80);
|
Notify(PSTR("\r\nACL data in error: "), 0x80);
|
||||||
PrintHex<uint8_t > (rcode, 0x80);
|
D_PrintHex<uint8_t > (rcode, 0x80);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
for (uint8_t i = 0; i < BTD_NUMSERVICES; i++)
|
for (uint8_t i = 0; i < BTD_NUMSERVICES; i++)
|
||||||
|
@ -1085,11 +1085,11 @@ void BTD::L2CAP_Command(uint16_t handle, uint8_t* data, uint8_t nbytes, uint8_t
|
||||||
delay(100); // This small delay prevents it from overflowing if it fails
|
delay(100); // This small delay prevents it from overflowing if it fails
|
||||||
#ifdef DEBUG_USB_HOST
|
#ifdef DEBUG_USB_HOST
|
||||||
Notify(PSTR("\r\nError sending L2CAP message: 0x"), 0x80);
|
Notify(PSTR("\r\nError sending L2CAP message: 0x"), 0x80);
|
||||||
PrintHex<uint8_t > (rcode, 0x80);
|
D_PrintHex<uint8_t > (rcode, 0x80);
|
||||||
Notify(PSTR(" - Channel ID: "), 0x80);
|
Notify(PSTR(" - Channel ID: "), 0x80);
|
||||||
PrintHex<uint8_t > (channelHigh, 0x80);
|
D_PrintHex<uint8_t > (channelHigh, 0x80);
|
||||||
Notify(PSTR(" "), 0x80);
|
Notify(PSTR(" "), 0x80);
|
||||||
PrintHex<uint8_t > (channelLow, 0x80);
|
D_PrintHex<uint8_t > (channelLow, 0x80);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
26
PS3BT.cpp
26
PS3BT.cpp
|
@ -272,30 +272,30 @@ void PS3BT::ACLData(uint8_t* ACLData) {
|
||||||
if (l2capinbuf[8] == L2CAP_CMD_COMMAND_REJECT) {
|
if (l2capinbuf[8] == L2CAP_CMD_COMMAND_REJECT) {
|
||||||
#ifdef DEBUG_USB_HOST
|
#ifdef DEBUG_USB_HOST
|
||||||
Notify(PSTR("\r\nL2CAP Command Rejected - Reason: "), 0x80);
|
Notify(PSTR("\r\nL2CAP Command Rejected - Reason: "), 0x80);
|
||||||
PrintHex<uint8_t > (l2capinbuf[13], 0x80);
|
D_PrintHex<uint8_t > (l2capinbuf[13], 0x80);
|
||||||
Notify(PSTR(" "), 0x80);
|
Notify(PSTR(" "), 0x80);
|
||||||
PrintHex<uint8_t > (l2capinbuf[12], 0x80);
|
D_PrintHex<uint8_t > (l2capinbuf[12], 0x80);
|
||||||
Notify(PSTR(" Data: "), 0x80);
|
Notify(PSTR(" Data: "), 0x80);
|
||||||
PrintHex<uint8_t > (l2capinbuf[17], 0x80);
|
D_PrintHex<uint8_t > (l2capinbuf[17], 0x80);
|
||||||
Notify(PSTR(" "), 0x80);
|
Notify(PSTR(" "), 0x80);
|
||||||
PrintHex<uint8_t > (l2capinbuf[16], 0x80);
|
D_PrintHex<uint8_t > (l2capinbuf[16], 0x80);
|
||||||
Notify(PSTR(" "), 0x80);
|
Notify(PSTR(" "), 0x80);
|
||||||
PrintHex<uint8_t > (l2capinbuf[15], 0x80);
|
D_PrintHex<uint8_t > (l2capinbuf[15], 0x80);
|
||||||
Notify(PSTR(" "), 0x80);
|
Notify(PSTR(" "), 0x80);
|
||||||
PrintHex<uint8_t > (l2capinbuf[14], 0x80);
|
D_PrintHex<uint8_t > (l2capinbuf[14], 0x80);
|
||||||
#endif
|
#endif
|
||||||
} else if (l2capinbuf[8] == L2CAP_CMD_CONNECTION_REQUEST) {
|
} else if (l2capinbuf[8] == L2CAP_CMD_CONNECTION_REQUEST) {
|
||||||
#ifdef EXTRADEBUG
|
#ifdef EXTRADEBUG
|
||||||
Notify(PSTR("\r\nL2CAP Connection Request - PSM: "), 0x80);
|
Notify(PSTR("\r\nL2CAP Connection Request - PSM: "), 0x80);
|
||||||
PrintHex<uint8_t > (l2capinbuf[13], 0x80);
|
D_PrintHex<uint8_t > (l2capinbuf[13], 0x80);
|
||||||
Notify(PSTR(" "), 0x80);
|
Notify(PSTR(" "), 0x80);
|
||||||
PrintHex<uint8_t > (l2capinbuf[12], 0x80);
|
D_PrintHex<uint8_t > (l2capinbuf[12], 0x80);
|
||||||
Notify(PSTR(" SCID: "), 0x80);
|
Notify(PSTR(" SCID: "), 0x80);
|
||||||
PrintHex<uint8_t > (l2capinbuf[15], 0x80);
|
D_PrintHex<uint8_t > (l2capinbuf[15], 0x80);
|
||||||
Notify(PSTR(" "), 0x80);
|
Notify(PSTR(" "), 0x80);
|
||||||
PrintHex<uint8_t > (l2capinbuf[14], 0x80);
|
D_PrintHex<uint8_t > (l2capinbuf[14], 0x80);
|
||||||
Notify(PSTR(" Identifier: "), 0x80);
|
Notify(PSTR(" Identifier: "), 0x80);
|
||||||
PrintHex<uint8_t > (l2capinbuf[9], 0x80);
|
D_PrintHex<uint8_t > (l2capinbuf[9], 0x80);
|
||||||
#endif
|
#endif
|
||||||
if ((l2capinbuf[12] | (l2capinbuf[13] << 8)) == HID_CTRL_PSM) {
|
if ((l2capinbuf[12] | (l2capinbuf[13] << 8)) == HID_CTRL_PSM) {
|
||||||
identifier = l2capinbuf[9];
|
identifier = l2capinbuf[9];
|
||||||
|
@ -358,7 +358,7 @@ void PS3BT::ACLData(uint8_t* ACLData) {
|
||||||
#ifdef EXTRADEBUG
|
#ifdef EXTRADEBUG
|
||||||
else {
|
else {
|
||||||
Notify(PSTR("\r\nL2CAP Unknown Signaling Command: "), 0x80);
|
Notify(PSTR("\r\nL2CAP Unknown Signaling Command: "), 0x80);
|
||||||
PrintHex<uint8_t > (l2capinbuf[8], 0x80);
|
D_PrintHex<uint8_t > (l2capinbuf[8], 0x80);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
} else if (l2capinbuf[6] == interrupt_dcid[0] && l2capinbuf[7] == interrupt_dcid[1]) { // l2cap_interrupt
|
} else if (l2capinbuf[6] == interrupt_dcid[0] && l2capinbuf[7] == interrupt_dcid[1]) { // l2cap_interrupt
|
||||||
|
@ -381,7 +381,7 @@ void PS3BT::ACLData(uint8_t* ACLData) {
|
||||||
|
|
||||||
#ifdef PRINTREPORT // Uncomment "#define PRINTREPORT" to print the report send by the PS3 Controllers
|
#ifdef PRINTREPORT // Uncomment "#define PRINTREPORT" to print the report send by the PS3 Controllers
|
||||||
for (uint8_t i = 10; i < 58; i++) {
|
for (uint8_t i = 10; i < 58; i++) {
|
||||||
PrintHex<uint8_t > (l2capinbuf[i], 0x80);
|
D_PrintHex<uint8_t > (l2capinbuf[i], 0x80);
|
||||||
Notify(PSTR(" "), 0x80);
|
Notify(PSTR(" "), 0x80);
|
||||||
}
|
}
|
||||||
Notify(PSTR("\r\n"), 0x80);
|
Notify(PSTR("\r\n"), 0x80);
|
||||||
|
|
10
PS3USB.cpp
10
PS3USB.cpp
|
@ -121,12 +121,12 @@ uint8_t PS3USB::Init(uint8_t parent, uint8_t port, bool lowspeed) {
|
||||||
#ifdef DEBUG_USB_HOST
|
#ifdef DEBUG_USB_HOST
|
||||||
Notify(PSTR("\r\nsetAddr: "), 0x80);
|
Notify(PSTR("\r\nsetAddr: "), 0x80);
|
||||||
#endif
|
#endif
|
||||||
PrintHex<uint8_t > (rcode, 0x80);
|
D_PrintHex<uint8_t > (rcode, 0x80);
|
||||||
return rcode;
|
return rcode;
|
||||||
}
|
}
|
||||||
#ifdef EXTRADEBUG
|
#ifdef EXTRADEBUG
|
||||||
Notify(PSTR("\r\nAddr: "), 0x80);
|
Notify(PSTR("\r\nAddr: "), 0x80);
|
||||||
PrintHex<uint8_t > (bAddress, 0x80);
|
D_PrintHex<uint8_t > (bAddress, 0x80);
|
||||||
#endif
|
#endif
|
||||||
p->lowspeed = false;
|
p->lowspeed = false;
|
||||||
|
|
||||||
|
@ -208,10 +208,10 @@ uint8_t PS3USB::Init(uint8_t parent, uint8_t port, bool lowspeed) {
|
||||||
#ifdef DEBUG_USB_HOST
|
#ifdef DEBUG_USB_HOST
|
||||||
Notify(PSTR("\r\nBluetooth Address was set to: "), 0x80);
|
Notify(PSTR("\r\nBluetooth Address was set to: "), 0x80);
|
||||||
for (int8_t i = 5; i > 0; i--) {
|
for (int8_t i = 5; i > 0; i--) {
|
||||||
PrintHex<uint8_t > (my_bdaddr[i], 0x80);
|
D_PrintHex<uint8_t > (my_bdaddr[i], 0x80);
|
||||||
Notify(PSTR(":"), 0x80);
|
Notify(PSTR(":"), 0x80);
|
||||||
}
|
}
|
||||||
PrintHex<uint8_t > (my_bdaddr[0], 0x80);
|
D_PrintHex<uint8_t > (my_bdaddr[0], 0x80);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
bPollEnable = true;
|
bPollEnable = true;
|
||||||
|
@ -305,7 +305,7 @@ void PS3USB::printReport() { //Uncomment "#define PRINTREPORT" to print the repo
|
||||||
if (readBuf == NULL)
|
if (readBuf == NULL)
|
||||||
return;
|
return;
|
||||||
for (uint8_t i = 0; i < PS3_REPORT_BUFFER_SIZE; i++) {
|
for (uint8_t i = 0; i < PS3_REPORT_BUFFER_SIZE; i++) {
|
||||||
PrintHex<uint8_t > (readBuf[i], 0x80);
|
D_PrintHex<uint8_t > (readBuf[i], 0x80);
|
||||||
Notify(PSTR(" "), 0x80);
|
Notify(PSTR(" "), 0x80);
|
||||||
}
|
}
|
||||||
Notify(PSTR("\r\n"), 0x80);
|
Notify(PSTR("\r\n"), 0x80);
|
||||||
|
|
58
SPP.cpp
58
SPP.cpp
|
@ -101,30 +101,30 @@ void SPP::ACLData(uint8_t* l2capinbuf) {
|
||||||
if (l2capinbuf[8] == L2CAP_CMD_COMMAND_REJECT) {
|
if (l2capinbuf[8] == L2CAP_CMD_COMMAND_REJECT) {
|
||||||
#ifdef DEBUG_USB_HOST
|
#ifdef DEBUG_USB_HOST
|
||||||
Notify(PSTR("\r\nL2CAP Command Rejected - Reason: "), 0x80);
|
Notify(PSTR("\r\nL2CAP Command Rejected - Reason: "), 0x80);
|
||||||
PrintHex<uint8_t > (l2capinbuf[13], 0x80);
|
D_PrintHex<uint8_t > (l2capinbuf[13], 0x80);
|
||||||
Notify(PSTR(" "), 0x80);
|
Notify(PSTR(" "), 0x80);
|
||||||
PrintHex<uint8_t > (l2capinbuf[12], 0x80);
|
D_PrintHex<uint8_t > (l2capinbuf[12], 0x80);
|
||||||
Notify(PSTR(" Data: "), 0x80);
|
Notify(PSTR(" Data: "), 0x80);
|
||||||
PrintHex<uint8_t > (l2capinbuf[17], 0x80);
|
D_PrintHex<uint8_t > (l2capinbuf[17], 0x80);
|
||||||
Notify(PSTR(" "), 0x80);
|
Notify(PSTR(" "), 0x80);
|
||||||
PrintHex<uint8_t > (l2capinbuf[16], 0x80);
|
D_PrintHex<uint8_t > (l2capinbuf[16], 0x80);
|
||||||
Notify(PSTR(" "), 0x80);
|
Notify(PSTR(" "), 0x80);
|
||||||
PrintHex<uint8_t > (l2capinbuf[15], 0x80);
|
D_PrintHex<uint8_t > (l2capinbuf[15], 0x80);
|
||||||
Notify(PSTR(" "), 0x80);
|
Notify(PSTR(" "), 0x80);
|
||||||
PrintHex<uint8_t > (l2capinbuf[14], 0x80);
|
D_PrintHex<uint8_t > (l2capinbuf[14], 0x80);
|
||||||
#endif
|
#endif
|
||||||
} else if (l2capinbuf[8] == L2CAP_CMD_CONNECTION_REQUEST) {
|
} else if (l2capinbuf[8] == L2CAP_CMD_CONNECTION_REQUEST) {
|
||||||
#ifdef EXTRADEBUG
|
#ifdef EXTRADEBUG
|
||||||
Notify(PSTR("\r\nL2CAP Connection Request - PSM: "), 0x80);
|
Notify(PSTR("\r\nL2CAP Connection Request - PSM: "), 0x80);
|
||||||
PrintHex<uint8_t > (l2capinbuf[13], 0x80);
|
D_PrintHex<uint8_t > (l2capinbuf[13], 0x80);
|
||||||
Notify(PSTR(" "), 0x80);
|
Notify(PSTR(" "), 0x80);
|
||||||
PrintHex<uint8_t > (l2capinbuf[12], 0x80);
|
D_PrintHex<uint8_t > (l2capinbuf[12], 0x80);
|
||||||
Notify(PSTR(" SCID: "), 0x80);
|
Notify(PSTR(" SCID: "), 0x80);
|
||||||
PrintHex<uint8_t > (l2capinbuf[15], 0x80);
|
D_PrintHex<uint8_t > (l2capinbuf[15], 0x80);
|
||||||
Notify(PSTR(" "), 0x80);
|
Notify(PSTR(" "), 0x80);
|
||||||
PrintHex<uint8_t > (l2capinbuf[14], 0x80);
|
D_PrintHex<uint8_t > (l2capinbuf[14], 0x80);
|
||||||
Notify(PSTR(" Identifier: "), 0x80);
|
Notify(PSTR(" Identifier: "), 0x80);
|
||||||
PrintHex<uint8_t > (l2capinbuf[9], 0x80);
|
D_PrintHex<uint8_t > (l2capinbuf[9], 0x80);
|
||||||
#endif
|
#endif
|
||||||
if ((l2capinbuf[12] | (l2capinbuf[13] << 8)) == SDP_PSM) { // It doesn't matter if it receives another reqeust, since it waits for the channel to disconnect in the L2CAP_SDP_DONE state, and the l2cap_event_flag will be cleared if so
|
if ((l2capinbuf[12] | (l2capinbuf[13] << 8)) == SDP_PSM) { // It doesn't matter if it receives another reqeust, since it waits for the channel to disconnect in the L2CAP_SDP_DONE state, and the l2cap_event_flag will be cleared if so
|
||||||
identifier = l2capinbuf[9];
|
identifier = l2capinbuf[9];
|
||||||
|
@ -187,7 +187,7 @@ void SPP::ACLData(uint8_t* l2capinbuf) {
|
||||||
#ifdef EXTRADEBUG
|
#ifdef EXTRADEBUG
|
||||||
else {
|
else {
|
||||||
Notify(PSTR("\r\nL2CAP Unknown Signaling Command: "), 0x80);
|
Notify(PSTR("\r\nL2CAP Unknown Signaling Command: "), 0x80);
|
||||||
PrintHex<uint8_t > (l2capinbuf[8], 0x80);
|
D_PrintHex<uint8_t > (l2capinbuf[8], 0x80);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
} else if (l2capinbuf[6] == sdp_dcid[0] && l2capinbuf[7] == sdp_dcid[1]) { // SDP
|
} else if (l2capinbuf[6] == sdp_dcid[0] && l2capinbuf[7] == sdp_dcid[1]) { // SDP
|
||||||
|
@ -217,14 +217,14 @@ void SPP::ACLData(uint8_t* l2capinbuf) {
|
||||||
uuid = (l2capinbuf[18] << 8 | l2capinbuf[19]);
|
uuid = (l2capinbuf[18] << 8 | l2capinbuf[19]);
|
||||||
else // Short UUID
|
else // Short UUID
|
||||||
uuid = (l2capinbuf[16] << 8 | l2capinbuf[17]);
|
uuid = (l2capinbuf[16] << 8 | l2capinbuf[17]);
|
||||||
PrintHex<uint16_t> (uuid, 0x80);
|
D_PrintHex<uint16_t> (uuid, 0x80);
|
||||||
|
|
||||||
Notify(PSTR("\r\nLength: "), 0x80);
|
Notify(PSTR("\r\nLength: "), 0x80);
|
||||||
uint16_t length = l2capinbuf[11] << 8 | l2capinbuf[12];
|
uint16_t length = l2capinbuf[11] << 8 | l2capinbuf[12];
|
||||||
PrintHex<uint16_t> (length, 0x80);
|
D_PrintHex<uint16_t> (length, 0x80);
|
||||||
Notify(PSTR("\r\nData: "), 0x80);
|
Notify(PSTR("\r\nData: "), 0x80);
|
||||||
for (uint8_t i = 0; i < length; i++) {
|
for (uint8_t i = 0; i < length; i++) {
|
||||||
PrintHex<uint8_t> (l2capinbuf[13+i], 0x80);
|
D_PrintHex<uint8_t> (l2capinbuf[13+i], 0x80);
|
||||||
Notify(PSTR(" "), 0x80);
|
Notify(PSTR(" "), 0x80);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -232,7 +232,7 @@ void SPP::ACLData(uint8_t* l2capinbuf) {
|
||||||
#ifdef EXTRADEBUG
|
#ifdef EXTRADEBUG
|
||||||
else {
|
else {
|
||||||
Notify(PSTR("\r\nUnknown PDU: "));
|
Notify(PSTR("\r\nUnknown PDU: "));
|
||||||
PrintHex<uint8_t > (l2capinbuf[8], 0x80);
|
D_PrintHex<uint8_t > (l2capinbuf[8], 0x80);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
} else if (l2capinbuf[6] == rfcomm_dcid[0] && l2capinbuf[7] == rfcomm_dcid[1]) { // RFCOMM
|
} else if (l2capinbuf[6] == rfcomm_dcid[0] && l2capinbuf[7] == rfcomm_dcid[1]) { // RFCOMM
|
||||||
|
@ -247,20 +247,20 @@ void SPP::ACLData(uint8_t* l2capinbuf) {
|
||||||
|
|
||||||
#ifdef EXTRADEBUG
|
#ifdef EXTRADEBUG
|
||||||
Notify(PSTR("\r\nRFCOMM Channel: "), 0x80);
|
Notify(PSTR("\r\nRFCOMM Channel: "), 0x80);
|
||||||
PrintHex<uint8_t > (rfcommChannel >> 3, 0x80);
|
D_PrintHex<uint8_t > (rfcommChannel >> 3, 0x80);
|
||||||
Notify(PSTR(" Direction: "), 0x80);
|
Notify(PSTR(" Direction: "), 0x80);
|
||||||
PrintHex<uint8_t > (rfcommDirection >> 2, 0x80);
|
D_PrintHex<uint8_t > (rfcommDirection >> 2, 0x80);
|
||||||
Notify(PSTR(" CommandResponse: "), 0x80);
|
Notify(PSTR(" CommandResponse: "), 0x80);
|
||||||
PrintHex<uint8_t > (rfcommCommandResponse >> 1, 0x80);
|
D_PrintHex<uint8_t > (rfcommCommandResponse >> 1, 0x80);
|
||||||
Notify(PSTR(" ChannelType: "), 0x80);
|
Notify(PSTR(" ChannelType: "), 0x80);
|
||||||
PrintHex<uint8_t > (rfcommChannelType, 0x80);
|
D_PrintHex<uint8_t > (rfcommChannelType, 0x80);
|
||||||
Notify(PSTR(" PF_BIT: "), 0x80);
|
Notify(PSTR(" PF_BIT: "), 0x80);
|
||||||
PrintHex<uint8_t > (rfcommPfBit, 0x80);
|
D_PrintHex<uint8_t > (rfcommPfBit, 0x80);
|
||||||
#endif
|
#endif
|
||||||
if (rfcommChannelType == RFCOMM_DISC) {
|
if (rfcommChannelType == RFCOMM_DISC) {
|
||||||
#ifdef DEBUG_USB_HOST
|
#ifdef DEBUG_USB_HOST
|
||||||
Notify(PSTR("\r\nReceived Disconnect RFCOMM Command on channel: "), 0x80);
|
Notify(PSTR("\r\nReceived Disconnect RFCOMM Command on channel: "), 0x80);
|
||||||
PrintHex<uint8_t > (rfcommChannel >> 3, 0x80);
|
D_PrintHex<uint8_t > (rfcommChannel >> 3, 0x80);
|
||||||
#endif
|
#endif
|
||||||
connected = false;
|
connected = false;
|
||||||
sendRfcomm(rfcommChannel, rfcommDirection, rfcommCommandResponse, RFCOMM_UA, rfcommPfBit, rfcommbuf, 0x00); // UA Command
|
sendRfcomm(rfcommChannel, rfcommDirection, rfcommCommandResponse, RFCOMM_UA, rfcommPfBit, rfcommbuf, 0x00); // UA Command
|
||||||
|
@ -280,7 +280,7 @@ void SPP::ACLData(uint8_t* l2capinbuf) {
|
||||||
Notify(rfcommAvailable, 0x80);
|
Notify(rfcommAvailable, 0x80);
|
||||||
if (offset) {
|
if (offset) {
|
||||||
Notify(PSTR(" - Credit: 0x"), 0x80);
|
Notify(PSTR(" - Credit: 0x"), 0x80);
|
||||||
PrintHex<uint8_t > (l2capinbuf[11], 0x80);
|
D_PrintHex<uint8_t > (l2capinbuf[11], 0x80);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#ifdef PRINTREPORT // Uncomment "#define PRINTREPORT" to print the report send to the Arduino via Bluetooth
|
#ifdef PRINTREPORT // Uncomment "#define PRINTREPORT" to print the report send to the Arduino via Bluetooth
|
||||||
|
@ -393,9 +393,9 @@ void SPP::ACLData(uint8_t* l2capinbuf) {
|
||||||
#ifdef DEBUG_USB_HOST
|
#ifdef DEBUG_USB_HOST
|
||||||
else if (rfcommChannelType != RFCOMM_DISC) {
|
else if (rfcommChannelType != RFCOMM_DISC) {
|
||||||
Notify(PSTR("\r\nUnsupported RFCOMM Data - ChannelType: "), 0x80);
|
Notify(PSTR("\r\nUnsupported RFCOMM Data - ChannelType: "), 0x80);
|
||||||
PrintHex<uint8_t > (rfcommChannelType, 0x80);
|
D_PrintHex<uint8_t > (rfcommChannelType, 0x80);
|
||||||
Notify(PSTR(" Command: "), 0x80);
|
Notify(PSTR(" Command: "), 0x80);
|
||||||
PrintHex<uint8_t > (l2capinbuf[11], 0x80);
|
D_PrintHex<uint8_t > (l2capinbuf[11], 0x80);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -403,9 +403,9 @@ void SPP::ACLData(uint8_t* l2capinbuf) {
|
||||||
#ifdef EXTRADEBUG
|
#ifdef EXTRADEBUG
|
||||||
else {
|
else {
|
||||||
Notify(PSTR("\r\nUnsupported L2CAP Data - Channel ID: "), 0x80);
|
Notify(PSTR("\r\nUnsupported L2CAP Data - Channel ID: "), 0x80);
|
||||||
PrintHex<uint8_t > (l2capinbuf[7], 0x80);
|
D_PrintHex<uint8_t > (l2capinbuf[7], 0x80);
|
||||||
Notify(PSTR(" "), 0x80);
|
Notify(PSTR(" "), 0x80);
|
||||||
PrintHex<uint8_t > (l2capinbuf[6], 0x80);
|
D_PrintHex<uint8_t > (l2capinbuf[6], 0x80);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
SDP_task();
|
SDP_task();
|
||||||
|
@ -698,7 +698,7 @@ void SPP::sendRfcomm(uint8_t channel, uint8_t direction, uint8_t CR, uint8_t cha
|
||||||
#ifdef EXTRADEBUG
|
#ifdef EXTRADEBUG
|
||||||
Notify(PSTR(" - RFCOMM Data: "), 0x80);
|
Notify(PSTR(" - RFCOMM Data: "), 0x80);
|
||||||
for (i = 0; i < length + 4; i++) {
|
for (i = 0; i < length + 4; i++) {
|
||||||
PrintHex<uint8_t > (l2capoutbuf[i], 0x80);
|
D_PrintHex<uint8_t > (l2capoutbuf[i], 0x80);
|
||||||
Notify(PSTR(" "), 0x80);
|
Notify(PSTR(" "), 0x80);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -714,7 +714,7 @@ void SPP::sendRfcommCredit(uint8_t channel, uint8_t direction, uint8_t CR, uint8
|
||||||
#ifdef EXTRADEBUG
|
#ifdef EXTRADEBUG
|
||||||
Notify(PSTR(" - RFCOMM Credit Data: "), 0x80);
|
Notify(PSTR(" - RFCOMM Credit Data: "), 0x80);
|
||||||
for (uint8_t i = 0; i < 5; i++) {
|
for (uint8_t i = 0; i < 5; i++) {
|
||||||
PrintHex<uint8_t > (l2capoutbuf[i], 0x80);
|
D_PrintHex<uint8_t > (l2capoutbuf[i], 0x80);
|
||||||
Notify(PSTR(" "), 0x80);
|
Notify(PSTR(" "), 0x80);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
2
Usb.h
2
Usb.h
|
@ -60,7 +60,7 @@ typedef MAX3421e<P10, P9> MAX3421E; // Official Arduinos (UNO, Duemilanove, Mega
|
||||||
|
|
||||||
//Debug macros. In 1.0 it is possible to move strings to PROGMEM by defining USBTRACE (USB_HOST_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), D_PrintHex((r), 0x80), Notify(PSTR("\r\n"), 0x80))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
42
Wii.cpp
42
Wii.cpp
|
@ -146,17 +146,17 @@ void WII::ACLData(uint8_t* l2capinbuf) {
|
||||||
if (l2capinbuf[8] == L2CAP_CMD_COMMAND_REJECT) {
|
if (l2capinbuf[8] == L2CAP_CMD_COMMAND_REJECT) {
|
||||||
#ifdef DEBUG_USB_HOST
|
#ifdef DEBUG_USB_HOST
|
||||||
Notify(PSTR("\r\nL2CAP Command Rejected - Reason: "), 0x80);
|
Notify(PSTR("\r\nL2CAP Command Rejected - Reason: "), 0x80);
|
||||||
PrintHex<uint8_t > (l2capinbuf[13], 0x80);
|
D_PrintHex<uint8_t > (l2capinbuf[13], 0x80);
|
||||||
Notify(PSTR(" "), 0x80);
|
Notify(PSTR(" "), 0x80);
|
||||||
PrintHex<uint8_t > (l2capinbuf[12], 0x80);
|
D_PrintHex<uint8_t > (l2capinbuf[12], 0x80);
|
||||||
Notify(PSTR(" "), 0x80);
|
Notify(PSTR(" "), 0x80);
|
||||||
PrintHex<uint8_t > (l2capinbuf[17], 0x80);
|
D_PrintHex<uint8_t > (l2capinbuf[17], 0x80);
|
||||||
Notify(PSTR(" "), 0x80);
|
Notify(PSTR(" "), 0x80);
|
||||||
PrintHex<uint8_t > (l2capinbuf[16], 0x80);
|
D_PrintHex<uint8_t > (l2capinbuf[16], 0x80);
|
||||||
Notify(PSTR(" "), 0x80);
|
Notify(PSTR(" "), 0x80);
|
||||||
PrintHex<uint8_t > (l2capinbuf[15], 0x80);
|
D_PrintHex<uint8_t > (l2capinbuf[15], 0x80);
|
||||||
Notify(PSTR(" "), 0x80);
|
Notify(PSTR(" "), 0x80);
|
||||||
PrintHex<uint8_t > (l2capinbuf[14], 0x80);
|
D_PrintHex<uint8_t > (l2capinbuf[14], 0x80);
|
||||||
#endif
|
#endif
|
||||||
} else if (l2capinbuf[8] == L2CAP_CMD_CONNECTION_RESPONSE) {
|
} else if (l2capinbuf[8] == L2CAP_CMD_CONNECTION_RESPONSE) {
|
||||||
if (((l2capinbuf[16] | (l2capinbuf[17] << 8)) == 0x0000) && ((l2capinbuf[18] | (l2capinbuf[19] << 8)) == SUCCESSFUL)) { // Success
|
if (((l2capinbuf[16] | (l2capinbuf[17] << 8)) == 0x0000) && ((l2capinbuf[18] | (l2capinbuf[19] << 8)) == SUCCESSFUL)) { // Success
|
||||||
|
@ -177,15 +177,15 @@ void WII::ACLData(uint8_t* l2capinbuf) {
|
||||||
} else if (l2capinbuf[8] == L2CAP_CMD_CONNECTION_REQUEST) {
|
} else if (l2capinbuf[8] == L2CAP_CMD_CONNECTION_REQUEST) {
|
||||||
#ifdef EXTRADEBUG
|
#ifdef EXTRADEBUG
|
||||||
Notify(PSTR("\r\nL2CAP Connection Request - PSM: "), 0x80);
|
Notify(PSTR("\r\nL2CAP Connection Request - PSM: "), 0x80);
|
||||||
PrintHex<uint8_t > (l2capinbuf[13], 0x80);
|
D_PrintHex<uint8_t > (l2capinbuf[13], 0x80);
|
||||||
Notify(PSTR(" "), 0x80);
|
Notify(PSTR(" "), 0x80);
|
||||||
PrintHex<uint8_t > (l2capinbuf[12], 0x80);
|
D_PrintHex<uint8_t > (l2capinbuf[12], 0x80);
|
||||||
Notify(PSTR(" SCID: "), 0x80);
|
Notify(PSTR(" SCID: "), 0x80);
|
||||||
PrintHex<uint8_t > (l2capinbuf[15], 0x80);
|
D_PrintHex<uint8_t > (l2capinbuf[15], 0x80);
|
||||||
Notify(PSTR(" "), 0x80);
|
Notify(PSTR(" "), 0x80);
|
||||||
PrintHex<uint8_t > (l2capinbuf[14], 0x80);
|
D_PrintHex<uint8_t > (l2capinbuf[14], 0x80);
|
||||||
Notify(PSTR(" Identifier: "), 0x80);
|
Notify(PSTR(" Identifier: "), 0x80);
|
||||||
PrintHex<uint8_t > (l2capinbuf[9], 0x80);
|
D_PrintHex<uint8_t > (l2capinbuf[9], 0x80);
|
||||||
#endif
|
#endif
|
||||||
if ((l2capinbuf[12] | (l2capinbuf[13] << 8)) == HID_CTRL_PSM) {
|
if ((l2capinbuf[12] | (l2capinbuf[13] << 8)) == HID_CTRL_PSM) {
|
||||||
identifier = l2capinbuf[9];
|
identifier = l2capinbuf[9];
|
||||||
|
@ -249,7 +249,7 @@ void WII::ACLData(uint8_t* l2capinbuf) {
|
||||||
else {
|
else {
|
||||||
identifier = l2capinbuf[9];
|
identifier = l2capinbuf[9];
|
||||||
Notify(PSTR("\r\nL2CAP Unknown Signaling Command: "), 0x80);
|
Notify(PSTR("\r\nL2CAP Unknown Signaling Command: "), 0x80);
|
||||||
PrintHex<uint8_t > (l2capinbuf[8], 0x80);
|
D_PrintHex<uint8_t > (l2capinbuf[8], 0x80);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
} else if (l2capinbuf[6] == interrupt_dcid[0] && l2capinbuf[7] == interrupt_dcid[1]) { // l2cap_interrupt
|
} else if (l2capinbuf[6] == interrupt_dcid[0] && l2capinbuf[7] == interrupt_dcid[1]) { // l2cap_interrupt
|
||||||
|
@ -274,7 +274,7 @@ void WII::ACLData(uint8_t* l2capinbuf) {
|
||||||
ButtonState = (uint32_t)((l2capinbuf[10] & 0x1F) | ((uint16_t)(l2capinbuf[11] & 0x9F) << 8));
|
ButtonState = (uint32_t)((l2capinbuf[10] & 0x1F) | ((uint16_t)(l2capinbuf[11] & 0x9F) << 8));
|
||||||
#ifdef PRINTREPORT
|
#ifdef PRINTREPORT
|
||||||
Notify(PSTR("ButtonState: "), 0x80);
|
Notify(PSTR("ButtonState: "), 0x80);
|
||||||
PrintHex<uint32_t > (ButtonState, 0x80);
|
D_PrintHex<uint32_t > (ButtonState, 0x80);
|
||||||
Notify(PSTR("\r\n"), 0x80);
|
Notify(PSTR("\r\n"), 0x80);
|
||||||
#endif
|
#endif
|
||||||
if (ButtonState != OldButtonState) {
|
if (ButtonState != OldButtonState) {
|
||||||
|
@ -373,11 +373,11 @@ void WII::ACLData(uint8_t* l2capinbuf) {
|
||||||
#ifdef DEBUG_USB_HOST
|
#ifdef DEBUG_USB_HOST
|
||||||
else {
|
else {
|
||||||
Notify(PSTR("\r\nUnknown Device: "), 0x80);
|
Notify(PSTR("\r\nUnknown Device: "), 0x80);
|
||||||
PrintHex<uint8_t > (l2capinbuf[13], 0x80);
|
D_PrintHex<uint8_t > (l2capinbuf[13], 0x80);
|
||||||
PrintHex<uint8_t > (l2capinbuf[14], 0x80);
|
D_PrintHex<uint8_t > (l2capinbuf[14], 0x80);
|
||||||
Notify(PSTR("\r\nData: "), 0x80);
|
Notify(PSTR("\r\nData: "), 0x80);
|
||||||
for (uint8_t i = 0; i < ((l2capinbuf[12] >> 4) + 1); i++) { // bit 4-7 is the length-1
|
for (uint8_t i = 0; i < ((l2capinbuf[12] >> 4) + 1); i++) { // bit 4-7 is the length-1
|
||||||
PrintHex<uint8_t > (l2capinbuf[15 + i], 0x80);
|
D_PrintHex<uint8_t > (l2capinbuf[15 + i], 0x80);
|
||||||
Notify(PSTR(" "), 0x80);
|
Notify(PSTR(" "), 0x80);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -386,8 +386,8 @@ void WII::ACLData(uint8_t* l2capinbuf) {
|
||||||
#ifdef EXTRADEBUG
|
#ifdef EXTRADEBUG
|
||||||
else {
|
else {
|
||||||
Notify(PSTR("\r\nReport Error: "), 0x80);
|
Notify(PSTR("\r\nReport Error: "), 0x80);
|
||||||
PrintHex<uint8_t > (l2capinbuf[13], 0x80);
|
D_PrintHex<uint8_t > (l2capinbuf[13], 0x80);
|
||||||
PrintHex<uint8_t > (l2capinbuf[14], 0x80);
|
D_PrintHex<uint8_t > (l2capinbuf[14], 0x80);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
|
@ -395,7 +395,7 @@ void WII::ACLData(uint8_t* l2capinbuf) {
|
||||||
#ifdef DEBUG_USB_HOST
|
#ifdef DEBUG_USB_HOST
|
||||||
if (l2capinbuf[13] != 0x00) { // Check if there is an error
|
if (l2capinbuf[13] != 0x00) { // Check if there is an error
|
||||||
Notify(PSTR("\r\nCommand failed: "), 0x80);
|
Notify(PSTR("\r\nCommand failed: "), 0x80);
|
||||||
PrintHex<uint8_t > (l2capinbuf[12], 0x80);
|
D_PrintHex<uint8_t > (l2capinbuf[12], 0x80);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
|
@ -567,7 +567,7 @@ void WII::ACLData(uint8_t* l2capinbuf) {
|
||||||
#ifdef DEBUG_USB_HOST
|
#ifdef DEBUG_USB_HOST
|
||||||
default:
|
default:
|
||||||
Notify(PSTR("\r\nUnknown Report type: "), 0x80);
|
Notify(PSTR("\r\nUnknown Report type: "), 0x80);
|
||||||
PrintHex<uint8_t > (l2capinbuf[9], 0x80);
|
D_PrintHex<uint8_t > (l2capinbuf[9], 0x80);
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -1104,7 +1104,7 @@ void WII::IRinitialize() { // Turns on and initialises the IR camera
|
||||||
setWiiModeNumber(mode_num); // Change input for whatever mode you want i.e. 0x01, 0x03, or 0x05
|
setWiiModeNumber(mode_num); // Change input for whatever mode you want i.e. 0x01, 0x03, or 0x05
|
||||||
#ifdef DEBUG_USB_HOST
|
#ifdef DEBUG_USB_HOST
|
||||||
Notify(PSTR("\r\nSet Wii Mode Number To 0x"), 0x80);
|
Notify(PSTR("\r\nSet Wii Mode Number To 0x"), 0x80);
|
||||||
PrintHex<uint8_t > (mode_num, 0x80);
|
D_PrintHex<uint8_t > (mode_num, 0x80);
|
||||||
#endif
|
#endif
|
||||||
delay(80);
|
delay(80);
|
||||||
|
|
||||||
|
|
|
@ -120,13 +120,13 @@ uint8_t XBOXRECV::Init(uint8_t parent, uint8_t port, bool lowspeed) {
|
||||||
bAddress = 0;
|
bAddress = 0;
|
||||||
#ifdef DEBUG_USB_HOST
|
#ifdef DEBUG_USB_HOST
|
||||||
Notify(PSTR("\r\nsetAddr: "), 0x80);
|
Notify(PSTR("\r\nsetAddr: "), 0x80);
|
||||||
PrintHex<uint8_t > (rcode, 0x80);
|
D_PrintHex<uint8_t > (rcode, 0x80);
|
||||||
#endif
|
#endif
|
||||||
return rcode;
|
return rcode;
|
||||||
}
|
}
|
||||||
#ifdef EXTRADEBUG
|
#ifdef EXTRADEBUG
|
||||||
Notify(PSTR("\r\nAddr: "), 0x80);
|
Notify(PSTR("\r\nAddr: "), 0x80);
|
||||||
PrintHex<uint8_t > (bAddress, 0x80);
|
D_PrintHex<uint8_t > (bAddress, 0x80);
|
||||||
#endif
|
#endif
|
||||||
p->lowspeed = false;
|
p->lowspeed = false;
|
||||||
|
|
||||||
|
@ -286,7 +286,7 @@ uint8_t XBOXRECV::Poll() {
|
||||||
if (bufferSize > 0) { // The number of received bytes
|
if (bufferSize > 0) { // The number of received bytes
|
||||||
#ifdef EXTRADEBUG
|
#ifdef EXTRADEBUG
|
||||||
Notify(PSTR("Bytes Received: "), 0x80);
|
Notify(PSTR("Bytes Received: "), 0x80);
|
||||||
PrintHex<uint16_t > (bufferSize, 0x80);
|
D_PrintHex<uint16_t > (bufferSize, 0x80);
|
||||||
Notify(PSTR("\r\n"), 0x80);
|
Notify(PSTR("\r\n"), 0x80);
|
||||||
#endif
|
#endif
|
||||||
readReport(i);
|
readReport(i);
|
||||||
|
@ -382,7 +382,7 @@ void XBOXRECV::printReport(uint8_t controller, uint8_t nBytes) { //Uncomment "#d
|
||||||
Notify(controller, 0x80);
|
Notify(controller, 0x80);
|
||||||
Notify(PSTR(": "), 0x80);
|
Notify(PSTR(": "), 0x80);
|
||||||
for (uint8_t i = 0; i < nBytes; i++) {
|
for (uint8_t i = 0; i < nBytes; i++) {
|
||||||
PrintHex<uint8_t > (readBuf[i], 0x80);
|
D_PrintHex<uint8_t > (readBuf[i], 0x80);
|
||||||
Notify(PSTR(" "), 0x80);
|
Notify(PSTR(" "), 0x80);
|
||||||
}
|
}
|
||||||
Notify(PSTR("\r\n"), 0x80);
|
Notify(PSTR("\r\n"), 0x80);
|
||||||
|
|
|
@ -124,12 +124,12 @@ uint8_t XBOXUSB::Init(uint8_t parent, uint8_t port, bool lowspeed) {
|
||||||
#ifdef DEBUG_USB_HOST
|
#ifdef DEBUG_USB_HOST
|
||||||
Notify(PSTR("\r\nsetAddr: "), 0x80);
|
Notify(PSTR("\r\nsetAddr: "), 0x80);
|
||||||
#endif
|
#endif
|
||||||
PrintHex<uint8_t > (rcode, 0x80);
|
D_PrintHex<uint8_t > (rcode, 0x80);
|
||||||
return rcode;
|
return rcode;
|
||||||
}
|
}
|
||||||
#ifdef EXTRADEBUG
|
#ifdef EXTRADEBUG
|
||||||
Notify(PSTR("\r\nAddr: "), 0x80);
|
Notify(PSTR("\r\nAddr: "), 0x80);
|
||||||
PrintHex<uint8_t > (bAddress, 0x80);
|
D_PrintHex<uint8_t > (bAddress, 0x80);
|
||||||
#endif
|
#endif
|
||||||
p->lowspeed = false;
|
p->lowspeed = false;
|
||||||
|
|
||||||
|
@ -267,7 +267,7 @@ void XBOXUSB::printReport() { //Uncomment "#define PRINTREPORT" to print the rep
|
||||||
if (readBuf == NULL)
|
if (readBuf == NULL)
|
||||||
return;
|
return;
|
||||||
for (uint8_t i = 0; i < XBOX_REPORT_BUFFER_SIZE; i++) {
|
for (uint8_t i = 0; i < XBOX_REPORT_BUFFER_SIZE; i++) {
|
||||||
PrintHex<uint8_t > (readBuf[i], 0x80);
|
D_PrintHex<uint8_t > (readBuf[i], 0x80);
|
||||||
Notify(PSTR(" "), 0x80);
|
Notify(PSTR(" "), 0x80);
|
||||||
}
|
}
|
||||||
Notify(PSTR("\r\n"), 0x80);
|
Notify(PSTR("\r\n"), 0x80);
|
||||||
|
|
12
adk.cpp
12
adk.cpp
|
@ -329,16 +329,16 @@ uint8_t ADK::SndData(uint16_t nbytes, uint8_t *dataptr) {
|
||||||
void ADK::PrintEndpointDescriptor(const USB_ENDPOINT_DESCRIPTOR* ep_ptr) {
|
void ADK::PrintEndpointDescriptor(const USB_ENDPOINT_DESCRIPTOR* ep_ptr) {
|
||||||
Notify(PSTR("Endpoint descriptor:"), 0x80);
|
Notify(PSTR("Endpoint descriptor:"), 0x80);
|
||||||
Notify(PSTR("\r\nLength:\t\t"), 0x80);
|
Notify(PSTR("\r\nLength:\t\t"), 0x80);
|
||||||
PrintHex<uint8_t > (ep_ptr->bLength, 0x80);
|
D_PrintHex<uint8_t > (ep_ptr->bLength, 0x80);
|
||||||
Notify(PSTR("\r\nType:\t\t"), 0x80);
|
Notify(PSTR("\r\nType:\t\t"), 0x80);
|
||||||
PrintHex<uint8_t > (ep_ptr->bDescriptorType, 0x80);
|
D_PrintHex<uint8_t > (ep_ptr->bDescriptorType, 0x80);
|
||||||
Notify(PSTR("\r\nAddress:\t"), 0x80);
|
Notify(PSTR("\r\nAddress:\t"), 0x80);
|
||||||
PrintHex<uint8_t > (ep_ptr->bEndpointAddress, 0x80);
|
D_PrintHex<uint8_t > (ep_ptr->bEndpointAddress, 0x80);
|
||||||
Notify(PSTR("\r\nAttributes:\t"), 0x80);
|
Notify(PSTR("\r\nAttributes:\t"), 0x80);
|
||||||
PrintHex<uint8_t > (ep_ptr->bmAttributes, 0x80);
|
D_PrintHex<uint8_t > (ep_ptr->bmAttributes, 0x80);
|
||||||
Notify(PSTR("\r\nMaxPktSize:\t"), 0x80);
|
Notify(PSTR("\r\nMaxPktSize:\t"), 0x80);
|
||||||
PrintHex<uint16_t > (ep_ptr->wMaxPacketSize, 0x80);
|
D_PrintHex<uint16_t > (ep_ptr->wMaxPacketSize, 0x80);
|
||||||
Notify(PSTR("\r\nPoll Intrv:\t"), 0x80);
|
Notify(PSTR("\r\nPoll Intrv:\t"), 0x80);
|
||||||
PrintHex<uint8_t > (ep_ptr->bInterval, 0x80);
|
D_PrintHex<uint8_t > (ep_ptr->bInterval, 0x80);
|
||||||
Notify(PSTR("\r\n"), 0x80);
|
Notify(PSTR("\r\n"), 0x80);
|
||||||
}
|
}
|
||||||
|
|
12
cdcacm.cpp
12
cdcacm.cpp
|
@ -334,16 +334,16 @@ uint8_t ACM::SendBreak(uint16_t duration) {
|
||||||
void ACM::PrintEndpointDescriptor(const USB_ENDPOINT_DESCRIPTOR* ep_ptr) {
|
void ACM::PrintEndpointDescriptor(const USB_ENDPOINT_DESCRIPTOR* ep_ptr) {
|
||||||
Notify(PSTR("Endpoint descriptor:"), 0x80);
|
Notify(PSTR("Endpoint descriptor:"), 0x80);
|
||||||
Notify(PSTR("\r\nLength:\t\t"), 0x80);
|
Notify(PSTR("\r\nLength:\t\t"), 0x80);
|
||||||
PrintHex<uint8_t > (ep_ptr->bLength, 0x80);
|
D_PrintHex<uint8_t > (ep_ptr->bLength, 0x80);
|
||||||
Notify(PSTR("\r\nType:\t\t"), 0x80);
|
Notify(PSTR("\r\nType:\t\t"), 0x80);
|
||||||
PrintHex<uint8_t > (ep_ptr->bDescriptorType, 0x80);
|
D_PrintHex<uint8_t > (ep_ptr->bDescriptorType, 0x80);
|
||||||
Notify(PSTR("\r\nAddress:\t"), 0x80);
|
Notify(PSTR("\r\nAddress:\t"), 0x80);
|
||||||
PrintHex<uint8_t > (ep_ptr->bEndpointAddress, 0x80);
|
D_PrintHex<uint8_t > (ep_ptr->bEndpointAddress, 0x80);
|
||||||
Notify(PSTR("\r\nAttributes:\t"), 0x80);
|
Notify(PSTR("\r\nAttributes:\t"), 0x80);
|
||||||
PrintHex<uint8_t > (ep_ptr->bmAttributes, 0x80);
|
D_PrintHex<uint8_t > (ep_ptr->bmAttributes, 0x80);
|
||||||
Notify(PSTR("\r\nMaxPktSize:\t"), 0x80);
|
Notify(PSTR("\r\nMaxPktSize:\t"), 0x80);
|
||||||
PrintHex<uint16_t > (ep_ptr->wMaxPacketSize, 0x80);
|
D_PrintHex<uint16_t > (ep_ptr->wMaxPacketSize, 0x80);
|
||||||
Notify(PSTR("\r\nPoll Intrv:\t"), 0x80);
|
Notify(PSTR("\r\nPoll Intrv:\t"), 0x80);
|
||||||
PrintHex<uint8_t > (ep_ptr->bInterval, 0x80);
|
D_PrintHex<uint8_t > (ep_ptr->bInterval, 0x80);
|
||||||
Notify(PSTR("\r\n"), 0x80);
|
Notify(PSTR("\r\n"), 0x80);
|
||||||
}
|
}
|
||||||
|
|
12
cdcftdi.cpp
12
cdcftdi.cpp
|
@ -326,16 +326,16 @@ uint8_t FTDI::SndData(uint16_t nbytes, uint8_t *dataptr) {
|
||||||
void FTDI::PrintEndpointDescriptor(const USB_ENDPOINT_DESCRIPTOR* ep_ptr) {
|
void FTDI::PrintEndpointDescriptor(const USB_ENDPOINT_DESCRIPTOR* ep_ptr) {
|
||||||
Notify(PSTR("Endpoint descriptor:"), 0x80);
|
Notify(PSTR("Endpoint descriptor:"), 0x80);
|
||||||
Notify(PSTR("\r\nLength:\t\t"), 0x80);
|
Notify(PSTR("\r\nLength:\t\t"), 0x80);
|
||||||
PrintHex<uint8_t > (ep_ptr->bLength, 0x80);
|
D_PrintHex<uint8_t > (ep_ptr->bLength, 0x80);
|
||||||
Notify(PSTR("\r\nType:\t\t"), 0x80);
|
Notify(PSTR("\r\nType:\t\t"), 0x80);
|
||||||
PrintHex<uint8_t > (ep_ptr->bDescriptorType, 0x80);
|
D_PrintHex<uint8_t > (ep_ptr->bDescriptorType, 0x80);
|
||||||
Notify(PSTR("\r\nAddress:\t"), 0x80);
|
Notify(PSTR("\r\nAddress:\t"), 0x80);
|
||||||
PrintHex<uint8_t > (ep_ptr->bEndpointAddress, 0x80);
|
D_PrintHex<uint8_t > (ep_ptr->bEndpointAddress, 0x80);
|
||||||
Notify(PSTR("\r\nAttributes:\t"), 0x80);
|
Notify(PSTR("\r\nAttributes:\t"), 0x80);
|
||||||
PrintHex<uint8_t > (ep_ptr->bmAttributes, 0x80);
|
D_PrintHex<uint8_t > (ep_ptr->bmAttributes, 0x80);
|
||||||
Notify(PSTR("\r\nMaxPktSize:\t"), 0x80);
|
Notify(PSTR("\r\nMaxPktSize:\t"), 0x80);
|
||||||
PrintHex<uint16_t > (ep_ptr->wMaxPacketSize, 0x80);
|
D_PrintHex<uint16_t > (ep_ptr->wMaxPacketSize, 0x80);
|
||||||
Notify(PSTR("\r\nPoll Intrv:\t"), 0x80);
|
Notify(PSTR("\r\nPoll Intrv:\t"), 0x80);
|
||||||
PrintHex<uint8_t > (ep_ptr->bInterval, 0x80);
|
D_PrintHex<uint8_t > (ep_ptr->bInterval, 0x80);
|
||||||
Notify(PSTR("\r\n"), 0x80);
|
Notify(PSTR("\r\n"), 0x80);
|
||||||
}
|
}
|
||||||
|
|
|
@ -175,19 +175,19 @@ template <const uint8_t CLASS_ID, const uint8_t SUBCLASS_ID, const uint8_t PROTO
|
||||||
void ConfigDescParser<CLASS_ID, SUBCLASS_ID, PROTOCOL_ID, MASK>::PrintHidDescriptor(const USB_HID_DESCRIPTOR *pDesc) {
|
void ConfigDescParser<CLASS_ID, SUBCLASS_ID, PROTOCOL_ID, MASK>::PrintHidDescriptor(const USB_HID_DESCRIPTOR *pDesc) {
|
||||||
Notify(PSTR("\r\n\r\nHID Descriptor:\r\n"), 0x80);
|
Notify(PSTR("\r\n\r\nHID Descriptor:\r\n"), 0x80);
|
||||||
Notify(PSTR("bDescLength:\t\t"), 0x80);
|
Notify(PSTR("bDescLength:\t\t"), 0x80);
|
||||||
PrintHex<uint8_t > (pDesc->bLength, 0x80);
|
D_PrintHex<uint8_t > (pDesc->bLength, 0x80);
|
||||||
|
|
||||||
Notify(PSTR("\r\nbDescriptorType:\t"), 0x80);
|
Notify(PSTR("\r\nbDescriptorType:\t"), 0x80);
|
||||||
PrintHex<uint8_t > (pDesc->bDescriptorType, 0x80);
|
D_PrintHex<uint8_t > (pDesc->bDescriptorType, 0x80);
|
||||||
|
|
||||||
Notify(PSTR("\r\nbcdHID:\t\t\t"), 0x80);
|
Notify(PSTR("\r\nbcdHID:\t\t\t"), 0x80);
|
||||||
PrintHex<uint16_t > (pDesc->bcdHID, 0x80);
|
D_PrintHex<uint16_t > (pDesc->bcdHID, 0x80);
|
||||||
|
|
||||||
Notify(PSTR("\r\nbCountryCode:\t\t"), 0x80);
|
Notify(PSTR("\r\nbCountryCode:\t\t"), 0x80);
|
||||||
PrintHex<uint8_t > (pDesc->bCountryCode, 0x80);
|
D_PrintHex<uint8_t > (pDesc->bCountryCode, 0x80);
|
||||||
|
|
||||||
Notify(PSTR("\r\nbNumDescriptors:\t"), 0x80);
|
Notify(PSTR("\r\nbNumDescriptors:\t"), 0x80);
|
||||||
PrintHex<uint8_t > (pDesc->bNumDescriptors, 0x80);
|
D_PrintHex<uint8_t > (pDesc->bNumDescriptors, 0x80);
|
||||||
|
|
||||||
//Notify(PSTR("\r\nbDescrType:\t\t"));
|
//Notify(PSTR("\r\nbDescrType:\t\t"));
|
||||||
//PrintHex<uint8_t>(pDesc->bDescrType);
|
//PrintHex<uint8_t>(pDesc->bDescrType);
|
||||||
|
@ -199,10 +199,10 @@ void ConfigDescParser<CLASS_ID, SUBCLASS_ID, PROTOCOL_ID, MASK>::PrintHidDescrip
|
||||||
HID_CLASS_DESCRIPTOR_LEN_AND_TYPE *pLT = (HID_CLASS_DESCRIPTOR_LEN_AND_TYPE*)&(pDesc->bDescrType);
|
HID_CLASS_DESCRIPTOR_LEN_AND_TYPE *pLT = (HID_CLASS_DESCRIPTOR_LEN_AND_TYPE*)&(pDesc->bDescrType);
|
||||||
|
|
||||||
Notify(PSTR("\r\nbDescrType:\t\t"), 0x80);
|
Notify(PSTR("\r\nbDescrType:\t\t"), 0x80);
|
||||||
PrintHex<uint8_t > (pLT[i].bDescrType, 0x80);
|
D_PrintHex<uint8_t > (pLT[i].bDescrType, 0x80);
|
||||||
|
|
||||||
Notify(PSTR("\r\nwDescriptorLength:\t"), 0x80);
|
Notify(PSTR("\r\nwDescriptorLength:\t"), 0x80);
|
||||||
PrintHex<uint16_t > (pLT[i].wDescriptorLength, 0x80);
|
D_PrintHex<uint16_t > (pLT[i].wDescriptorLength, 0x80);
|
||||||
}
|
}
|
||||||
Notify(PSTR("\r\n"), 0x80);
|
Notify(PSTR("\r\n"), 0x80);
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,7 +37,7 @@ void KbdRptParser::PrintKey(uint8_t m, uint8_t key)
|
||||||
Serial.print((mod.bmLeftGUI == 1) ? "G" : " ");
|
Serial.print((mod.bmLeftGUI == 1) ? "G" : " ");
|
||||||
|
|
||||||
Serial.print(" >");
|
Serial.print(" >");
|
||||||
PrintHex<uint8_t>(key, 0x80);
|
D_PrintHex<uint8_t>(key, 0x80);
|
||||||
Serial.print("< ");
|
Serial.print("< ");
|
||||||
|
|
||||||
Serial.print((mod.bmRightCtrl == 1) ? "C" : " ");
|
Serial.print((mod.bmRightCtrl == 1) ? "C" : " ");
|
||||||
|
|
|
@ -63,22 +63,22 @@ void JoystickReportParser::Parse(HID *hid, bool is_rpt_id, uint8_t len, uint8_t
|
||||||
void JoystickEvents::OnGamePadChanged(const GamePadEventData *evt)
|
void JoystickEvents::OnGamePadChanged(const GamePadEventData *evt)
|
||||||
{
|
{
|
||||||
Serial.print("X: ");
|
Serial.print("X: ");
|
||||||
PrintHex<uint8_t>(evt->X, 0x80);
|
D_PrintHex<uint8_t>(evt->X, 0x80);
|
||||||
Serial.print("\tY: ");
|
Serial.print("\tY: ");
|
||||||
PrintHex<uint8_t>(evt->Y, 0x80);
|
D_PrintHex<uint8_t>(evt->Y, 0x80);
|
||||||
Serial.print("\tZ: ");
|
Serial.print("\tZ: ");
|
||||||
PrintHex<uint8_t>(evt->Z1, 0x80);
|
D_PrintHex<uint8_t>(evt->Z1, 0x80);
|
||||||
Serial.print("\tZ: ");
|
Serial.print("\tZ: ");
|
||||||
PrintHex<uint8_t>(evt->Z2, 0x80);
|
D_PrintHex<uint8_t>(evt->Z2, 0x80);
|
||||||
Serial.print("\tRz: ");
|
Serial.print("\tRz: ");
|
||||||
PrintHex<uint8_t>(evt->Rz, 0x80);
|
D_PrintHex<uint8_t>(evt->Rz, 0x80);
|
||||||
Serial.println("");
|
Serial.println("");
|
||||||
}
|
}
|
||||||
|
|
||||||
void JoystickEvents::OnHatSwitch(uint8_t hat)
|
void JoystickEvents::OnHatSwitch(uint8_t hat)
|
||||||
{
|
{
|
||||||
Serial.print("Hat Switch: ");
|
Serial.print("Hat Switch: ");
|
||||||
PrintHex<uint8_t>(hat, 0x80);
|
D_PrintHex<uint8_t>(hat, 0x80);
|
||||||
Serial.println("");
|
Serial.println("");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -26,18 +26,18 @@ void JoystickReportParser::Parse(HID *hid, bool is_rpt_id, uint8_t len, uint8_t
|
||||||
void JoystickEvents::OnGamePadChanged(const GamePadEventData *evt)
|
void JoystickEvents::OnGamePadChanged(const GamePadEventData *evt)
|
||||||
{
|
{
|
||||||
Serial.print("X: ");
|
Serial.print("X: ");
|
||||||
PrintHex<uint16_t>(evt->x, 0x80);
|
D_PrintHex<uint16_t>(evt->x, 0x80);
|
||||||
Serial.print(" Y: ");
|
Serial.print(" Y: ");
|
||||||
PrintHex<uint16_t>(evt->y, 0x80);
|
D_PrintHex<uint16_t>(evt->y, 0x80);
|
||||||
Serial.print(" Hat Switch: ");
|
Serial.print(" Hat Switch: ");
|
||||||
PrintHex<uint8_t>(evt->hat, 0x80);
|
D_PrintHex<uint8_t>(evt->hat, 0x80);
|
||||||
Serial.print(" Twist: ");
|
Serial.print(" Twist: ");
|
||||||
PrintHex<uint8_t>(evt->twist, 0x80);
|
D_PrintHex<uint8_t>(evt->twist, 0x80);
|
||||||
Serial.print(" Slider: ");
|
Serial.print(" Slider: ");
|
||||||
PrintHex<uint8_t>(evt->slider, 0x80);
|
D_PrintHex<uint8_t>(evt->slider, 0x80);
|
||||||
Serial.print(" Buttons A: ");
|
Serial.print(" Buttons A: ");
|
||||||
PrintHex<uint8_t>(evt->buttons_a, 0x80);
|
D_PrintHex<uint8_t>(evt->buttons_a, 0x80);
|
||||||
Serial.print(" Buttons B: ");
|
Serial.print(" Buttons B: ");
|
||||||
PrintHex<uint8_t>(evt->buttons_b, 0x80);
|
D_PrintHex<uint8_t>(evt->buttons_b, 0x80);
|
||||||
Serial.println("");
|
Serial.println("");
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,10 +47,10 @@ void HexDumper<BASE_CLASS, LEN_TYPE, OFFSET_TYPE>::Parse(const LEN_TYPE len, con
|
||||||
if(UsbDEBUGlvl >= 0x80) { // Fully bypass this block of code if we do not debug.
|
if(UsbDEBUGlvl >= 0x80) { // Fully bypass this block of code if we do not debug.
|
||||||
for(LEN_TYPE j = 0; j < len; j++, byteCount++, byteTotal++) {
|
for(LEN_TYPE j = 0; j < len; j++, byteCount++, byteTotal++) {
|
||||||
if(!byteCount) {
|
if(!byteCount) {
|
||||||
PrintHex<OFFSET_TYPE > (byteTotal, 0x80);
|
D_PrintHex<OFFSET_TYPE > (byteTotal, 0x80);
|
||||||
E_Notify(PSTR(": "), 0x80);
|
E_Notify(PSTR(": "), 0x80);
|
||||||
}
|
}
|
||||||
PrintHex<uint8_t > (pbuf[j], 0x80);
|
D_PrintHex<uint8_t > (pbuf[j], 0x80);
|
||||||
E_Notify(PSTR(" "), 0x80);
|
E_Notify(PSTR(" "), 0x80);
|
||||||
|
|
||||||
if(byteCount == 15) {
|
if(byteCount == 15) {
|
||||||
|
|
26
hid.cpp
26
hid.cpp
|
@ -44,39 +44,39 @@ uint8_t HID::GetProtocol(uint8_t iface, uint8_t* dataptr) {
|
||||||
void HID::PrintEndpointDescriptor(const USB_ENDPOINT_DESCRIPTOR* ep_ptr) {
|
void HID::PrintEndpointDescriptor(const USB_ENDPOINT_DESCRIPTOR* ep_ptr) {
|
||||||
Notify(PSTR("Endpoint descriptor:"), 0x80);
|
Notify(PSTR("Endpoint descriptor:"), 0x80);
|
||||||
Notify(PSTR("\r\nLength:\t\t"), 0x80);
|
Notify(PSTR("\r\nLength:\t\t"), 0x80);
|
||||||
PrintHex<uint8_t > (ep_ptr->bLength, 0x80);
|
D_PrintHex<uint8_t > (ep_ptr->bLength, 0x80);
|
||||||
Notify(PSTR("\r\nType:\t\t"), 0x80);
|
Notify(PSTR("\r\nType:\t\t"), 0x80);
|
||||||
PrintHex<uint8_t > (ep_ptr->bDescriptorType, 0x80);
|
D_PrintHex<uint8_t > (ep_ptr->bDescriptorType, 0x80);
|
||||||
Notify(PSTR("\r\nAddress:\t"), 0x80);
|
Notify(PSTR("\r\nAddress:\t"), 0x80);
|
||||||
PrintHex<uint8_t > (ep_ptr->bEndpointAddress, 0x80);
|
D_PrintHex<uint8_t > (ep_ptr->bEndpointAddress, 0x80);
|
||||||
Notify(PSTR("\r\nAttributes:\t"), 0x80);
|
Notify(PSTR("\r\nAttributes:\t"), 0x80);
|
||||||
PrintHex<uint8_t > (ep_ptr->bmAttributes, 0x80);
|
D_PrintHex<uint8_t > (ep_ptr->bmAttributes, 0x80);
|
||||||
Notify(PSTR("\r\nMaxPktSize:\t"), 0x80);
|
Notify(PSTR("\r\nMaxPktSize:\t"), 0x80);
|
||||||
PrintHex<uint16_t > (ep_ptr->wMaxPacketSize, 0x80);
|
D_PrintHex<uint16_t > (ep_ptr->wMaxPacketSize, 0x80);
|
||||||
Notify(PSTR("\r\nPoll Intrv:\t"), 0x80);
|
Notify(PSTR("\r\nPoll Intrv:\t"), 0x80);
|
||||||
PrintHex<uint8_t > (ep_ptr->bInterval, 0x80);
|
D_PrintHex<uint8_t > (ep_ptr->bInterval, 0x80);
|
||||||
}
|
}
|
||||||
|
|
||||||
void HID::PrintHidDescriptor(const USB_HID_DESCRIPTOR *pDesc) {
|
void HID::PrintHidDescriptor(const USB_HID_DESCRIPTOR *pDesc) {
|
||||||
Notify(PSTR("\r\n\r\nHID Descriptor:\r\n"), 0x80);
|
Notify(PSTR("\r\n\r\nHID Descriptor:\r\n"), 0x80);
|
||||||
Notify(PSTR("bDescLength:\t\t"), 0x80);
|
Notify(PSTR("bDescLength:\t\t"), 0x80);
|
||||||
PrintHex<uint8_t > (pDesc->bLength, 0x80);
|
D_PrintHex<uint8_t > (pDesc->bLength, 0x80);
|
||||||
|
|
||||||
Notify(PSTR("\r\nbDescriptorType:\t"), 0x80);
|
Notify(PSTR("\r\nbDescriptorType:\t"), 0x80);
|
||||||
PrintHex<uint8_t > (pDesc->bDescriptorType, 0x80);
|
D_PrintHex<uint8_t > (pDesc->bDescriptorType, 0x80);
|
||||||
|
|
||||||
Notify(PSTR("\r\nbcdHID:\t\t\t"), 0x80);
|
Notify(PSTR("\r\nbcdHID:\t\t\t"), 0x80);
|
||||||
PrintHex<uint16_t > (pDesc->bcdHID, 0x80);
|
D_PrintHex<uint16_t > (pDesc->bcdHID, 0x80);
|
||||||
|
|
||||||
Notify(PSTR("\r\nbCountryCode:\t\t"), 0x80);
|
Notify(PSTR("\r\nbCountryCode:\t\t"), 0x80);
|
||||||
PrintHex<uint8_t > (pDesc->bCountryCode, 0x80);
|
D_PrintHex<uint8_t > (pDesc->bCountryCode, 0x80);
|
||||||
|
|
||||||
Notify(PSTR("\r\nbNumDescriptors:\t"), 0x80);
|
Notify(PSTR("\r\nbNumDescriptors:\t"), 0x80);
|
||||||
PrintHex<uint8_t > (pDesc->bNumDescriptors, 0x80);
|
D_PrintHex<uint8_t > (pDesc->bNumDescriptors, 0x80);
|
||||||
|
|
||||||
Notify(PSTR("\r\nbDescrType:\t\t"), 0x80);
|
Notify(PSTR("\r\nbDescrType:\t\t"), 0x80);
|
||||||
PrintHex<uint8_t > (pDesc->bDescrType, 0x80);
|
D_PrintHex<uint8_t > (pDesc->bDescrType, 0x80);
|
||||||
|
|
||||||
Notify(PSTR("\r\nwDescriptorLength:\t"), 0x80);
|
Notify(PSTR("\r\nwDescriptorLength:\t"), 0x80);
|
||||||
PrintHex<uint16_t > (pDesc->wDescriptorLength, 0x80);
|
D_PrintHex<uint16_t > (pDesc->wDescriptorLength, 0x80);
|
||||||
}
|
}
|
||||||
|
|
|
@ -996,13 +996,13 @@ void ReportDescParserBase::Parse(const uint16_t len, const uint8_t *pbuf, const
|
||||||
void ReportDescParserBase::PrintValue(uint8_t *p, uint8_t len) {
|
void ReportDescParserBase::PrintValue(uint8_t *p, uint8_t len) {
|
||||||
Notify(PSTR("("), 0x80);
|
Notify(PSTR("("), 0x80);
|
||||||
for (; len; p++, len--)
|
for (; len; p++, len--)
|
||||||
PrintHex<uint8_t > (*p, 0x80);
|
D_PrintHex<uint8_t > (*p, 0x80);
|
||||||
Notify(PSTR(")"), 0x80);
|
Notify(PSTR(")"), 0x80);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ReportDescParserBase::PrintByteValue(uint8_t data) {
|
void ReportDescParserBase::PrintByteValue(uint8_t data) {
|
||||||
Notify(PSTR("("), 0x80);
|
Notify(PSTR("("), 0x80);
|
||||||
PrintHex<uint8_t > (data, 0x80);
|
D_PrintHex<uint8_t > (data, 0x80);
|
||||||
Notify(PSTR(")"), 0x80);
|
Notify(PSTR(")"), 0x80);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1172,7 +1172,7 @@ uint8_t ReportDescParserBase::ParseItem(uint8_t **pp, uint16_t *pcntdn) {
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
Notify(PSTR(" Vendor Defined("), 0x80);
|
Notify(PSTR(" Vendor Defined("), 0x80);
|
||||||
PrintHex<uint8_t > (data, 0x80);
|
D_PrintHex<uint8_t > (data, 0x80);
|
||||||
Notify(PSTR(")"), 0x80);
|
Notify(PSTR(")"), 0x80);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -1183,7 +1183,7 @@ uint8_t ReportDescParserBase::ParseItem(uint8_t **pp, uint16_t *pcntdn) {
|
||||||
rptSize = 0;
|
rptSize = 0;
|
||||||
rptCount = 0;
|
rptCount = 0;
|
||||||
Notify(PSTR("("), 0x80);
|
Notify(PSTR("("), 0x80);
|
||||||
PrintBin<uint8_t > (data, 0x80);
|
D_PrintBin<uint8_t > (data, 0x80);
|
||||||
Notify(PSTR(")"), 0x80);
|
Notify(PSTR(")"), 0x80);
|
||||||
break;
|
break;
|
||||||
} // switch (**pp & (TYPE_MASK | TAG_MASK))
|
} // switch (**pp & (TYPE_MASK | TAG_MASK))
|
||||||
|
@ -1265,7 +1265,7 @@ void ReportDescParserBase::PrintUsagePage(uint16_t page) {
|
||||||
void ReportDescParserBase::PrintButtonPageUsage(uint16_t usage) {
|
void ReportDescParserBase::PrintButtonPageUsage(uint16_t usage) {
|
||||||
Notify(pstrSpace, 0x80);
|
Notify(pstrSpace, 0x80);
|
||||||
Notify(PSTR("Btn"), 0x80);
|
Notify(PSTR("Btn"), 0x80);
|
||||||
PrintHex<uint16_t > (usage, 0x80);
|
D_PrintHex<uint16_t > (usage, 0x80);
|
||||||
Notify(PSTR("\r\n"), 0x80);
|
Notify(PSTR("\r\n"), 0x80);
|
||||||
//USB_HOST_SERIAL.print(usage, HEX);
|
//USB_HOST_SERIAL.print(usage, HEX);
|
||||||
}
|
}
|
||||||
|
@ -1274,7 +1274,7 @@ void ReportDescParserBase::PrintOrdinalPageUsage(uint16_t usage) {
|
||||||
Notify(pstrSpace, 0x80);
|
Notify(pstrSpace, 0x80);
|
||||||
Notify(PSTR("Inst"), 0x80);
|
Notify(PSTR("Inst"), 0x80);
|
||||||
// Sorry, HEX for now...
|
// Sorry, HEX for now...
|
||||||
PrintHex<uint16_t > (usage, 0x80);
|
D_PrintHex<uint16_t > (usage, 0x80);
|
||||||
Notify(PSTR("\r\n"), 0x80);
|
Notify(PSTR("\r\n"), 0x80);
|
||||||
//USB_HOST_SERIAL.print(usage, DEC);
|
//USB_HOST_SERIAL.print(usage, DEC);
|
||||||
}
|
}
|
||||||
|
|
|
@ -374,7 +374,7 @@ uint8_t HIDUniversal::Poll() {
|
||||||
Notify(PSTR("\r\nBuf: "), 0x80);
|
Notify(PSTR("\r\nBuf: "), 0x80);
|
||||||
|
|
||||||
for (uint8_t i = 0; i < read; i++)
|
for (uint8_t i = 0; i < read; i++)
|
||||||
PrintHex<uint8_t > (buf[i], 0x80);
|
D_PrintHex<uint8_t > (buf[i], 0x80);
|
||||||
|
|
||||||
Notify(PSTR("\r\n"), 0x80);
|
Notify(PSTR("\r\n"), 0x80);
|
||||||
|
|
||||||
|
|
|
@ -134,14 +134,14 @@ uint8_t BulkOnly::MediaCTL(uint8_t lun, uint8_t ctl) {
|
||||||
uint8_t BulkOnly::Read(uint8_t lun, uint32_t addr, uint16_t bsize, uint8_t blocks, uint8_t *buf) {
|
uint8_t BulkOnly::Read(uint8_t lun, uint32_t addr, uint16_t bsize, uint8_t blocks, uint8_t *buf) {
|
||||||
if (!LUNOk[lun]) return MASS_ERR_NO_MEDIA;
|
if (!LUNOk[lun]) return MASS_ERR_NO_MEDIA;
|
||||||
Notify(PSTR("\r\nRead LUN:\t"), 0x80);
|
Notify(PSTR("\r\nRead LUN:\t"), 0x80);
|
||||||
PrintHex<uint8_t > (lun, 0x90);
|
D_PrintHex<uint8_t > (lun, 0x90);
|
||||||
//printf("LUN=%i LBA=%8.8X BLOCKS=%i SIZE=%i\r\n", lun, addr, blocks, bsize);
|
//printf("LUN=%i LBA=%8.8X BLOCKS=%i SIZE=%i\r\n", lun, addr, blocks, bsize);
|
||||||
Notify(PSTR("\r\nLBA:\t\t"), 0x90);
|
Notify(PSTR("\r\nLBA:\t\t"), 0x90);
|
||||||
PrintHex<uint32_t > (addr, 0x90);
|
D_PrintHex<uint32_t > (addr, 0x90);
|
||||||
Notify(PSTR("\r\nblocks:\t\t"), 0x90);
|
Notify(PSTR("\r\nblocks:\t\t"), 0x90);
|
||||||
PrintHex<uint8_t > (blocks, 0x90);
|
D_PrintHex<uint8_t > (blocks, 0x90);
|
||||||
Notify(PSTR("\r\nblock size:\t"), 0x90);
|
Notify(PSTR("\r\nblock size:\t"), 0x90);
|
||||||
PrintHex<uint16_t > (bsize, 0x90);
|
D_PrintHex<uint16_t > (bsize, 0x90);
|
||||||
Notify(PSTR("\r\n---------\r\n"), 0x80);
|
Notify(PSTR("\r\n---------\r\n"), 0x80);
|
||||||
CommandBlockWrapper cbw;
|
CommandBlockWrapper cbw;
|
||||||
|
|
||||||
|
@ -187,14 +187,14 @@ uint8_t BulkOnly::Write(uint8_t lun, uint32_t addr, uint16_t bsize, uint8_t bloc
|
||||||
if (!LUNOk[lun]) return MASS_ERR_NO_MEDIA;
|
if (!LUNOk[lun]) return MASS_ERR_NO_MEDIA;
|
||||||
if (!WriteOk[lun]) return MASS_ERR_WRITE_PROTECTED;
|
if (!WriteOk[lun]) return MASS_ERR_WRITE_PROTECTED;
|
||||||
Notify(PSTR("\r\nWrite LUN:\t"), 0x80);
|
Notify(PSTR("\r\nWrite LUN:\t"), 0x80);
|
||||||
PrintHex<uint8_t > (lun, 0x90);
|
D_PrintHex<uint8_t > (lun, 0x90);
|
||||||
//printf("LUN=%i LBA=%8.8X BLOCKS=%i SIZE=%i\r\n", lun, addr, blocks, bsize);
|
//printf("LUN=%i LBA=%8.8X BLOCKS=%i SIZE=%i\r\n", lun, addr, blocks, bsize);
|
||||||
Notify(PSTR("\r\nLBA:\t\t"), 0x90);
|
Notify(PSTR("\r\nLBA:\t\t"), 0x90);
|
||||||
PrintHex<uint32_t > (addr, 0x90);
|
D_PrintHex<uint32_t > (addr, 0x90);
|
||||||
Notify(PSTR("\r\nblocks:\t\t"), 0x90);
|
Notify(PSTR("\r\nblocks:\t\t"), 0x90);
|
||||||
PrintHex<uint8_t > (blocks, 0x90);
|
D_PrintHex<uint8_t > (blocks, 0x90);
|
||||||
Notify(PSTR("\r\nblock size:\t"), 0x90);
|
Notify(PSTR("\r\nblock size:\t"), 0x90);
|
||||||
PrintHex<uint16_t > (bsize, 0x90);
|
D_PrintHex<uint16_t > (bsize, 0x90);
|
||||||
Notify(PSTR("\r\n---------\r\n"), 0x80);
|
Notify(PSTR("\r\n---------\r\n"), 0x80);
|
||||||
//MediaCTL(lun, 0x01);
|
//MediaCTL(lun, 0x01);
|
||||||
CommandBlockWrapper cbw;
|
CommandBlockWrapper cbw;
|
||||||
|
@ -557,7 +557,7 @@ boolean BulkOnly::CheckLUN(uint8_t lun) {
|
||||||
}
|
}
|
||||||
ErrorMessage<uint8_t > (PSTR(">>>>>>>>>>>>>>>>CAPACITY OK ON LUN"), lun);
|
ErrorMessage<uint8_t > (PSTR(">>>>>>>>>>>>>>>>CAPACITY OK ON LUN"), lun);
|
||||||
for (uint8_t i = 0; i<sizeof (Capacity); i++)
|
for (uint8_t i = 0; i<sizeof (Capacity); i++)
|
||||||
PrintHex<uint8_t > (capacity.data[i], 0x80);
|
D_PrintHex<uint8_t > (capacity.data[i], 0x80);
|
||||||
Notify(PSTR("\r\n\r\n"), 0x80);
|
Notify(PSTR("\r\n\r\n"), 0x80);
|
||||||
// Only 512/1024/2048/4096 are valid values!
|
// Only 512/1024/2048/4096 are valid values!
|
||||||
uint32_t c = ((uint32_t)capacity.data[4] << 24) + ((uint32_t)capacity.data[5] << 16) + ((uint32_t)capacity.data[6] << 8) + (uint32_t)capacity.data[7];
|
uint32_t c = ((uint32_t)capacity.data[4] << 24) + ((uint32_t)capacity.data[5] << 16) + ((uint32_t)capacity.data[6] << 8) + (uint32_t)capacity.data[7];
|
||||||
|
@ -835,7 +835,7 @@ uint8_t BulkOnly::Page3F(uint8_t lun) {
|
||||||
WriteOk[lun] = ((buf[2] & 0x80) == 0);
|
WriteOk[lun] = ((buf[2] & 0x80) == 0);
|
||||||
Notify(PSTR("Mode Sense: "), 0x80);
|
Notify(PSTR("Mode Sense: "), 0x80);
|
||||||
for (int i = 0; i < 4; i++) {
|
for (int i = 0; i < 4; i++) {
|
||||||
PrintHex<uint8_t > (buf[i], 0x80);
|
D_PrintHex<uint8_t > (buf[i], 0x80);
|
||||||
Notify(PSTR(" "), 0x80);
|
Notify(PSTR(" "), 0x80);
|
||||||
}
|
}
|
||||||
Notify(PSTR("\r\n"), 0x80);
|
Notify(PSTR("\r\n"), 0x80);
|
||||||
|
@ -1197,7 +1197,7 @@ uint8_t BulkOnly::HandleSCSIError(uint8_t status) {
|
||||||
if (rsp.bResponseCode & 0x80) {
|
if (rsp.bResponseCode & 0x80) {
|
||||||
Notify(PSTR("Information field: "), 0x80);
|
Notify(PSTR("Information field: "), 0x80);
|
||||||
for (int i = 0; i < 4; i++) {
|
for (int i = 0; i < 4; i++) {
|
||||||
PrintHex<uint8_t > (rsp.CmdSpecificInformation[i], 0x80);
|
D_PrintHex<uint8_t > (rsp.CmdSpecificInformation[i], 0x80);
|
||||||
Notify(PSTR(" "), 0x80);
|
Notify(PSTR(" "), 0x80);
|
||||||
}
|
}
|
||||||
Notify(PSTR("\r\n"), 0x80);
|
Notify(PSTR("\r\n"), 0x80);
|
||||||
|
@ -1299,17 +1299,17 @@ void BulkOnly::EndpointXtract(uint8_t conf, uint8_t iface, uint8_t alt, uint8_t
|
||||||
void BulkOnly::PrintEndpointDescriptor(const USB_ENDPOINT_DESCRIPTOR * ep_ptr) {
|
void BulkOnly::PrintEndpointDescriptor(const USB_ENDPOINT_DESCRIPTOR * ep_ptr) {
|
||||||
Notify(PSTR("Endpoint descriptor:"), 0x80);
|
Notify(PSTR("Endpoint descriptor:"), 0x80);
|
||||||
Notify(PSTR("\r\nLength:\t\t"), 0x80);
|
Notify(PSTR("\r\nLength:\t\t"), 0x80);
|
||||||
PrintHex<uint8_t > (ep_ptr->bLength, 0x80);
|
D_PrintHex<uint8_t > (ep_ptr->bLength, 0x80);
|
||||||
Notify(PSTR("\r\nType:\t\t"), 0x80);
|
Notify(PSTR("\r\nType:\t\t"), 0x80);
|
||||||
PrintHex<uint8_t > (ep_ptr->bDescriptorType, 0x80);
|
D_PrintHex<uint8_t > (ep_ptr->bDescriptorType, 0x80);
|
||||||
Notify(PSTR("\r\nAddress:\t"), 0x80);
|
Notify(PSTR("\r\nAddress:\t"), 0x80);
|
||||||
PrintHex<uint8_t > (ep_ptr->bEndpointAddress, 0x80);
|
D_PrintHex<uint8_t > (ep_ptr->bEndpointAddress, 0x80);
|
||||||
Notify(PSTR("\r\nAttributes:\t"), 0x80);
|
Notify(PSTR("\r\nAttributes:\t"), 0x80);
|
||||||
PrintHex<uint8_t > (ep_ptr->bmAttributes, 0x80);
|
D_PrintHex<uint8_t > (ep_ptr->bmAttributes, 0x80);
|
||||||
Notify(PSTR("\r\nMaxPktSize:\t"), 0x80);
|
Notify(PSTR("\r\nMaxPktSize:\t"), 0x80);
|
||||||
PrintHex<uint16_t > (ep_ptr->wMaxPacketSize, 0x80);
|
D_PrintHex<uint16_t > (ep_ptr->wMaxPacketSize, 0x80);
|
||||||
Notify(PSTR("\r\nPoll Intrv:\t"), 0x80);
|
Notify(PSTR("\r\nPoll Intrv:\t"), 0x80);
|
||||||
PrintHex<uint8_t > (ep_ptr->bInterval, 0x80);
|
D_PrintHex<uint8_t > (ep_ptr->bInterval, 0x80);
|
||||||
Notify(PSTR("\r\n"), 0x80);
|
Notify(PSTR("\r\n"), 0x80);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -103,13 +103,13 @@ void NotifyFailSetConfDescr(uint8_t reason) {
|
||||||
*/
|
*/
|
||||||
void NotifyFailUnknownDevice(uint16_t VID, uint16_t PID) {
|
void NotifyFailUnknownDevice(uint16_t VID, uint16_t PID) {
|
||||||
Notify(PSTR("\r\nUnknown Device Connected - VID: "), 0x80);
|
Notify(PSTR("\r\nUnknown Device Connected - VID: "), 0x80);
|
||||||
PrintHex<uint16_t > (VID, 0x80);
|
D_PrintHex<uint16_t > (VID, 0x80);
|
||||||
Notify(PSTR(" PID: "), 0x80);
|
Notify(PSTR(" PID: "), 0x80);
|
||||||
PrintHex<uint16_t > (PID, 0x80);
|
D_PrintHex<uint16_t > (PID, 0x80);
|
||||||
}
|
}
|
||||||
|
|
||||||
void NotifyFail(uint8_t rcode) {
|
void NotifyFail(uint8_t rcode) {
|
||||||
PrintHex<uint8_t > (rcode, 0x80);
|
D_PrintHex<uint8_t > (rcode, 0x80);
|
||||||
Notify(PSTR("\r\n"), 0x80);
|
Notify(PSTR("\r\n"), 0x80);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -69,7 +69,7 @@ void ErrorMessage(uint8_t level, char const * msg, ERROR_TYPE rcode = 0) {
|
||||||
#ifdef DEBUG_USB_HOST
|
#ifdef DEBUG_USB_HOST
|
||||||
Notify(msg, level);
|
Notify(msg, level);
|
||||||
Notify(PSTR(": "), level);
|
Notify(PSTR(": "), level);
|
||||||
PrintHex<ERROR_TYPE > (rcode, level);
|
D_PrintHex<ERROR_TYPE > (rcode, level);
|
||||||
Notify(PSTR("\r\n"), level);
|
Notify(PSTR("\r\n"), level);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -79,7 +79,7 @@ void ErrorMessage(char const * msg, ERROR_TYPE rcode = 0) {
|
||||||
#ifdef DEBUG_USB_HOST
|
#ifdef DEBUG_USB_HOST
|
||||||
Notify(msg, 0x80);
|
Notify(msg, 0x80);
|
||||||
Notify(PSTR(": "), 0x80);
|
Notify(PSTR(": "), 0x80);
|
||||||
PrintHex<ERROR_TYPE > (rcode, 0x80);
|
D_PrintHex<ERROR_TYPE > (rcode, 0x80);
|
||||||
Notify(PSTR("\r\n"), 0x80);
|
Notify(PSTR("\r\n"), 0x80);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
23
printhex.h
23
printhex.h
|
@ -31,7 +31,6 @@ void E_Notifyc(char c, int lvl);
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
void PrintHex(T val, int lvl) {
|
void PrintHex(T val, int lvl) {
|
||||||
//#ifdef DEBUG_USB_HOST
|
|
||||||
int num_nibbles = sizeof(T) * 2;
|
int num_nibbles = sizeof(T) * 2;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
|
@ -39,23 +38,19 @@ void PrintHex(T val, int lvl) {
|
||||||
if(v > 57) v += 7;
|
if(v > 57) v += 7;
|
||||||
E_Notifyc(v, lvl);
|
E_Notifyc(v, lvl);
|
||||||
} while(--num_nibbles);
|
} while(--num_nibbles);
|
||||||
//#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
void PrintBin(T val, int lvl) {
|
void PrintBin(T val, int lvl) {
|
||||||
//#ifdef DEBUG_USB_HOST
|
|
||||||
for(T mask = (((T) 1) << ((sizeof(T) << 3) - 1)); mask; mask >>= 1)
|
for(T mask = (((T) 1) << ((sizeof(T) << 3) - 1)); mask; mask >>= 1)
|
||||||
if(val & mask)
|
if(val & mask)
|
||||||
E_Notifyc('1', lvl);
|
E_Notifyc('1', lvl);
|
||||||
else
|
else
|
||||||
E_Notifyc('0', lvl);
|
E_Notifyc('0', lvl);
|
||||||
//#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
void SerialPrintHex(T val) {
|
void SerialPrintHex(T val) {
|
||||||
//#ifdef DEBUG_USB_HOST
|
|
||||||
int num_nibbles = sizeof(T) * 2;
|
int num_nibbles = sizeof(T) * 2;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
|
@ -63,12 +58,10 @@ void SerialPrintHex(T val) {
|
||||||
if(v > 57) v += 7;
|
if(v > 57) v += 7;
|
||||||
USB_HOST_SERIAL.print(v);
|
USB_HOST_SERIAL.print(v);
|
||||||
} while(--num_nibbles);
|
} while(--num_nibbles);
|
||||||
//#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
void PrintHex2(Print *prn, T val) {
|
void PrintHex2(Print *prn, T val) {
|
||||||
//#ifdef DEBUG_USB_HOST
|
|
||||||
T mask = (((T) 1) << (((sizeof(T) << 1) - 1) << 2));
|
T mask = (((T) 1) << (((sizeof(T) << 1) - 1) << 2));
|
||||||
|
|
||||||
while(mask > 1) {
|
while(mask > 1) {
|
||||||
|
@ -78,7 +71,21 @@ void PrintHex2(Print *prn, T val) {
|
||||||
mask >>= 4;
|
mask >>= 4;
|
||||||
}
|
}
|
||||||
prn->print((T) val, HEX);
|
prn->print((T) val, HEX);
|
||||||
//#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <class T> void D_PrintHex(T val, int lvl) {
|
||||||
|
#ifdef DEBUG_USB_HOST
|
||||||
|
PrintHex<T>(val, lvl);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
template <class T>
|
||||||
|
void D_PrintBin(T val, int lvl) {
|
||||||
|
#ifdef DEBUG_USB_HOST
|
||||||
|
PrintBin<T>(val, lvl);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endif // __PRINTHEX_H__
|
#endif // __PRINTHEX_H__
|
||||||
|
|
Loading…
Reference in a new issue