From 159e8dc46b4c08efe43f3ae9f86d8811c0100afa Mon Sep 17 00:00:00 2001 From: "Andrew J. Kroll" Date: Mon, 10 Jun 2013 14:26:51 -0400 Subject: [PATCH] refactor DEBUG -> DEBUG_USB_HOST --- BTD.cpp | 84 +++++++++++++++++++------------------- PS3BT.cpp | 34 ++++++++-------- PS3USB.cpp | 30 +++++++------- SPP.cpp | 50 +++++++++++------------ Wii.cpp | 102 +++++++++++++++++++++++------------------------ XBOXRECV.cpp | 30 +++++++------- XBOXUSB.cpp | 26 ++++++------ adk.cpp | 14 +++---- cdcacm.cpp | 12 +++--- cdcftdi.cpp | 12 +++--- cdcprolific.cpp | 12 +++--- hidboot.h | 14 +++---- hiduniversal.cpp | 12 +++--- masstorage.cpp | 16 ++++---- message.cpp | 2 +- message.h | 8 ++-- printhex.h | 8 ++-- 17 files changed, 233 insertions(+), 233 deletions(-) diff --git a/BTD.cpp b/BTD.cpp index 8b3a5b24..02f442a5 100755 --- a/BTD.cpp +++ b/BTD.cpp @@ -16,7 +16,7 @@ */ #include "BTD.h" -// To enable serial debugging uncomment "#define DEBUG" in message.h +// To enable serial debugging uncomment "#define DEBUG_USB_HOST" in message.h //#define EXTRADEBUG // Uncomment to get even more debugging data const uint8_t BTD::BTD_CONTROL_PIPE = 0; @@ -58,7 +58,7 @@ uint8_t BTD::Init(uint8_t parent, uint8_t port, bool lowspeed) { #endif // check if address has already been assigned to an instance if (bAddress) { -#ifdef DEBUG +#ifdef DEBUG_USB_HOST Notify(PSTR("\r\nAddress in use"), 0x80); #endif return USB_ERROR_CLASS_INSTANCE_ALREADY_IN_USE; @@ -68,14 +68,14 @@ uint8_t BTD::Init(uint8_t parent, uint8_t port, bool lowspeed) { p = addrPool.GetUsbDevicePtr(0); if (!p) { -#ifdef DEBUG +#ifdef DEBUG_USB_HOST Notify(PSTR("\r\nAddress not found"), 0x80); #endif return USB_ERROR_ADDRESS_NOT_FOUND_IN_POOL; } if (!p->epinfo) { -#ifdef DEBUG +#ifdef DEBUG_USB_HOST Notify(PSTR("\r\nepinfo is null"), 0x80); #endif return USB_ERROR_EPINFO_IS_NULL; @@ -113,7 +113,7 @@ uint8_t BTD::Init(uint8_t parent, uint8_t port, bool lowspeed) { p->lowspeed = false; addrPool.FreeAddress(bAddress); bAddress = 0; -#ifdef DEBUG +#ifdef DEBUG_USB_HOST Notify(PSTR("\r\nsetAddr: "), 0x80); #endif PrintHex (rcode, 0x80); @@ -145,7 +145,7 @@ uint8_t BTD::Init(uint8_t parent, uint8_t port, bool lowspeed) { if (rcode) goto FailSetConfDescr; -#ifdef DEBUG +#ifdef DEBUG_USB_HOST if (PID == PS3_PID || PID == PS3NAVIGATION_PID) { if (PID == PS3_PID) Notify(PSTR("\r\nDualshock 3 Controller Connected"), 0x80); @@ -156,7 +156,7 @@ uint8_t BTD::Init(uint8_t parent, uint8_t port, bool lowspeed) { #endif if (my_bdaddr[0] == 0x00 && my_bdaddr[1] == 0x00 && my_bdaddr[2] == 0x00 && my_bdaddr[3] == 0x00 && my_bdaddr[4] == 0x00 && my_bdaddr[5] == 0x00) { -#ifdef DEBUG +#ifdef DEBUG_USB_HOST Notify(PSTR("\r\nPlease plug in the dongle before trying to pair with the PS3 Controller\n\rOr set the Bluetooth address in the constructor of the PS3BT class"), 0x80); #endif } else { @@ -164,7 +164,7 @@ uint8_t BTD::Init(uint8_t parent, uint8_t port, bool lowspeed) { setBdaddr(my_bdaddr); // Set internal Bluetooth address else setMoveBdaddr(my_bdaddr); // Set internal Bluetooth address -#ifdef DEBUG +#ifdef DEBUG_USB_HOST Notify(PSTR("\r\nBluetooth Address was set to: "), 0x80); for (int8_t i = 5; i > 0; i--) { PrintHex (my_bdaddr[i], 0x80); @@ -214,7 +214,7 @@ uint8_t BTD::Init(uint8_t parent, uint8_t port, bool lowspeed) { watingForConnection = false; bPollEnable = true; -#ifdef DEBUG +#ifdef DEBUG_USB_HOST Notify(PSTR("\r\nBluetooth Dongle Initialized"), 0x80); #endif } @@ -222,37 +222,37 @@ uint8_t BTD::Init(uint8_t parent, uint8_t port, bool lowspeed) { /* diagnostic messages */ FailGetDevDescr: -#ifdef DEBUG +#ifdef DEBUG_USB_HOST NotifyFailGetDevDescr(); goto Fail; #endif FailSetDevTblEntry: -#ifdef DEBUG +#ifdef DEBUG_USB_HOST NotifyFailSetDevTblEntry(); goto Fail; #endif FailGetConfDescr: -#ifdef DEBUG +#ifdef DEBUG_USB_HOST NotifyFailGetConfDescr(); goto Fail; #endif FailSetConfDescr: -#ifdef DEBUG +#ifdef DEBUG_USB_HOST NotifyFailSetConfDescr(); #endif goto Fail; FailUnknownDevice: -#ifdef DEBUG +#ifdef DEBUG_USB_HOST NotifyFailUnknownDevice(VID, PID); #endif pUsb->setAddr(bAddress, 0, 0); // Reset address rcode = USB_DEV_CONFIG_ERROR_DEVICE_NOT_SUPPORTED; Fail: -#ifdef DEBUG +#ifdef DEBUG_USB_HOST Notify(PSTR("\r\nBTD Init Failed, error code: "), 0x80); NotifyFail(rcode); #endif @@ -360,7 +360,7 @@ void BTD::HCI_event_task() { case EV_COMMAND_STATUS: if (hcibuf[2]) { // show status on serial if not OK -#ifdef DEBUG +#ifdef DEBUG_USB_HOST Notify(PSTR("\r\nHCI Command Failed: "), 0x80); PrintHex (hcibuf[2], 0x80); Notify(PSTR(" "), 0x80); @@ -374,7 +374,7 @@ void BTD::HCI_event_task() { case EV_INQUIRY_COMPLETE: if (inquiry_counter >= 5) { inquiry_counter = 0; -#ifdef DEBUG +#ifdef DEBUG_USB_HOST Notify(PSTR("\r\nCouldn't find Wiimote"), 0x80); #endif connectToWii = false; @@ -468,18 +468,18 @@ void BTD::HCI_event_task() { case EV_PIN_CODE_REQUEST: if (pairWithWii) { -#ifdef DEBUG +#ifdef DEBUG_USB_HOST Notify(PSTR("\r\nPairing with wiimote"), 0x80); #endif hci_pin_code_request_reply(); } else if (btdPin != NULL) { -#ifdef DEBUG +#ifdef DEBUG_USB_HOST Notify(PSTR("\r\nBluetooth pin is set too: "), 0x80); NotifyStr(btdPin, 0x80); #endif hci_pin_code_request_reply(); } else { -#ifdef DEBUG +#ifdef DEBUG_USB_HOST Notify(PSTR("\r\nNo pin was set"), 0x80); #endif hci_pin_code_negative_request_reply(); @@ -487,7 +487,7 @@ void BTD::HCI_event_task() { break; case EV_LINK_KEY_REQUEST: -#ifdef DEBUG +#ifdef DEBUG_USB_HOST Notify(PSTR("\r\nReceived Key Request"), 0x80); #endif hci_link_key_request_negative_reply(); @@ -495,7 +495,7 @@ void BTD::HCI_event_task() { case EV_AUTHENTICATION_COMPLETE: if (pairWithWii && !connectToWii) { -#ifdef DEBUG +#ifdef DEBUG_USB_HOST Notify(PSTR("\r\nPairing successful"), 0x80); #endif connectToWii = true; // Only send the ACL data to the Wii service @@ -549,7 +549,7 @@ void BTD::HCI_task() { hci_counter++; if (hci_cmd_complete) { hci_counter = 0; -#ifdef DEBUG +#ifdef DEBUG_USB_HOST Notify(PSTR("\r\nHCI Reset complete"), 0x80); #endif hci_state = HCI_CLASS_STATE; @@ -558,7 +558,7 @@ void BTD::HCI_task() { hci_num_reset_loops *= 10; if (hci_num_reset_loops > 2000) hci_num_reset_loops = 2000; -#ifdef DEBUG +#ifdef DEBUG_USB_HOST Notify(PSTR("\r\nNo response to HCI Reset"), 0x80); #endif hci_state = HCI_INIT_STATE; @@ -568,7 +568,7 @@ void BTD::HCI_task() { case HCI_CLASS_STATE: if (hci_cmd_complete) { -#ifdef DEBUG +#ifdef DEBUG_USB_HOST Notify(PSTR("\r\nWrite class of device"), 0x80); #endif hci_state = HCI_BDADDR_STATE; @@ -578,7 +578,7 @@ void BTD::HCI_task() { case HCI_BDADDR_STATE: if (hci_read_bdaddr_complete) { -#ifdef DEBUG +#ifdef DEBUG_USB_HOST Notify(PSTR("\r\nLocal Bluetooth Address: "), 0x80); for (int8_t i = 5; i > 0; i--) { PrintHex (my_bdaddr[i], 0x80); @@ -603,7 +603,7 @@ void BTD::HCI_task() { case HCI_SET_NAME_STATE: if (hci_cmd_complete) { -#ifdef DEBUG +#ifdef DEBUG_USB_HOST Notify(PSTR("\r\nThe name is set to: "), 0x80); NotifyStr(btdName, 0x80); #endif @@ -613,7 +613,7 @@ void BTD::HCI_task() { case HCI_CHECK_WII_SERVICE: if (pairWithWii) { // Check if it should try to connect to a wiimote -#ifdef DEBUG +#ifdef DEBUG_USB_HOST Notify(PSTR("\r\nStarting inquiry\r\nPress 1 & 2 on the Wiimote\r\nOr press sync if you are using a Wii U Pro Controller"), 0x80); #endif hci_inquiry(); @@ -625,7 +625,7 @@ void BTD::HCI_task() { case HCI_INQUIRY_STATE: if (hci_wii_found) { hci_inquiry_cancel(); // Stop inquiry -#ifdef DEBUG +#ifdef DEBUG_USB_HOST Notify(PSTR("\r\nWiimote found"), 0x80); Notify(PSTR("\r\nNow just create the instance like so:"), 0x80); Notify(PSTR("\r\nWII Wii(&Btd);"), 0x80); @@ -641,7 +641,7 @@ void BTD::HCI_task() { case HCI_CONNECT_WII_STATE: if (hci_cmd_complete) { -#ifdef DEBUG +#ifdef DEBUG_USB_HOST Notify(PSTR("\r\nConnecting to Wiimote"), 0x80); #endif hci_connect(); @@ -652,13 +652,13 @@ void BTD::HCI_task() { case HCI_CONNECTED_WII_STATE: if (hci_connect_event) { if (hci_connect_complete) { -#ifdef DEBUG +#ifdef DEBUG_USB_HOST Notify(PSTR("\r\nConnected to Wiimote"), 0x80); #endif hci_authentication_request(); // This will start the pairing with the wiimote hci_state = HCI_SCANNING_STATE; } else { -#ifdef DEBUG +#ifdef DEBUG_USB_HOST Notify(PSTR("\r\nTrying to connect one more time..."), 0x80); #endif hci_connect(); // Try to connect one more time @@ -668,7 +668,7 @@ void BTD::HCI_task() { case HCI_SCANNING_STATE: if (!connectToWii && !pairWithWii) { -#ifdef DEBUG +#ifdef DEBUG_USB_HOST Notify(PSTR("\r\nWait For Incoming Connection Request"), 0x80); #endif hci_write_scan_enable(); @@ -680,7 +680,7 @@ void BTD::HCI_task() { case HCI_CONNECT_IN_STATE: if (hci_incoming_connect_request) { watingForConnection = false; -#ifdef DEBUG +#ifdef DEBUG_USB_HOST Notify(PSTR("\r\nIncoming Connection Request"), 0x80); #endif hci_remote_name(); @@ -691,7 +691,7 @@ void BTD::HCI_task() { case HCI_REMOTE_NAME_STATE: if (hci_remote_name_complete) { -#ifdef DEBUG +#ifdef DEBUG_USB_HOST Notify(PSTR("\r\nRemote Name: "), 0x80); for (uint8_t i = 0; i < 30; i++) { if (remote_name[i] == NULL) @@ -701,16 +701,16 @@ void BTD::HCI_task() { #endif if (strncmp((const char*)remote_name, "Nintendo", 8) == 0) { incomingWii = true; -#ifdef DEBUG +#ifdef DEBUG_USB_HOST Notify(PSTR("\r\nWiimote is connecting"), 0x80); #endif if (strncmp((const char*)remote_name, "Nintendo RVL-CNT-01-TR", 22) == 0) { -#ifdef DEBUG +#ifdef DEBUG_USB_HOST Notify(PSTR(" with Motion Plus Inside"), 0x80); #endif motionPlusInside = true; } else if (strncmp((const char*)remote_name, "Nintendo RVL-CNT-01-UC", 22) == 0) { -#ifdef DEBUG +#ifdef DEBUG_USB_HOST Notify(PSTR(" - Wii U Pro Controller"), 0x80); #endif motionPlusInside = true; @@ -731,7 +731,7 @@ void BTD::HCI_task() { case HCI_CONNECTED_STATE: if (hci_connect_complete) { -#ifdef DEBUG +#ifdef DEBUG_USB_HOST Notify(PSTR("\r\nConnected to Device: "), 0x80); for (int8_t i = 5; i > 0; i--) { PrintHex (disc_bdaddr[i], 0x80); @@ -759,7 +759,7 @@ void BTD::HCI_task() { case HCI_DISCONNECT_STATE: if (hci_disconnect_complete) { -#ifdef DEBUG +#ifdef DEBUG_USB_HOST Notify(PSTR("\r\nHCI Disconnected from Device"), 0x80); #endif hci_event_flag = 0; // Clear all flags @@ -957,7 +957,7 @@ void BTD::hci_pin_code_request_reply() { if (pairWithWii) { hcibuf[9] = 6; // Pin length is the length of the Bluetooth address if (wiiUProController) { -#ifdef DEBUG +#ifdef DEBUG_USB_HOST Notify(PSTR("\r\nParing with Wii U Pro Controller"), 0x80); #endif for (uint8_t i = 0; i < 6; i++) @@ -1083,7 +1083,7 @@ void BTD::L2CAP_Command(uint16_t handle, uint8_t* data, uint8_t nbytes, uint8_t uint8_t rcode = pUsb->outTransfer(bAddress, epInfo[ BTD_DATAOUT_PIPE ].epAddr, (8 + nbytes), buf); if (rcode) { delay(100); // This small delay prevents it from overflowing if it fails -#ifdef DEBUG +#ifdef DEBUG_USB_HOST Notify(PSTR("\r\nError sending L2CAP message: 0x"), 0x80); PrintHex (rcode, 0x80); Notify(PSTR(" - Channel ID: "), 0x80); diff --git a/PS3BT.cpp b/PS3BT.cpp index 473c6099..26ad8772 100644 --- a/PS3BT.cpp +++ b/PS3BT.cpp @@ -16,7 +16,7 @@ */ #include "PS3BT.h" -// To enable serial debugging uncomment "#define DEBUG" in message.h +// To enable serial debugging uncomment "#define DEBUG_USB_HOST" in message.h //#define EXTRADEBUG // Uncomment to get even more debugging data //#define PRINTREPORT // Uncomment to print the report send by the PS3 Controllers @@ -255,7 +255,7 @@ void PS3BT::ACLData(uint8_t* ACLData) { l2cap_state = L2CAP_WAIT; for (uint8_t i = 0; i < 30; i++) remote_name[i] = pBtd->remote_name[i]; // Store the remote name for the connection -#ifdef DEBUG +#ifdef DEBUG_USB_HOST if (pBtd->hci_version < 3) { // Check the HCI Version of the Bluetooth dongle Notify(PSTR("\r\nYour dongle may not support reading the analog buttons, sensors and status\r\nYour HCI Version is: "), 0x80); Notify(pBtd->hci_version, 0x80); @@ -270,7 +270,7 @@ void PS3BT::ACLData(uint8_t* ACLData) { l2capinbuf[i] = ACLData[i]; if ((l2capinbuf[6] | (l2capinbuf[7] << 8)) == 0x0001) { //l2cap_control - Channel ID for ACL-U if (l2capinbuf[8] == L2CAP_CMD_COMMAND_REJECT) { -#ifdef DEBUG +#ifdef DEBUG_USB_HOST Notify(PSTR("\r\nL2CAP Command Rejected - Reason: "), 0x80); PrintHex (l2capinbuf[13], 0x80); Notify(PSTR(" "), 0x80); @@ -330,14 +330,14 @@ void PS3BT::ACLData(uint8_t* ACLData) { } } else if (l2capinbuf[8] == L2CAP_CMD_DISCONNECT_REQUEST) { if (l2capinbuf[12] == control_dcid[0] && l2capinbuf[13] == control_dcid[1]) { -#ifdef DEBUG +#ifdef DEBUG_USB_HOST Notify(PSTR("\r\nDisconnect Request: Control Channel"), 0x80); #endif identifier = l2capinbuf[9]; pBtd->l2cap_disconnection_response(hci_handle, identifier, control_dcid, control_scid); Reset(); } else if (l2capinbuf[12] == interrupt_dcid[0] && l2capinbuf[13] == interrupt_dcid[1]) { -#ifdef DEBUG +#ifdef DEBUG_USB_HOST Notify(PSTR("\r\nDisconnect Request: Interrupt Channel"), 0x80); #endif identifier = l2capinbuf[9]; @@ -397,7 +397,7 @@ void PS3BT::L2CAP_task() { switch (l2cap_state) { case L2CAP_WAIT: if (l2cap_connection_request_control_flag) { -#ifdef DEBUG +#ifdef DEBUG_USB_HOST Notify(PSTR("\r\nHID Control Incoming Connection Request"), 0x80); #endif pBtd->l2cap_connection_response(hci_handle, identifier, control_dcid, control_scid, PENDING); @@ -411,7 +411,7 @@ void PS3BT::L2CAP_task() { break; case L2CAP_CONTROL_REQUEST: if (l2cap_config_request_control_flag) { -#ifdef DEBUG +#ifdef DEBUG_USB_HOST Notify(PSTR("\r\nHID Control Configuration Request"), 0x80); #endif pBtd->l2cap_config_response(hci_handle, identifier, control_scid); @@ -421,7 +421,7 @@ void PS3BT::L2CAP_task() { case L2CAP_CONTROL_SUCCESS: if (l2cap_config_success_control_flag) { -#ifdef DEBUG +#ifdef DEBUG_USB_HOST Notify(PSTR("\r\nHID Control Successfully Configured"), 0x80); #endif l2cap_state = L2CAP_INTERRUPT_SETUP; @@ -429,7 +429,7 @@ void PS3BT::L2CAP_task() { break; case L2CAP_INTERRUPT_SETUP: if (l2cap_connection_request_interrupt_flag) { -#ifdef DEBUG +#ifdef DEBUG_USB_HOST Notify(PSTR("\r\nHID Interrupt Incoming Connection Request"), 0x80); #endif pBtd->l2cap_connection_response(hci_handle, identifier, interrupt_dcid, interrupt_scid, PENDING); @@ -444,7 +444,7 @@ void PS3BT::L2CAP_task() { break; case L2CAP_INTERRUPT_REQUEST: if (l2cap_config_request_interrupt_flag) { -#ifdef DEBUG +#ifdef DEBUG_USB_HOST Notify(PSTR("\r\nHID Interrupt Configuration Request"), 0x80); #endif pBtd->l2cap_config_response(hci_handle, identifier, interrupt_scid); @@ -453,7 +453,7 @@ void PS3BT::L2CAP_task() { break; case L2CAP_INTERRUPT_SUCCESS: if (l2cap_config_success_interrupt_flag) { -#ifdef DEBUG +#ifdef DEBUG_USB_HOST Notify(PSTR("\r\nHID Interrupt Successfully Configured"), 0x80); #endif if (remote_name[0] == 'M') { // First letter in Motion Controller ('M') @@ -473,7 +473,7 @@ void PS3BT::L2CAP_task() { case L2CAP_INTERRUPT_DISCONNECT: if (l2cap_disconnect_response_interrupt_flag) { -#ifdef DEBUG +#ifdef DEBUG_USB_HOST Notify(PSTR("\r\nDisconnected Interrupt Channel"), 0x80); #endif identifier++; @@ -484,7 +484,7 @@ void PS3BT::L2CAP_task() { case L2CAP_CONTROL_DISCONNECT: if (l2cap_disconnect_response_control_flag) { -#ifdef DEBUG +#ifdef DEBUG_USB_HOST Notify(PSTR("\r\nDisconnected Control Channel"), 0x80); #endif pBtd->hci_disconnect(hci_handle); @@ -517,20 +517,20 @@ void PS3BT::Run() { if (millis() - timer > 1000) { // loop 1 second before sending the command if (remote_name[0] == 'P') { // First letter in PLAYSTATION(R)3 Controller ('P') setLedOn(LED1); -#ifdef DEBUG +#ifdef DEBUG_USB_HOST Notify(PSTR("\r\nDualshock 3 Controller Enabled\r\n"), 0x80); #endif PS3Connected = true; } else if (remote_name[0] == 'N') { // First letter in Navigation Controller ('N') setLedOn(LED1); // This just turns LED constantly on, on the Navigation controller -#ifdef DEBUG +#ifdef DEBUG_USB_HOST Notify(PSTR("\r\nNavigation Controller Enabled\r\n"), 0x80); #endif PS3NavigationConnected = true; } else if (remote_name[0] == 'M') { // First letter in Motion Controller ('M') moveSetBulb(Red); timerBulbRumble = millis(); -#ifdef DEBUG +#ifdef DEBUG_USB_HOST Notify(PSTR("\r\nMotion Controller Enabled\r\n"), 0x80); #endif PS3MoveConnected = true; @@ -650,7 +650,7 @@ void PS3BT::moveSetBulb(Colors color) { //Use this to set the Color using the pr } void PS3BT::moveSetRumble(uint8_t rumble) { -#ifdef DEBUG +#ifdef DEBUG_USB_HOST if (rumble < 64 && rumble != 0) // The rumble value has to at least 64, or approximately 25% (64/255*100) Notify(PSTR("\r\nThe rumble value has to at least 64, or approximately 25%"), 0x80); #endif diff --git a/PS3USB.cpp b/PS3USB.cpp index de30777b..9b028f68 100644 --- a/PS3USB.cpp +++ b/PS3USB.cpp @@ -16,7 +16,7 @@ */ #include "PS3USB.h" -// To enable serial debugging uncomment "#define DEBUG" in message.h +// To enable serial debugging uncomment "#define DEBUG_USB_HOST" in message.h //#define EXTRADEBUG // Uncomment to get even more debugging data //#define PRINTREPORT // Uncomment to print the report send by the PS3 Controllers @@ -58,7 +58,7 @@ uint8_t PS3USB::Init(uint8_t parent, uint8_t port, bool lowspeed) { #endif // check if address has already been assigned to an instance if (bAddress) { -#ifdef DEBUG +#ifdef DEBUG_USB_HOST Notify(PSTR("\r\nAddress in use"), 0x80); #endif return USB_ERROR_CLASS_INSTANCE_ALREADY_IN_USE; @@ -68,14 +68,14 @@ uint8_t PS3USB::Init(uint8_t parent, uint8_t port, bool lowspeed) { p = addrPool.GetUsbDevicePtr(0); if (!p) { -#ifdef DEBUG +#ifdef DEBUG_USB_HOST Notify(PSTR("\r\nAddress not found"), 0x80); #endif return USB_ERROR_ADDRESS_NOT_FOUND_IN_POOL; } if (!p->epinfo) { -#ifdef DEBUG +#ifdef DEBUG_USB_HOST Notify(PSTR("\r\nepinfo is null"), 0x80); #endif return USB_ERROR_EPINFO_IS_NULL; @@ -118,7 +118,7 @@ uint8_t PS3USB::Init(uint8_t parent, uint8_t port, bool lowspeed) { p->lowspeed = false; addrPool.FreeAddress(bAddress); bAddress = 0; -#ifdef DEBUG +#ifdef DEBUG_USB_HOST Notify(PSTR("\r\nsetAddr: "), 0x80); #endif PrintHex (rcode, 0x80); @@ -173,12 +173,12 @@ uint8_t PS3USB::Init(uint8_t parent, uint8_t port, bool lowspeed) { if (PID == PS3_PID || PID == PS3NAVIGATION_PID) { if (PID == PS3_PID) { -#ifdef DEBUG +#ifdef DEBUG_USB_HOST Notify(PSTR("\r\nDualshock 3 Controller Connected"), 0x80); #endif PS3Connected = true; } else { // must be a navigation controller -#ifdef DEBUG +#ifdef DEBUG_USB_HOST Notify(PSTR("\r\nNavigation Controller Connected"), 0x80); #endif PS3NavigationConnected = true; @@ -195,7 +195,7 @@ uint8_t PS3USB::Init(uint8_t parent, uint8_t port, bool lowspeed) { for (uint8_t i = 6; i < 10; i++) readBuf[i] = 0x7F; // Set the analog joystick values to center position } else { // must be a Motion controller -#ifdef DEBUG +#ifdef DEBUG_USB_HOST Notify(PSTR("\r\nMotion Controller Connected"), 0x80); #endif PS3MoveConnected = true; @@ -205,7 +205,7 @@ uint8_t PS3USB::Init(uint8_t parent, uint8_t port, bool lowspeed) { writeBuf[0] = 0x02; // Set report ID, this is needed for Move commands to work } -#ifdef DEBUG +#ifdef DEBUG_USB_HOST Notify(PSTR("\r\nBluetooth Address was set to: "), 0x80); for (int8_t i = 5; i > 0; i--) { PrintHex (my_bdaddr[i], 0x80); @@ -221,29 +221,29 @@ uint8_t PS3USB::Init(uint8_t parent, uint8_t port, bool lowspeed) { /* diagnostic messages */ FailGetDevDescr: -#ifdef DEBUG +#ifdef DEBUG_USB_HOST NotifyFailGetDevDescr(); goto Fail; #endif FailSetDevTblEntry: -#ifdef DEBUG +#ifdef DEBUG_USB_HOST NotifyFailSetDevTblEntry(); goto Fail; #endif FailSetConfDescr: -#ifdef DEBUG +#ifdef DEBUG_USB_HOST NotifyFailSetConfDescr(); #endif goto Fail; FailUnknownDevice: -#ifdef DEBUG +#ifdef DEBUG_USB_HOST NotifyFailUnknownDevice(VID, PID); #endif rcode = USB_DEV_CONFIG_ERROR_DEVICE_NOT_SUPPORTED; Fail: -#ifdef DEBUG +#ifdef DEBUG_USB_HOST Notify(PSTR("\r\nPS3 Init Failed, error code: "), 0x80); NotifyFail(rcode); #endif @@ -513,7 +513,7 @@ void PS3USB::moveSetBulb(Colors color) { //Use this to set the Color using the p } void PS3USB::moveSetRumble(uint8_t rumble) { -#ifdef DEBUG +#ifdef DEBUG_USB_HOST if (rumble < 64 && rumble != 0) // The rumble value has to at least 64, or approximately 25% (64/255*100) Notify(PSTR("\r\nThe rumble value has to at least 64, or approximately 25%"), 0x80); #endif diff --git a/SPP.cpp b/SPP.cpp index 18588f15..ff12d0b5 100644 --- a/SPP.cpp +++ b/SPP.cpp @@ -16,7 +16,7 @@ */ #include "SPP.h" -// To enable serial debugging uncomment "#define DEBUG" in message.h +// To enable serial debugging uncomment "#define DEBUG_USB_HOST" in message.h //#define EXTRADEBUG // Uncomment to get even more debugging data //#define PRINTREPORT // Uncomment to print the report sent to the Arduino @@ -99,7 +99,7 @@ void SPP::ACLData(uint8_t* l2capinbuf) { if (((l2capinbuf[0] | (l2capinbuf[1] << 8)) == (hci_handle | 0x2000))) { // acl_handle_ok if ((l2capinbuf[6] | (l2capinbuf[7] << 8)) == 0x0001) { //l2cap_control - Channel ID for ACL-U if (l2capinbuf[8] == L2CAP_CMD_COMMAND_REJECT) { -#ifdef DEBUG +#ifdef DEBUG_USB_HOST Notify(PSTR("\r\nL2CAP Command Rejected - Reason: "), 0x80); PrintHex (l2capinbuf[13], 0x80); Notify(PSTR(" "), 0x80); @@ -178,7 +178,7 @@ void SPP::ACLData(uint8_t* l2capinbuf) { l2cap_event_flag |= L2CAP_FLAG_DISCONNECT_RESPONSE; } } else if (l2capinbuf[8] == L2CAP_CMD_INFORMATION_REQUEST) { -#ifdef DEBUG +#ifdef DEBUG_USB_HOST Notify(PSTR("\r\nInformation request"), 0x80); #endif identifier = l2capinbuf[9]; @@ -252,7 +252,7 @@ void SPP::ACLData(uint8_t* l2capinbuf) { PrintHex (rfcommPfBit, 0x80); #endif if (rfcommChannelType == RFCOMM_DISC) { -#ifdef DEBUG +#ifdef DEBUG_USB_HOST Notify(PSTR("\r\nReceived Disconnect RFCOMM Command on channel: "), 0x80); PrintHex (rfcommChannel >> 3, 0x80); #endif @@ -282,7 +282,7 @@ void SPP::ACLData(uint8_t* l2capinbuf) { Notifyc(l2capinbuf[i + 11 + offset], 0x80); #endif } else if (rfcommChannelType == RFCOMM_UIH && l2capinbuf[11] == BT_RFCOMM_RPN_CMD) { // UIH Remote Port Negotiation Command -#ifdef DEBUG +#ifdef DEBUG_USB_HOST Notify(PSTR("\r\nReceived UIH Remote Port Negotiation Command"), 0x80); #endif rfcommbuf[0] = BT_RFCOMM_RPN_RSP; // Command @@ -297,7 +297,7 @@ void SPP::ACLData(uint8_t* l2capinbuf) { rfcommbuf[9] = l2capinbuf[20]; // Number of Frames sendRfcomm(rfcommChannel, rfcommDirection, 0, RFCOMM_UIH, rfcommPfBit, rfcommbuf, 0x0A); // UIH Remote Port Negotiation Response } else if (rfcommChannelType == RFCOMM_UIH && l2capinbuf[11] == BT_RFCOMM_MSC_CMD) { // UIH Modem Status Command -#ifdef DEBUG +#ifdef DEBUG_USB_HOST Notify(PSTR("\r\nSend UIH Modem Status Response"), 0x80); #endif rfcommbuf[0] = BT_RFCOMM_MSC_RSP; // UIH Modem Status Response @@ -308,12 +308,12 @@ void SPP::ACLData(uint8_t* l2capinbuf) { } } else { if (rfcommChannelType == RFCOMM_SABM) { // SABM Command - this is sent twice: once for channel 0 and then for the channel to establish -#ifdef DEBUG +#ifdef DEBUG_USB_HOST Notify(PSTR("\r\nReceived SABM Command"), 0x80); #endif sendRfcomm(rfcommChannel, rfcommDirection, rfcommCommandResponse, RFCOMM_UA, rfcommPfBit, rfcommbuf, 0x00); // UA Command } else if (rfcommChannelType == RFCOMM_UIH && l2capinbuf[11] == BT_RFCOMM_PN_CMD) { // UIH Parameter Negotiation Command -#ifdef DEBUG +#ifdef DEBUG_USB_HOST Notify(PSTR("\r\nReceived UIH Parameter Negotiation Command"), 0x80); #endif rfcommbuf[0] = BT_RFCOMM_PN_RSP; // UIH Parameter Negotiation Response @@ -328,7 +328,7 @@ void SPP::ACLData(uint8_t* l2capinbuf) { rfcommbuf[9] = 0x00; // Number of Frames sendRfcomm(rfcommChannel, rfcommDirection, 0, RFCOMM_UIH, rfcommPfBit, rfcommbuf, 0x0A); } else if (rfcommChannelType == RFCOMM_UIH && l2capinbuf[11] == BT_RFCOMM_MSC_CMD) { // UIH Modem Status Command -#ifdef DEBUG +#ifdef DEBUG_USB_HOST Notify(PSTR("\r\nSend UIH Modem Status Response"), 0x80); #endif rfcommbuf[0] = BT_RFCOMM_MSC_RSP; // UIH Modem Status Response @@ -338,7 +338,7 @@ void SPP::ACLData(uint8_t* l2capinbuf) { sendRfcomm(rfcommChannel, rfcommDirection, 0, RFCOMM_UIH, rfcommPfBit, rfcommbuf, 0x04); delay(1); -#ifdef DEBUG +#ifdef DEBUG_USB_HOST Notify(PSTR("\r\nSend UIH Modem Status Command"), 0x80); #endif rfcommbuf[0] = BT_RFCOMM_MSC_CMD; // UIH Modem Status Command @@ -349,7 +349,7 @@ void SPP::ACLData(uint8_t* l2capinbuf) { sendRfcomm(rfcommChannel, rfcommDirection, 0, RFCOMM_UIH, rfcommPfBit, rfcommbuf, 0x04); } else if (rfcommChannelType == RFCOMM_UIH && l2capinbuf[11] == BT_RFCOMM_MSC_RSP) { // UIH Modem Status Response if (!creditSent) { -#ifdef DEBUG +#ifdef DEBUG_USB_HOST Notify(PSTR("\r\nSend UIH Command with credit"), 0x80); #endif sendRfcommCredit(rfcommChannelConnection, rfcommDirection, 0, RFCOMM_UIH, 0x10, sizeof (rfcommDataBuffer)); // Send credit @@ -358,11 +358,11 @@ void SPP::ACLData(uint8_t* l2capinbuf) { waitForLastCommand = true; } } else if (rfcommChannelType == RFCOMM_UIH && l2capinbuf[10] == 0x01) { // UIH Command with credit -#ifdef DEBUG +#ifdef DEBUG_USB_HOST Notify(PSTR("\r\nReceived UIH Command with credit"), 0x80); #endif } else if (rfcommChannelType == RFCOMM_UIH && l2capinbuf[11] == BT_RFCOMM_RPN_CMD) { // UIH Remote Port Negotiation Command -#ifdef DEBUG +#ifdef DEBUG_USB_HOST Notify(PSTR("\r\nReceived UIH Remote Port Negotiation Command"), 0x80); #endif rfcommbuf[0] = BT_RFCOMM_RPN_RSP; // Command @@ -376,7 +376,7 @@ void SPP::ACLData(uint8_t* l2capinbuf) { rfcommbuf[8] = l2capinbuf[19]; // MaxRatransm. rfcommbuf[9] = l2capinbuf[20]; // Number of Frames sendRfcomm(rfcommChannel, rfcommDirection, 0, RFCOMM_UIH, rfcommPfBit, rfcommbuf, 0x0A); // UIH Remote Port Negotiation Response -#ifdef DEBUG +#ifdef DEBUG_USB_HOST Notify(PSTR("\r\nRFCOMM Connection is now established\r\n"), 0x80); #endif waitForLastCommand = false; @@ -384,7 +384,7 @@ void SPP::ACLData(uint8_t* l2capinbuf) { connected = true; // The RFCOMM channel is now established sppIndex = 0; } -#ifdef DEBUG +#ifdef DEBUG_USB_HOST else if (rfcommChannelType != RFCOMM_DISC) { Notify(PSTR("\r\nUnsupported RFCOMM Data - ChannelType: "), 0x80); PrintHex (rfcommChannelType, 0x80); @@ -409,7 +409,7 @@ void SPP::ACLData(uint8_t* l2capinbuf) { void SPP::Run() { if (waitForLastCommand && (millis() - timer) > 100) { // We will only wait 100ms and see if the UIH Remote Port Negotiation Command is send, as some deviced don't send it -#ifdef DEBUG +#ifdef DEBUG_USB_HOST Notify(PSTR("\r\nRFCOMM Connection is now established - Automatic\r\n"), 0x80); #endif creditSent = false; @@ -425,7 +425,7 @@ void SPP::SDP_task() { case L2CAP_SDP_WAIT: if (l2cap_connection_request_sdp_flag) { l2cap_event_flag &= ~L2CAP_FLAG_CONNECTION_SDP_REQUEST; // Clear flag -#ifdef DEBUG +#ifdef DEBUG_USB_HOST Notify(PSTR("\r\nSDP Incoming Connection Request"), 0x80); #endif pBtd->l2cap_connection_response(hci_handle, identifier, sdp_dcid, sdp_scid, PENDING); @@ -440,7 +440,7 @@ void SPP::SDP_task() { case L2CAP_SDP_REQUEST: if (l2cap_config_request_sdp_flag) { l2cap_event_flag &= ~L2CAP_FLAG_CONFIG_SDP_REQUEST; // Clear flag -#ifdef DEBUG +#ifdef DEBUG_USB_HOST Notify(PSTR("\r\nSDP Configuration Request"), 0x80); #endif pBtd->l2cap_config_response(hci_handle, identifier, sdp_scid); @@ -450,7 +450,7 @@ void SPP::SDP_task() { case L2CAP_SDP_SUCCESS: if (l2cap_config_success_sdp_flag) { l2cap_event_flag &= ~L2CAP_FLAG_CONFIG_SDP_SUCCESS; // Clear flag -#ifdef DEBUG +#ifdef DEBUG_USB_HOST Notify(PSTR("\r\nSDP Successfully Configured"), 0x80); #endif firstMessage = true; // Reset bool @@ -462,7 +462,7 @@ void SPP::SDP_task() { if (l2cap_disconnect_request_sdp_flag) { l2cap_event_flag &= ~L2CAP_FLAG_DISCONNECT_SDP_REQUEST; // Clear flag SDPConnected = false; -#ifdef DEBUG +#ifdef DEBUG_USB_HOST Notify(PSTR("\r\nDisconnected SDP Channel"), 0x80); #endif pBtd->l2cap_disconnection_response(hci_handle, identifier, sdp_dcid, sdp_scid); @@ -472,7 +472,7 @@ void SPP::SDP_task() { break; case L2CAP_DISCONNECT_RESPONSE: // This is for both disconnection response from the RFCOMM and SDP channel if they were connected if (l2cap_disconnect_response_flag) { -#ifdef DEBUG +#ifdef DEBUG_USB_HOST Notify(PSTR("\r\nDisconnected L2CAP Connection"), 0x80); #endif RFCOMMConnected = false; @@ -492,7 +492,7 @@ void SPP::RFCOMM_task() { case L2CAP_RFCOMM_WAIT: if (l2cap_connection_request_rfcomm_flag) { l2cap_event_flag &= ~L2CAP_FLAG_CONNECTION_RFCOMM_REQUEST; // Clear flag -#ifdef DEBUG +#ifdef DEBUG_USB_HOST Notify(PSTR("\r\nRFCOMM Incoming Connection Request"), 0x80); #endif pBtd->l2cap_connection_response(hci_handle, identifier, rfcomm_dcid, rfcomm_scid, PENDING); @@ -507,7 +507,7 @@ void SPP::RFCOMM_task() { case L2CAP_RFCOMM_REQUEST: if (l2cap_config_request_rfcomm_flag) { l2cap_event_flag &= ~L2CAP_FLAG_CONFIG_RFCOMM_REQUEST; // Clear flag -#ifdef DEBUG +#ifdef DEBUG_USB_HOST Notify(PSTR("\r\nRFCOMM Configuration Request"), 0x80); #endif pBtd->l2cap_config_response(hci_handle, identifier, rfcomm_scid); @@ -517,7 +517,7 @@ void SPP::RFCOMM_task() { case L2CAP_RFCOMM_SUCCESS: if (l2cap_config_success_rfcomm_flag) { l2cap_event_flag &= ~L2CAP_FLAG_CONFIG_RFCOMM_SUCCESS; // Clear flag -#ifdef DEBUG +#ifdef DEBUG_USB_HOST Notify(PSTR("\r\nRFCOMM Successfully Configured"), 0x80); #endif rfcommAvailable = 0; // Reset number of bytes available @@ -531,7 +531,7 @@ void SPP::RFCOMM_task() { l2cap_event_flag &= ~L2CAP_FLAG_DISCONNECT_RFCOMM_REQUEST; // Clear flag RFCOMMConnected = false; connected = false; -#ifdef DEBUG +#ifdef DEBUG_USB_HOST Notify(PSTR("\r\nDisconnected RFCOMM Channel"), 0x80); #endif pBtd->l2cap_disconnection_response(hci_handle, identifier, rfcomm_dcid, rfcomm_scid); diff --git a/Wii.cpp b/Wii.cpp index 53f37528..f259bfdb 100755 --- a/Wii.cpp +++ b/Wii.cpp @@ -20,7 +20,7 @@ */ #include "Wii.h" -// To enable serial debugging uncomment "#define DEBUG" in message.h +// To enable serial debugging uncomment "#define DEBUG_USB_HOST" in message.h //#define EXTRADEBUG // Uncomment to get even more debugging data //#define PRINTREPORT // Uncomment to print the report send by the Wii controllers @@ -118,7 +118,7 @@ void WII::Reset() { void WII::disconnect() { // Use this void to disconnect any of the controllers if (motionPlusConnected && !pBtd->motionPlusInside) { // Disable the Motion Plus extension -#ifdef DEBUG +#ifdef DEBUG_USB_HOST Notify(PSTR("\r\nDeactivating Motion Plus"), 0x80); #endif initExtension1(); // This will disable the Motion Plus extension @@ -144,7 +144,7 @@ void WII::ACLData(uint8_t* l2capinbuf) { if ((l2capinbuf[0] | (l2capinbuf[1] << 8)) == (hci_handle | 0x2000)) { // acl_handle_ok or it's a new connection if ((l2capinbuf[6] | (l2capinbuf[7] << 8)) == 0x0001) { //l2cap_control - Channel ID for ACL-U if (l2capinbuf[8] == L2CAP_CMD_COMMAND_REJECT) { -#ifdef DEBUG +#ifdef DEBUG_USB_HOST Notify(PSTR("\r\nL2CAP Command Rejected - Reason: "), 0x80); PrintHex (l2capinbuf[13], 0x80); Notify(PSTR(" "), 0x80); @@ -220,14 +220,14 @@ void WII::ACLData(uint8_t* l2capinbuf) { } } else if (l2capinbuf[8] == L2CAP_CMD_DISCONNECT_REQUEST) { if (l2capinbuf[12] == control_dcid[0] && l2capinbuf[13] == control_dcid[1]) { -#ifdef DEBUG +#ifdef DEBUG_USB_HOST Notify(PSTR("\r\nDisconnect Request: Control Channel"), 0x80); #endif identifier = l2capinbuf[9]; pBtd->l2cap_disconnection_response(hci_handle, identifier, control_dcid, control_scid); Reset(); } else if (l2capinbuf[12] == interrupt_dcid[0] && l2capinbuf[13] == interrupt_dcid[1]) { -#ifdef DEBUG +#ifdef DEBUG_USB_HOST Notify(PSTR("\r\nDisconnect Request: Interrupt Channel"), 0x80); #endif identifier = l2capinbuf[9]; @@ -294,12 +294,12 @@ void WII::ACLData(uint8_t* l2capinbuf) { wiiState = l2capinbuf[12]; // (0x01: Battery is nearly empty), (0x02: An Extension Controller is connected), (0x04: Speaker enabled), (0x08: IR enabled), (0x10: LED1, 0x20: LED2, 0x40: LED3, 0x80: LED4) batteryLevel = l2capinbuf[15]; // Update battery level if (l2capinbuf[12] & 0x01) { -#ifdef DEBUG +#ifdef DEBUG_USB_HOST Notify(PSTR("\r\nWARNING: Battery is nearly empty"), 0x80); #endif } if (l2capinbuf[12] & 0x02) { // Check if a extension is connected -#ifdef DEBUG +#ifdef DEBUG_USB_HOST if (!unknownExtensionConnected) Notify(PSTR("\r\nExtension connected"), 0x80); #endif @@ -309,11 +309,11 @@ void WII::ACLData(uint8_t* l2capinbuf) { #endif setReportMode(false, 0x35); // Also read the extension } else { -#ifdef DEBUG +#ifdef DEBUG_USB_HOST Notify(PSTR("\r\nExtension disconnected"), 0x80); #endif if (motionPlusConnected) { -#ifdef DEBUG +#ifdef DEBUG_USB_HOST Notify(PSTR(" - from Motion Plus"), 0x80); #endif l2cap_event_flag &= ~WII_FLAG_NUNCHUCK_CONNECTED; @@ -321,7 +321,7 @@ void WII::ACLData(uint8_t* l2capinbuf) { nunchuckConnected = false; //else if(classicControllerConnected) } else if (nunchuckConnected) { -#ifdef DEBUG +#ifdef DEBUG_USB_HOST Notify(PSTR(" - Nunchuck"), 0x80); #endif nunchuckConnected = false; // It must be the Nunchuck controller then @@ -337,40 +337,40 @@ void WII::ACLData(uint8_t* l2capinbuf) { if ((l2capinbuf[12] & 0x0F) == 0) { // No error // See: http://wiibrew.org/wiki/Wiimote/Extension_Controllers if (l2capinbuf[16] == 0x00 && l2capinbuf[17] == 0xA4 && l2capinbuf[18] == 0x20 && l2capinbuf[19] == 0x00 && l2capinbuf[20] == 0x00) { -#ifdef DEBUG +#ifdef DEBUG_USB_HOST Notify(PSTR("\r\nNunchuck connected"), 0x80); #endif l2cap_event_flag |= WII_FLAG_NUNCHUCK_CONNECTED; } else if (l2capinbuf[16] == 0x00 && (l2capinbuf[17] == 0xA6 || l2capinbuf[17] == 0xA4) && l2capinbuf[18] == 0x20 && l2capinbuf[19] == 0x00 && l2capinbuf[20] == 0x05) { -#ifdef DEBUG +#ifdef DEBUG_USB_HOST Notify(PSTR("\r\nMotion Plus connected"), 0x80); #endif l2cap_event_flag |= WII_FLAG_MOTION_PLUS_CONNECTED; } else if (l2capinbuf[16] == 0x00 && l2capinbuf[17] == 0xA4 && l2capinbuf[18] == 0x20 && l2capinbuf[19] == 0x04 && l2capinbuf[20] == 0x05) { -#ifdef DEBUG +#ifdef DEBUG_USB_HOST Notify(PSTR("\r\nMotion Plus activated in normal mode"), 0x80); #endif motionPlusConnected = true; } else if (l2capinbuf[16] == 0x00 && l2capinbuf[17] == 0xA4 && l2capinbuf[18] == 0x20 && l2capinbuf[19] == 0x05 && l2capinbuf[20] == 0x05) { -#ifdef DEBUG +#ifdef DEBUG_USB_HOST Notify(PSTR("\r\nMotion Plus activated in Nunchuck pass-through mode"), 0x80); #endif activateNunchuck = false; motionPlusConnected = true; nunchuckConnected = true; } else if (l2capinbuf[16] == 0x00 && l2capinbuf[17] == 0xA6 && l2capinbuf[18] == 0x20 && (l2capinbuf[19] == 0x00 || l2capinbuf[19] == 0x04 || l2capinbuf[19] == 0x05 || l2capinbuf[19] == 0x07) && l2capinbuf[20] == 0x05) { -#ifdef DEBUG +#ifdef DEBUG_USB_HOST Notify(PSTR("\r\nInactive Wii Motion Plus"), 0x80); Notify(PSTR("\r\nPlease unplug the Motion Plus, disconnect the Wiimote and then replug the Motion Plus Extension"), 0x80); #endif stateCounter = 300; // Skip the rest in "L2CAP_CHECK_MOTION_PLUS_STATE" } else if (l2capinbuf[16] == 0x00 && l2capinbuf[17] == 0xA4 && l2capinbuf[18] == 0x20 && l2capinbuf[19] == 0x01 && l2capinbuf[20] == 0x20) { -#ifdef DEBUG +#ifdef DEBUG_USB_HOST Notify(PSTR("\r\nWii U Pro Controller connected"), 0x80); #endif wiiUProControllerConnected = true; } -#ifdef DEBUG +#ifdef DEBUG_USB_HOST else { Notify(PSTR("\r\nUnknown Device: "), 0x80); PrintHex (l2capinbuf[13], 0x80); @@ -392,7 +392,7 @@ void WII::ACLData(uint8_t* l2capinbuf) { #endif break; case 0x22: // Acknowledge output report, return function result -#ifdef DEBUG +#ifdef DEBUG_USB_HOST if (l2capinbuf[13] != 0x00) { // Check if there is an error Notify(PSTR("\r\nCommand failed: "), 0x80); PrintHex (l2capinbuf[12], 0x80); @@ -496,7 +496,7 @@ void WII::ACLData(uint8_t* l2capinbuf) { */ } else { if ((micros() - timer) > 1000000) { // Loop for 1 sec before resetting the values -#ifdef DEBUG +#ifdef DEBUG_USB_HOST Notify(PSTR("\r\nThe gyro values has been reset"), 0x80); #endif gyroYawZero = (l2capinbuf[15] | ((l2capinbuf[18] & 0xFC) << 6)); @@ -531,7 +531,7 @@ void WII::ACLData(uint8_t* l2capinbuf) { if (!extensionConnected) { extensionConnected = true; unknownExtensionConnected = true; -#ifdef DEBUG +#ifdef DEBUG_USB_HOST Notify(PSTR("\r\nExtension connected to Motion Plus"), 0x80); #endif } @@ -539,7 +539,7 @@ void WII::ACLData(uint8_t* l2capinbuf) { if (extensionConnected && !unknownExtensionConnected) { extensionConnected = false; unknownExtensionConnected = true; -#ifdef DEBUG +#ifdef DEBUG_USB_HOST Notify(PSTR("\r\nExtension disconnected from Motion Plus"), 0x80); #endif nunchuckConnected = false; // There is no extension connected to the Motion Plus if this report is sent @@ -564,7 +564,7 @@ void WII::ACLData(uint8_t* l2capinbuf) { hatValues[RightHatY] = (l2capinbuf[21] | l2capinbuf[22] << 8); } break; -#ifdef DEBUG +#ifdef DEBUG_USB_HOST default: Notify(PSTR("\r\nUnknown Report type: "), 0x80); PrintHex (l2capinbuf[9], 0x80); @@ -583,7 +583,7 @@ void WII::L2CAP_task() { /* These states are used if the Wiimote is the host */ case L2CAP_CONTROL_SUCCESS: if (l2cap_config_success_control_flag) { -#ifdef DEBUG +#ifdef DEBUG_USB_HOST Notify(PSTR("\r\nHID Control Successfully Configured"), 0x80); #endif l2cap_state = L2CAP_INTERRUPT_SETUP; @@ -592,7 +592,7 @@ void WII::L2CAP_task() { case L2CAP_INTERRUPT_SETUP: if (l2cap_connection_request_interrupt_flag) { -#ifdef DEBUG +#ifdef DEBUG_USB_HOST Notify(PSTR("\r\nHID Interrupt Incoming Connection Request"), 0x80); #endif pBtd->l2cap_connection_response(hci_handle, identifier, interrupt_dcid, interrupt_scid, PENDING); @@ -609,7 +609,7 @@ void WII::L2CAP_task() { /* These states are used if the Arduino is the host */ case L2CAP_CONTROL_CONNECT_REQUEST: if (l2cap_connected_control_flag) { -#ifdef DEBUG +#ifdef DEBUG_USB_HOST Notify(PSTR("\r\nSend HID Control Config Request"), 0x80); #endif identifier++; @@ -620,7 +620,7 @@ void WII::L2CAP_task() { case L2CAP_CONTROL_CONFIG_REQUEST: if (l2cap_config_success_control_flag) { -#ifdef DEBUG +#ifdef DEBUG_USB_HOST Notify(PSTR("\r\nSend HID Interrupt Connection Request"), 0x80); #endif identifier++; @@ -631,7 +631,7 @@ void WII::L2CAP_task() { case L2CAP_INTERRUPT_CONNECT_REQUEST: if (l2cap_connected_interrupt_flag) { -#ifdef DEBUG +#ifdef DEBUG_USB_HOST Notify(PSTR("\r\nSend HID Interrupt Config Request"), 0x80); #endif identifier++; @@ -642,7 +642,7 @@ void WII::L2CAP_task() { case L2CAP_INTERRUPT_CONFIG_REQUEST: if (l2cap_config_success_interrupt_flag) { // Now the HID channels is established -#ifdef DEBUG +#ifdef DEBUG_USB_HOST Notify(PSTR("\r\nHID Channels Established"), 0x80); #endif pBtd->connectToWii = false; @@ -657,7 +657,7 @@ void WII::L2CAP_task() { case L2CAP_INTERRUPT_DISCONNECT: if (l2cap_disconnect_response_interrupt_flag) { -#ifdef DEBUG +#ifdef DEBUG_USB_HOST Notify(PSTR("\r\nDisconnected Interrupt Channel"), 0x80); #endif identifier++; @@ -668,7 +668,7 @@ void WII::L2CAP_task() { case L2CAP_CONTROL_DISCONNECT: if (l2cap_disconnect_response_control_flag) { -#ifdef DEBUG +#ifdef DEBUG_USB_HOST Notify(PSTR("\r\nDisconnected Control Channel"), 0x80); #endif pBtd->hci_disconnect(hci_handle); @@ -686,7 +686,7 @@ void WII::Run() { if (pBtd->connectToWii && !pBtd->l2capConnectionClaimed && !wiimoteConnected && !activeConnection) { pBtd->l2capConnectionClaimed = true; activeConnection = true; -#ifdef DEBUG +#ifdef DEBUG_USB_HOST Notify(PSTR("\r\nSend HID Control Connection Request"), 0x80); #endif hci_handle = pBtd->hci_handle; // Store the HCI Handle for the connection @@ -695,7 +695,7 @@ void WII::Run() { pBtd->l2cap_connection_request(hci_handle, identifier, control_dcid, HID_CTRL_PSM); l2cap_state = L2CAP_CONTROL_CONNECT_REQUEST; } else if (l2cap_connection_request_control_flag) { -#ifdef DEBUG +#ifdef DEBUG_USB_HOST Notify(PSTR("\r\nHID Control Incoming Connection Request"), 0x80); #endif pBtd->l2cap_connection_response(hci_handle, identifier, control_dcid, control_scid, PENDING); @@ -709,7 +709,7 @@ void WII::Run() { break; case L2CAP_CHECK_MOTION_PLUS_STATE: -#ifdef DEBUG +#ifdef DEBUG_USB_HOST if (stateCounter == 0) // Only print onnce Notify(PSTR("\r\nChecking if a Motion Plus is connected"), 0x80); #endif @@ -722,14 +722,14 @@ void WII::Run() { timer = micros(); if (unknownExtensionConnected) { -#ifdef DEBUG +#ifdef DEBUG_USB_HOST Notify(PSTR("\r\nA extension is also connected"), 0x80); #endif activateNunchuck = true; // For we will just set this to true as this the only extension supported so far } } else if (stateCounter == 601) { // We will try three times to check for the motion plus -#ifdef DEBUG +#ifdef DEBUG_USB_HOST Notify(PSTR("\r\nNo Motion Plus was detected"), 0x80); #endif stateCounter = 0; @@ -738,7 +738,7 @@ void WII::Run() { break; case L2CAP_CHECK_EXTENSION_STATE: // This is used to check if there is anything plugged in to the extension port -#ifdef DEBUG +#ifdef DEBUG_USB_HOST if (stateCounter == 0) // Only print onnce Notify(PSTR("\r\nChecking if there is any extension connected"), 0x80); #endif @@ -785,7 +785,7 @@ void WII::Run() { case L2CAP_DONE: if (unknownExtensionConnected) { -#ifdef DEBUG +#ifdef DEBUG_USB_HOST if (stateCounter == 0) // Only print once Notify(PSTR("\r\nChecking extension port"), 0x80); #endif @@ -803,7 +803,7 @@ void WII::Run() { readExtensionType(); else if (stateCounter == 250) { if (nunchuck_connected_flag) { -#ifdef DEBUG +#ifdef DEBUG_USB_HOST Notify(PSTR("\r\nNunchuck was reconnected"), 0x80); #endif activateNunchuck = true; @@ -813,7 +813,7 @@ void WII::Run() { stateCounter = 449; } else if (stateCounter == 300) { if (motionPlusConnected) { -#ifdef DEBUG +#ifdef DEBUG_USB_HOST Notify(PSTR("\r\nReactivating the Motion Plus"), 0x80); #endif initMotionPlus(); @@ -967,19 +967,19 @@ void WII::initMotionPlus() { void WII::activateMotionPlus() { uint8_t buf[1]; if (pBtd->wiiUProController) { -#ifdef DEBUG +#ifdef DEBUG_USB_HOST Notify(PSTR("\r\nActivating Wii U Pro Controller"), 0x80); #endif buf[0] = 0x00; // It seems like you can send anything but 0x04, 0x05, and 0x07 } else if (activateNunchuck) { -#ifdef DEBUG +#ifdef DEBUG_USB_HOST Notify(PSTR("\r\nActivating Motion Plus in pass-through mode"), 0x80); #endif buf[0] = 0x05; // Activate nunchuck pass-through mode } //else if(classicControllerConnected && extensionConnected) //buf[0] = 0x07; else { -#ifdef DEBUG +#ifdef DEBUG_USB_HOST Notify(PSTR("\r\nActivating Motion Plus in normal mode"), 0x80); #endif buf[0] = 0x04; // Don't use any extension @@ -1071,58 +1071,58 @@ uint16_t WII::getAnalogHat(AnalogHat a) { void WII::IRinitialize() { // Turns on and initialises the IR camera enableIRCamera1(); -#ifdef DEBUG +#ifdef DEBUG_USB_HOST Notify(PSTR("\r\nEnable IR Camera1 Complete"), 0x80); #endif delay(80); enableIRCamera2(); -#ifdef DEBUG +#ifdef DEBUG_USB_HOST Notify(PSTR("\r\nEnable IR Camera2 Complete"), 0x80); #endif delay(80); write0x08Value(); -#ifdef DEBUG +#ifdef DEBUG_USB_HOST Notify(PSTR("\r\nWrote hex number 0x08"), 0x80); #endif delay(80); writeSensitivityBlock1(); -#ifdef DEBUG +#ifdef DEBUG_USB_HOST Notify(PSTR("\r\nWrote Sensitivity Block 1"), 0x80); #endif delay(80); writeSensitivityBlock2(); -#ifdef DEBUG +#ifdef DEBUG_USB_HOST Notify(PSTR("\r\nWrote Sensitivity Block 2"), 0x80); #endif delay(80); uint8_t mode_num = 0x03; setWiiModeNumber(mode_num); // Change input for whatever mode you want i.e. 0x01, 0x03, or 0x05 -#ifdef DEBUG +#ifdef DEBUG_USB_HOST Notify(PSTR("\r\nSet Wii Mode Number To 0x"), 0x80); PrintHex (mode_num, 0x80); #endif delay(80); write0x08Value(); -#ifdef DEBUG +#ifdef DEBUG_USB_HOST Notify(PSTR("\r\nWrote Hex Number 0x08"), 0x80); #endif delay(80); setReportMode(false, 0x33); //setReportMode(false, 0x3f); // For full reporting mode, doesn't work yet -#ifdef DEBUG +#ifdef DEBUG_USB_HOST Notify(PSTR("\r\nSet Report Mode to 0x33"), 0x80); #endif delay(80); statusRequest(); // Used to update wiiState - call isIRCameraEnabled() afterwards to check if it actually worked -#ifdef DEBUG +#ifdef DEBUG_USB_HOST Notify(PSTR("\r\nIR Initialized"), 0x80); #endif } diff --git a/XBOXRECV.cpp b/XBOXRECV.cpp index 51e64e82..4f39ce04 100644 --- a/XBOXRECV.cpp +++ b/XBOXRECV.cpp @@ -18,7 +18,7 @@ */ #include "XBOXRECV.h" -// To enable serial debugging uncomment "#define DEBUG" in message.h +// To enable serial debugging uncomment "#define DEBUG_USB_HOST" in message.h //#define EXTRADEBUG // Uncomment to get even more debugging data //#define PRINTREPORT // Uncomment to print the report send by the Xbox 360 Controller @@ -52,7 +52,7 @@ uint8_t XBOXRECV::Init(uint8_t parent, uint8_t port, bool lowspeed) { #endif // check if address has already been assigned to an instance if (bAddress) { -#ifdef DEBUG +#ifdef DEBUG_USB_HOST Notify(PSTR("\r\nAddress in use"), 0x80); #endif return USB_ERROR_CLASS_INSTANCE_ALREADY_IN_USE; @@ -62,14 +62,14 @@ uint8_t XBOXRECV::Init(uint8_t parent, uint8_t port, bool lowspeed) { p = addrPool.GetUsbDevicePtr(0); if (!p) { -#ifdef DEBUG +#ifdef DEBUG_USB_HOST Notify(PSTR("\r\nAddress not found"), 0x80); #endif return USB_ERROR_ADDRESS_NOT_FOUND_IN_POOL; } if (!p->epinfo) { -#ifdef DEBUG +#ifdef DEBUG_USB_HOST Notify(PSTR("\r\nepinfo is null"), 0x80); #endif return USB_ERROR_EPINFO_IS_NULL; @@ -97,7 +97,7 @@ uint8_t XBOXRECV::Init(uint8_t parent, uint8_t port, bool lowspeed) { if (VID != XBOX_VID && VID != MADCATZ_VID) // We just check if it's a xbox receiver using the Vendor ID goto FailUnknownDevice; else if (PID != XBOX_WIRELESS_RECEIVER_PID && PID != XBOX_WIRELESS_RECEIVER_THIRD_PARTY_PID) { -#ifdef DEBUG +#ifdef DEBUG_USB_HOST Notify(PSTR("\r\nYou'll need a wireless receiver for this libary to work"), 0x80); #endif goto FailUnknownDevice; @@ -118,7 +118,7 @@ uint8_t XBOXRECV::Init(uint8_t parent, uint8_t port, bool lowspeed) { p->lowspeed = false; addrPool.FreeAddress(bAddress); bAddress = 0; -#ifdef DEBUG +#ifdef DEBUG_USB_HOST Notify(PSTR("\r\nsetAddr: "), 0x80); PrintHex (rcode, 0x80); #endif @@ -209,7 +209,7 @@ uint8_t XBOXRECV::Init(uint8_t parent, uint8_t port, bool lowspeed) { if (rcode) goto FailSetConfDescr; -#ifdef DEBUG +#ifdef DEBUG_USB_HOST Notify(PSTR("\r\nXbox Wireless Receiver Connected\r\n"), 0x80); #endif XboxReceiverConnected = true; @@ -218,31 +218,31 @@ uint8_t XBOXRECV::Init(uint8_t parent, uint8_t port, bool lowspeed) { /* diagnostic messages */ FailGetDevDescr: -#ifdef DEBUG +#ifdef DEBUG_USB_HOST NotifyFailGetDevDescr(); goto Fail; #endif FailSetDevTblEntry: -#ifdef DEBUG +#ifdef DEBUG_USB_HOST NotifyFailSetDevTblEntry(); goto Fail; #endif FailSetConfDescr: -#ifdef DEBUG +#ifdef DEBUG_USB_HOST NotifyFailSetConfDescr(); #endif goto Fail; FailUnknownDevice: -#ifdef DEBUG +#ifdef DEBUG_USB_HOST NotifyFailUnknownDevice(VID,PID); #endif rcode = USB_DEV_CONFIG_ERROR_DEVICE_NOT_SUPPORTED; Fail: -#ifdef DEBUG +#ifdef DEBUG_USB_HOST Notify(PSTR("\r\nXbox 360 Init Failed, error code: "), 0x80); NotifyFail(rcode); #endif @@ -304,12 +304,12 @@ void XBOXRECV::readReport(uint8_t controller) { // This report is send when a controller is connected and disconnected if (readBuf[0] == 0x08 && readBuf[1] != Xbox360Connected[controller]) { Xbox360Connected[controller] = readBuf[1]; -#ifdef DEBUG +#ifdef DEBUG_USB_HOST Notify(PSTR("Controller "), 0x80); Notify(controller, 0x80); #endif if (Xbox360Connected[controller]) { -#ifdef DEBUG +#ifdef DEBUG_USB_HOST char* str = 0; switch (readBuf[1]) { case 0x80: str = PSTR(" as controller\r\n"); @@ -335,7 +335,7 @@ void XBOXRECV::readReport(uint8_t controller) { } setLedOn(led, controller); } -#ifdef DEBUG +#ifdef DEBUG_USB_HOST else Notify(PSTR(": disconnected\r\n"), 0x80); #endif diff --git a/XBOXUSB.cpp b/XBOXUSB.cpp index eff7d383..3b308306 100644 --- a/XBOXUSB.cpp +++ b/XBOXUSB.cpp @@ -16,7 +16,7 @@ */ #include "XBOXUSB.h" -// To enable serial debugging uncomment "#define DEBUG" in message.h +// To enable serial debugging uncomment "#define DEBUG_USB_HOST" in message.h //#define EXTRADEBUG // Uncomment to get even more debugging data //#define PRINTREPORT // Uncomment to print the report send by the Xbox 360 Controller @@ -50,7 +50,7 @@ uint8_t XBOXUSB::Init(uint8_t parent, uint8_t port, bool lowspeed) { #endif // check if address has already been assigned to an instance if (bAddress) { -#ifdef DEBUG +#ifdef DEBUG_USB_HOST Notify(PSTR("\r\nAddress in use"), 0x80); #endif return USB_ERROR_CLASS_INSTANCE_ALREADY_IN_USE; @@ -60,14 +60,14 @@ uint8_t XBOXUSB::Init(uint8_t parent, uint8_t port, bool lowspeed) { p = addrPool.GetUsbDevicePtr(0); if (!p) { -#ifdef DEBUG +#ifdef DEBUG_USB_HOST Notify(PSTR("\r\nAddress not found"), 0x80); #endif return USB_ERROR_ADDRESS_NOT_FOUND_IN_POOL; } if (!p->epinfo) { -#ifdef DEBUG +#ifdef DEBUG_USB_HOST Notify(PSTR("\r\nepinfo is null"), 0x80); #endif return USB_ERROR_EPINFO_IS_NULL; @@ -95,12 +95,12 @@ uint8_t XBOXUSB::Init(uint8_t parent, uint8_t port, bool lowspeed) { if (VID != XBOX_VID && VID != MADCATZ_VID && VID != JOYTECH_VID) // We just check if it's a xbox controller using the Vendor ID goto FailUnknownDevice; if (PID == XBOX_WIRELESS_PID) { -#ifdef DEBUG +#ifdef DEBUG_USB_HOST Notify(PSTR("\r\nYou have plugged in a wireless Xbox 360 controller - it doesn't support USB communication"), 0x80); #endif goto FailUnknownDevice; } else if (PID == XBOX_WIRELESS_RECEIVER_PID || PID == XBOX_WIRELESS_RECEIVER_THIRD_PARTY_PID) { -#ifdef DEBUG +#ifdef DEBUG_USB_HOST Notify(PSTR("\r\nThis library only supports Xbox 360 controllers via USB"), 0x80); #endif goto FailUnknownDevice; @@ -121,7 +121,7 @@ uint8_t XBOXUSB::Init(uint8_t parent, uint8_t port, bool lowspeed) { p->lowspeed = false; addrPool.FreeAddress(bAddress); bAddress = 0; -#ifdef DEBUG +#ifdef DEBUG_USB_HOST Notify(PSTR("\r\nsetAddr: "), 0x80); #endif PrintHex (rcode, 0x80); @@ -173,7 +173,7 @@ uint8_t XBOXUSB::Init(uint8_t parent, uint8_t port, bool lowspeed) { if (rcode) goto FailSetConfDescr; -#ifdef DEBUG +#ifdef DEBUG_USB_HOST Notify(PSTR("\r\nXbox 360 Controller Connected\r\n"), 0x80); #endif setLedOn(LED1); @@ -183,30 +183,30 @@ uint8_t XBOXUSB::Init(uint8_t parent, uint8_t port, bool lowspeed) { /* diagnostic messages */ FailGetDevDescr: -#ifdef DEBUG +#ifdef DEBUG_USB_HOST NotifyFailGetDevDescr(); goto Fail; #endif FailSetDevTblEntry: -#ifdef DEBUG +#ifdef DEBUG_USB_HOST NotifyFailSetDevTblEntry(); goto Fail; #endif FailSetConfDescr: -#ifdef DEBUG +#ifdef DEBUG_USB_HOST NotifyFailSetConfDescr(); goto Fail; #endif FailUnknownDevice: -#ifdef DEBUG +#ifdef DEBUG_USB_HOST NotifyFailUnknownDevice(VID, PID); #endif rcode = USB_DEV_CONFIG_ERROR_DEVICE_NOT_SUPPORTED; Fail: -#ifdef DEBUG +#ifdef DEBUG_USB_HOST Notify(PSTR("\r\nXbox 360 Init Failed, error code: "), 0x80); NotifyFail(rcode); #endif diff --git a/adk.cpp b/adk.cpp index 14904ade..14d35860 100644 --- a/adk.cpp +++ b/adk.cpp @@ -227,43 +227,43 @@ uint8_t ADK::Init(uint8_t parent, uint8_t port, bool lowspeed) { /* diagnostic messages */ FailGetDevDescr: -#ifdef DEBUG +#ifdef DEBUG_USB_HOST NotifyFailGetDevDescr(); goto Fail; #endif FailSetDevTblEntry: -#ifdef DEBUG +#ifdef DEBUG_USB_HOST NotifyFailSetDevTblEntry(); goto Fail; #endif FailGetConfDescr: -#ifdef DEBUG +#ifdef DEBUG_USB_HOST NotifyFailGetConfDescr(); goto Fail; #endif FailSetConfDescr: -#ifdef DEBUG +#ifdef DEBUG_USB_HOST NotifyFailSetConfDescr(); goto Fail; #endif FailGetProto: -#ifdef DEBUG +#ifdef DEBUG_USB_HOST USBTRACE("\r\ngetProto:"); goto Fail; #endif FailSwAcc: -#ifdef DEBUG +#ifdef DEBUG_USB_HOST USBTRACE("\r\nswAcc:"); goto Fail; #endif SwAttempt: -#ifdef DEBUG +#ifdef DEBUG_USB_HOST USBTRACE("\r\nAccessory mode switch attempt"); #endif //FailOnInit: diff --git a/cdcacm.cpp b/cdcacm.cpp index b6891615..2c75a594 100644 --- a/cdcacm.cpp +++ b/cdcacm.cpp @@ -183,36 +183,36 @@ uint8_t ACM::Init(uint8_t parent, uint8_t port, bool lowspeed) { return 0; FailGetDevDescr: -#ifdef DEBUG +#ifdef DEBUG_USB_HOST NotifyFailGetDevDescr(); goto Fail; #endif FailSetDevTblEntry: -#ifdef DEBUG +#ifdef DEBUG_USB_HOST NotifyFailSetDevTblEntry(); goto Fail; #endif FailGetConfDescr: -#ifdef DEBUG +#ifdef DEBUG_USB_HOST NotifyFailGetConfDescr(); goto Fail; #endif FailSetConfDescr: -#ifdef DEBUG +#ifdef DEBUG_USB_HOST NotifyFailSetConfDescr(); goto Fail; #endif FailOnInit: -#ifdef DEBUG +#ifdef DEBUG_USB_HOST USBTRACE("OnInit:"); #endif Fail: -#ifdef DEBUG +#ifdef DEBUG_USB_HOST NotifyFail(rcode); #endif Release(); diff --git a/cdcftdi.cpp b/cdcftdi.cpp index 626ed09f..a8489373 100644 --- a/cdcftdi.cpp +++ b/cdcftdi.cpp @@ -178,36 +178,36 @@ uint8_t FTDI::Init(uint8_t parent, uint8_t port, bool lowspeed) { return 0; FailGetDevDescr: -#ifdef DEBUG +#ifdef DEBUG_USB_HOST NotifyFailGetDevDescr(); goto Fail; #endif FailSetDevTblEntry: -#ifdef DEBUG +#ifdef DEBUG_USB_HOST NotifyFailSetDevTblEntry(); goto Fail; #endif FailGetConfDescr: -#ifdef DEBUG +#ifdef DEBUG_USB_HOST NotifyFailGetConfDescr(); goto Fail; #endif FailSetConfDescr: -#ifdef DEBUG +#ifdef DEBUG_USB_HOST NotifyFailSetConfDescr(); goto Fail; #endif FailOnInit: -#ifdef DEBUG +#ifdef DEBUG_USB_HOST USBTRACE("OnInit:"); #endif Fail: -#ifdef DEBUG +#ifdef DEBUG_USB_HOST NotifyFail(rcode); #endif Release(); diff --git a/cdcprolific.cpp b/cdcprolific.cpp index 4be8198d..ac4b0f63 100644 --- a/cdcprolific.cpp +++ b/cdcprolific.cpp @@ -155,36 +155,36 @@ uint8_t PL2303::Init(uint8_t parent, uint8_t port, bool lowspeed) { return 0; FailGetDevDescr: -#ifdef DEBUG +#ifdef DEBUG_USB_HOST NotifyFailGetDevDescr(); goto Fail; #endif FailSetDevTblEntry: -#ifdef DEBUG +#ifdef DEBUG_USB_HOST NotifyFailSetDevTblEntry(); goto Fail; #endif FailGetConfDescr: -#ifdef DEBUG +#ifdef DEBUG_USB_HOST NotifyFailGetConfDescr(); goto Fail; #endif FailSetConfDescr: -#ifdef DEBUG +#ifdef DEBUG_USB_HOST NotifyFailSetConfDescr(); goto Fail; #endif FailOnInit: -#ifdef DEBUG +#ifdef DEBUG_USB_HOST USBTRACE("OnInit:"); #endif Fail: -#ifdef DEBUG +#ifdef DEBUG_USB_HOST NotifyFail(rcode); #endif Release(); diff --git a/hidboot.h b/hidboot.h index bf002f64..797b3a3c 100644 --- a/hidboot.h +++ b/hidboot.h @@ -393,42 +393,42 @@ uint8_t HIDBoot::Init(uint8_t parent, uint8_t port, bool lowspeed return 0; FailGetDevDescr: -#ifdef DEBUG +#ifdef DEBUG_USB_HOST NotifyFailGetDevDescr(); goto Fail; #endif FailSetDevTblEntry: -#ifdef DEBUG +#ifdef DEBUG_USB_HOST NotifyFailSetDevTblEntry(); goto Fail; #endif FailGetConfDescr: -#ifdef DEBUG +#ifdef DEBUG_USB_HOST NotifyFailGetConfDescr(); goto Fail; #endif FailSetConfDescr: -#ifdef DEBUG +#ifdef DEBUG_USB_HOST NotifyFailSetConfDescr(); goto Fail; #endif FailSetProtocol: -#ifdef DEBUG +#ifdef DEBUG_USB_HOST USBTRACE("SetProto:"); goto Fail; #endif FailSetIdle: -#ifdef DEBUG +#ifdef DEBUG_USB_HOST USBTRACE("SetIdle:"); #endif Fail: -#ifdef DEBUG +#ifdef DEBUG_USB_HOST NotifyFail(rcode); #endif Release(); diff --git a/hiduniversal.cpp b/hiduniversal.cpp index d35480f7..800839e1 100644 --- a/hiduniversal.cpp +++ b/hiduniversal.cpp @@ -221,37 +221,37 @@ uint8_t HIDUniversal::Init(uint8_t parent, uint8_t port, bool lowspeed) { return 0; FailGetDevDescr: -#ifdef DEBUG +#ifdef DEBUG_USB_HOST NotifyFailGetDevDescr(); goto Fail; #endif FailSetDevTblEntry: -#ifdef DEBUG +#ifdef DEBUG_USB_HOST NotifyFailSetDevTblEntry(); goto Fail; #endif FailGetConfDescr: -#ifdef DEBUG +#ifdef DEBUG_USB_HOST NotifyFailGetConfDescr(); goto Fail; #endif FailSetConfDescr: -#ifdef DEBUG +#ifdef DEBUG_USB_HOST NotifyFailSetConfDescr(); goto Fail; #endif FailSetIdle: -#ifdef DEBUG +#ifdef DEBUG_USB_HOST USBTRACE("SetIdle:"); #endif Fail: -#ifdef DEBUG +#ifdef DEBUG_USB_HOST NotifyFail(rcode); #endif Release(); diff --git a/masstorage.cpp b/masstorage.cpp index 681999ff..6fae6ce1 100644 --- a/masstorage.cpp +++ b/masstorage.cpp @@ -174,7 +174,7 @@ uint8_t BulkOnly::ConfigureDevice(uint8_t parent, uint8_t port, bool lowspeed) { return USB_ERROR_CONFIG_REQUIRES_ADDITIONAL_RESET; FailGetDevDescr: -#ifdef DEBUG +#ifdef DEBUG_USB_HOST NotifyFailGetDevDescr(rcode); #endif rcode = USB_ERROR_FailGetDevDescr; @@ -362,42 +362,42 @@ uint8_t BulkOnly::Init(uint8_t parent, uint8_t port, bool lowspeed) { return 0; FailSetConfDescr: -#ifdef DEBUG +#ifdef DEBUG_USB_HOST NotifyFailSetConfDescr(); goto Fail; #endif FailOnInit: -#ifdef DEBUG +#ifdef DEBUG_USB_HOST USBTRACE("OnInit:"); goto Fail; #endif FailGetMaxLUN: -#ifdef DEBUG +#ifdef DEBUG_USB_HOST USBTRACE("GetMaxLUN:"); goto Fail; #endif FailInvalidSectorSize: -#ifdef DEBUG +#ifdef DEBUG_USB_HOST USBTRACE("Sector Size is NOT VALID: "); goto Fail; #endif FailSetDevTblEntry: -#ifdef DEBUG +#ifdef DEBUG_USB_HOST NotifyFailSetDevTblEntry(); goto Fail; #endif FailGetConfDescr: -#ifdef DEBUG +#ifdef DEBUG_USB_HOST NotifyFailGetConfDescr(); #endif Fail: -#ifdef DEBUG +#ifdef DEBUG_USB_HOST NotifyFail(rcode); #endif Release(); diff --git a/message.cpp b/message.cpp index 78883a73..393faa32 100644 --- a/message.cpp +++ b/message.cpp @@ -63,7 +63,7 @@ void E_Notify(double d, int lvl) { Serial.flush(); } -#ifdef DEBUG +#ifdef DEBUG_USB_HOST void NotifyFailGetDevDescr(void) { Notify(PSTR("\r\ngetDevDescr"), 0x80); } diff --git a/message.h b/message.h index 78de0dc6..a2fe5f25 100644 --- a/message.h +++ b/message.h @@ -18,7 +18,7 @@ e-mail : support@circuitsathome.com #define __MESSAGE_H__ // uncomment to activate -//#define DEBUG +//#define DEBUG_USB_HOST #include #include @@ -31,7 +31,7 @@ void E_Notify(uint8_t b, int lvl); void E_NotifyStr(char const * msg, int lvl); void E_Notifyc(char c, int lvl); -#ifdef DEBUG +#ifdef DEBUG_USB_HOST #define Notify E_Notify #define NotifyStr E_NotifyStr #define Notifyc E_Notifyc @@ -61,7 +61,7 @@ void NotifyFail(uint8_t rcode); template void ErrorMessage(uint8_t level, char const * msg, ERROR_TYPE rcode = 0) { -#ifdef DEBUG +#ifdef DEBUG_USB_HOST Notify(msg, level); Notify(PSTR(": "), level); PrintHex (rcode, level); @@ -71,7 +71,7 @@ void ErrorMessage(uint8_t level, char const * msg, ERROR_TYPE rcode = 0) { template void ErrorMessage(char const * msg, ERROR_TYPE rcode = 0) { -#ifdef DEBUG +#ifdef DEBUG_USB_HOST Notify(msg, 0x80); Notify(PSTR(": "), 0x80); PrintHex (rcode, 0x80); diff --git a/printhex.h b/printhex.h index 7ac8af6a..55a5b19f 100644 --- a/printhex.h +++ b/printhex.h @@ -27,7 +27,7 @@ void E_Notifyc(char c, int lvl); template void PrintHex(T val, int lvl) { -#ifdef DEBUG +#ifdef DEBUG_USB_HOST int num_nibbles = sizeof(T) * 2; do { @@ -40,7 +40,7 @@ void PrintHex(T val, int lvl) { template void PrintBin(T val, int lvl) { -#ifdef DEBUG +#ifdef DEBUG_USB_HOST for(T mask = (((T) 1) << ((sizeof(T) << 3) - 1)); mask; mask >>= 1) if(val & mask) E_Notifyc('1', lvl); @@ -51,7 +51,7 @@ void PrintBin(T val, int lvl) { template void SerialPrintHex(T val) { -#ifdef DEBUG +#ifdef DEBUG_USB_HOST int num_nibbles = sizeof(T) * 2; do { @@ -64,7 +64,7 @@ void SerialPrintHex(T val) { template void PrintHex2(Print *prn, T val) { -#ifdef DEBUG +#ifdef DEBUG_USB_HOST T mask = (((T) 1) << (((sizeof(T) << 1) - 1) << 2)); while(mask > 1) {