Merge pull request #44 from felis/xxxajk

Xxxajk and done.
This commit is contained in:
xxxajk 2013-03-30 09:06:14 -07:00
commit bd9307702c
22 changed files with 175 additions and 185 deletions

38
BTD.cpp
View file

@ -143,7 +143,7 @@ uint8_t BTD::Init(uint8_t parent, uint8_t port, bool lowspeed) {
/* We only need the Control endpoint, so we don't have to initialize the other endpoints of device */ /* We only need the Control endpoint, so we don't have to initialize the other endpoints of device */
rcode = pUsb->setConf(bAddress, epInfo[ BTD_CONTROL_PIPE ].epAddr, 1); rcode = pUsb->setConf(bAddress, epInfo[ BTD_CONTROL_PIPE ].epAddr, 1);
if (rcode) if (rcode)
goto FailSetConf; goto FailSetConfDescr;
if (PID == PS3_PID || PID == PS3NAVIGATION_PID) { if (PID == PS3_PID || PID == PS3NAVIGATION_PID) {
#ifdef DEBUG #ifdef DEBUG
@ -193,7 +193,7 @@ uint8_t BTD::Init(uint8_t parent, uint8_t port, bool lowspeed) {
// Set Configuration Value // Set Configuration Value
rcode = pUsb->setConf(bAddress, epInfo[ BTD_CONTROL_PIPE ].epAddr, bConfNum); rcode = pUsb->setConf(bAddress, epInfo[ BTD_CONTROL_PIPE ].epAddr, bConfNum);
if (rcode) if (rcode)
goto FailSetConf; goto FailSetConfDescr;
hci_num_reset_loops = 100; // only loop 100 times before trying to send the hci reset command hci_num_reset_loops = 100; // only loop 100 times before trying to send the hci reset command
hci_counter = 0; hci_counter = 0;
@ -209,40 +209,30 @@ uint8_t BTD::Init(uint8_t parent, uint8_t port, bool lowspeed) {
/* diagnostic messages */ /* diagnostic messages */
FailGetDevDescr: FailGetDevDescr:
#ifdef DEBUG NotifyFailGetDevDescr();
Notify(PSTR("\r\ngetDevDescr"), 0x80);
#endif
goto Fail; goto Fail;
FailSetDevTblEntry: FailSetDevTblEntry:
#ifdef DEBUG NotifyFailSetDevTblEntry();
Notify(PSTR("\r\nsetDevTblEn"), 0x80);
#endif
goto Fail; goto Fail;
FailGetConfDescr: FailGetConfDescr:
#ifdef DEBUG NotifyFailGetConfDescr();
Notify(PSTR("\r\ngetConf"), 0x80);
#endif
goto Fail; goto Fail;
FailSetConf:
#ifdef DEBUG FailSetConfDescr:
Notify(PSTR("\r\nsetConf"), 0x80); NotifyFailSetConfDescr();
#endif
goto Fail; goto Fail;
FailUnknownDevice:
#ifdef DEBUG FailUnknownDevice:
Notify(PSTR("\r\nUnknown Device Connected - VID: "), 0x80); NotifyFailUnknownDevice(VID,PID);
PrintHex<uint16_t > (VID, 0x80);
Notify(PSTR(" PID: "), 0x80);
PrintHex<uint16_t > (PID, 0x80);
#endif
pUsb->setAddr(bAddress, 0, 0); // Reset address pUsb->setAddr(bAddress, 0, 0); // Reset address
rcode = USB_DEV_CONFIG_ERROR_DEVICE_NOT_SUPPORTED; rcode = USB_DEV_CONFIG_ERROR_DEVICE_NOT_SUPPORTED;
goto Fail;
Fail: Fail:
#ifdef DEBUG #ifdef DEBUG
Notify(PSTR("\r\nBTD Init Failed, error code: "), 0x80); Notify(PSTR("\r\nBTD Init Failed, error code: "), 0x80);
Serial.print(rcode);
#endif #endif
NotifyFail(rcode);
Release(); Release();
return rcode; return rcode;
} }

View file

@ -187,7 +187,7 @@ uint8_t PS3USB::Init(uint8_t parent, uint8_t port, bool lowspeed) {
rcode = pUsb->setConf(bAddress, epInfo[ PS3_CONTROL_PIPE ].epAddr, 1); rcode = pUsb->setConf(bAddress, epInfo[ PS3_CONTROL_PIPE ].epAddr, 1);
if (rcode) if (rcode)
goto FailSetConf; goto FailSetConfDescr;
if (PID == PS3_PID || PID == PS3NAVIGATION_PID) { if (PID == PS3_PID || PID == PS3NAVIGATION_PID) {
if (PID == PS3_PID) { if (PID == PS3_PID) {
@ -232,34 +232,25 @@ uint8_t PS3USB::Init(uint8_t parent, uint8_t port, bool lowspeed) {
/* diagnostic messages */ /* diagnostic messages */
FailGetDevDescr: FailGetDevDescr:
#ifdef DEBUG NotifyFailGetDevDescr();
Notify(PSTR("\r\ngetDevDescr:"), 0x80);
#endif
goto Fail; goto Fail;
FailSetDevTblEntry: FailSetDevTblEntry:
#ifdef DEBUG NotifyFailSetDevTblEntry();
Notify(PSTR("\r\nsetDevTblEn:"), 0x80);
#endif
goto Fail; goto Fail;
FailSetConf:
#ifdef DEBUG FailSetConfDescr:
Notify(PSTR("\r\nsetConf:"), 0x80); NotifyFailSetConfDescr();
#endif
goto Fail; goto Fail;
FailUnknownDevice: FailUnknownDevice:
#ifdef DEBUG NotifyFailUnknownDevice(VID,PID);
Notify(PSTR("\r\nUnknown Device Connected - VID: "), 0x80);
PrintHex<uint16_t > (VID, 0x80);
Notify(PSTR(" PID: "), 0x80);
PrintHex<uint16_t > (PID, 0x80);
#endif
rcode = USB_DEV_CONFIG_ERROR_DEVICE_NOT_SUPPORTED; rcode = USB_DEV_CONFIG_ERROR_DEVICE_NOT_SUPPORTED;
goto Fail; Fail:
Fail:
#ifdef DEBUG #ifdef DEBUG
Notify(PSTR("\r\nPS3 Init Failed, error code: "), 0x80); Notify(PSTR("\r\nPS3 Init Failed, error code: "), 0x80);
Serial.print(rcode, HEX);
#endif #endif
NotifyFail(rcode);
Release(); Release();
return rcode; return rcode;
} }

6
Usb.h
View file

@ -18,10 +18,8 @@ e-mail : support@circuitsathome.com
#ifndef _usb_h_ #ifndef _usb_h_
#define _usb_h_ #define _usb_h_
//#define BOARD_BLACK_WIDDOW //#define BOARD_BLACK_WIDDOW
#define USB_METHODS_INLINE #define USB_METHODS_INLINE
#include <inttypes.h> #include <inttypes.h>
@ -39,12 +37,8 @@ e-mail : support@circuitsathome.com
#else #else
#include <WProgram.h> #include <WProgram.h>
#endif #endif
#include "printhex.h"
#include "hexdump.h"
#include "message.h" #include "message.h"
extern int UsbDEBUGlvl;
/* shield pins. First parameter - SS pin, second parameter - INT pin */ /* shield pins. First parameter - SS pin, second parameter - INT pin */
#ifdef BOARD_BLACK_WIDDOW #ifdef BOARD_BLACK_WIDDOW

6
Wii.h
View file

@ -204,6 +204,10 @@ public:
*/ */
void setLedStatus(); void setLedStatus();
/**
* Call this to update battery level and Wiimote state
*/
void statusRequest();
/** /**
* Return the battery level of the Wiimote. * Return the battery level of the Wiimote.
* @return The battery level in the range 0-255. * @return The battery level in the range 0-255.
@ -211,7 +215,6 @@ public:
uint8_t getBatteryLevel() { uint8_t getBatteryLevel() {
return batteryLevel; return batteryLevel;
}; };
/** /**
* Return the Wiimote state. * Return the Wiimote state.
* @return See: http://wiibrew.org/wiki/Wiimote#0x20:_Status. * @return See: http://wiibrew.org/wiki/Wiimote#0x20:_Status.
@ -438,7 +441,6 @@ private:
/* HID Commands */ /* HID Commands */
void HID_Command(uint8_t* data, uint8_t nbytes); void HID_Command(uint8_t* data, uint8_t nbytes);
void setReportMode(bool continuous, uint8_t mode); void setReportMode(bool continuous, uint8_t mode);
void statusRequest();
void writeData(uint32_t offset, uint8_t size, uint8_t* data); void writeData(uint32_t offset, uint8_t size, uint8_t* data);
void initExtension1(); void initExtension1();

View file

@ -207,7 +207,7 @@ uint8_t XBOXRECV::Init(uint8_t parent, uint8_t port, bool lowspeed) {
rcode = pUsb->setConf(bAddress, epInfo[ XBOX_CONTROL_PIPE ].epAddr, 1); rcode = pUsb->setConf(bAddress, epInfo[ XBOX_CONTROL_PIPE ].epAddr, 1);
if (rcode) if (rcode)
goto FailSetConf; goto FailSetConfDescr;
#ifdef DEBUG #ifdef DEBUG
Notify(PSTR("\r\nXbox Wireless Receiver Connected\r\n"), 0x80); Notify(PSTR("\r\nXbox Wireless Receiver Connected\r\n"), 0x80);
@ -218,34 +218,26 @@ uint8_t XBOXRECV::Init(uint8_t parent, uint8_t port, bool lowspeed) {
/* diagnostic messages */ /* diagnostic messages */
FailGetDevDescr: FailGetDevDescr:
#ifdef DEBUG NotifyFailGetDevDescr();
Notify(PSTR("\r\ngetDevDescr:"), 0x80);
#endif
goto Fail; goto Fail;
FailSetDevTblEntry: FailSetDevTblEntry:
#ifdef DEBUG NotifyFailSetDevTblEntry();
Notify(PSTR("\r\nsetDevTblEn:"), 0x80);
#endif
goto Fail; goto Fail;
FailSetConf:
#ifdef DEBUG FailSetConfDescr:
Notify(PSTR("\r\nsetConf:"), 0x80); NotifyFailSetConfDescr();
#endif
goto Fail; goto Fail;
FailUnknownDevice:
#ifdef DEBUG FailUnknownDevice:
Notify(PSTR("\r\nUnknown Device Connected - VID: "), 0x80); NotifyFailUnknownDevice(VID,PID);
PrintHex<uint16_t > (VID, 0x80);
Notify(PSTR(" PID: "), 0x80);
PrintHex<uint16_t > (PID, 0x80);
#endif
rcode = USB_DEV_CONFIG_ERROR_DEVICE_NOT_SUPPORTED; rcode = USB_DEV_CONFIG_ERROR_DEVICE_NOT_SUPPORTED;
goto Fail;
Fail: Fail:
#ifdef DEBUG #ifdef DEBUG
Notify(PSTR("\r\nXbox 360 Init Failed, error code: "), 0x80); Notify(PSTR("\r\nXbox 360 Init Failed, error code: "), 0x80);
Serial.print(rcode, HEX);
#endif #endif
NotifyFail(rcode);
Release(); Release();
return rcode; return rcode;
} }
@ -447,10 +439,7 @@ ControllerStatus Breakdown
ControllerStatus[controller] & 0x8000 // 0 ControllerStatus[controller] & 0x8000 // 0
*/ */
uint8_t XBOXRECV::getBatteryLevel(uint8_t controller) { uint8_t XBOXRECV::getBatteryLevel(uint8_t controller) {
uint8_t batteryLevel = ((controllerStatus[controller] & 0x00C0) >> 6) * 33; return ((controllerStatus[controller] & 0x00C0) >> 6);
if (batteryLevel == 99)
batteryLevel = 100;
return batteryLevel;
} }
void XBOXRECV::XboxCommand(uint8_t controller, uint8_t* data, uint16_t nbytes) { void XBOXRECV::XboxCommand(uint8_t controller, uint8_t* data, uint16_t nbytes) {

View file

@ -191,7 +191,7 @@ public:
/** /**
* Used to get the battery level from the controller. * Used to get the battery level from the controller.
* @param controller The controller to read from. * @param controller The controller to read from.
* @return Returns the battery level in percentage in 33% steps. * @return Returns the battery level as an integer in the range of 0-3.
*/ */
uint8_t getBatteryLevel(uint8_t controller); uint8_t getBatteryLevel(uint8_t controller);
/** /**

View file

@ -171,7 +171,7 @@ uint8_t XBOXUSB::Init(uint8_t parent, uint8_t port, bool lowspeed) {
rcode = pUsb->setConf(bAddress, epInfo[ XBOX_CONTROL_PIPE ].epAddr, 1); rcode = pUsb->setConf(bAddress, epInfo[ XBOX_CONTROL_PIPE ].epAddr, 1);
if (rcode) if (rcode)
goto FailSetConf; goto FailSetConfDescr;
#ifdef DEBUG #ifdef DEBUG
Notify(PSTR("\r\nXbox 360 Controller Connected\r\n"), 0x80); Notify(PSTR("\r\nXbox 360 Controller Connected\r\n"), 0x80);
@ -183,34 +183,25 @@ uint8_t XBOXUSB::Init(uint8_t parent, uint8_t port, bool lowspeed) {
/* diagnostic messages */ /* diagnostic messages */
FailGetDevDescr: FailGetDevDescr:
#ifdef DEBUG NotifyFailGetDevDescr();
Notify(PSTR("\r\ngetDevDescr:"), 0x80);
#endif
goto Fail; goto Fail;
FailSetDevTblEntry: FailSetDevTblEntry:
#ifdef DEBUG NotifyFailSetDevTblEntry();
Notify(PSTR("\r\nsetDevTblEn:"), 0x80);
#endif
goto Fail; goto Fail;
FailSetConf:
#ifdef DEBUG FailSetConfDescr:
Notify(PSTR("\r\nsetConf:"), 0x80); NotifyFailSetConfDescr();
#endif
goto Fail; goto Fail;
FailUnknownDevice: FailUnknownDevice:
#ifdef DEBUG NotifyFailUnknownDevice(VID,PID);
Notify(PSTR("\r\nUnknown Device Connected - VID: "), 0x80);
PrintHex<uint16_t > (VID, 0x80);
Notify(PSTR(" PID: "), 0x80);
PrintHex<uint16_t > (PID, 0x80);
#endif
rcode = USB_DEV_CONFIG_ERROR_DEVICE_NOT_SUPPORTED; rcode = USB_DEV_CONFIG_ERROR_DEVICE_NOT_SUPPORTED;
goto Fail;
Fail: Fail:
#ifdef DEBUG #ifdef DEBUG
Notify(PSTR("\r\nXbox 360 Init Failed, error code: "), 0x80); Notify(PSTR("\r\nXbox 360 Init Failed, error code: "), 0x80);
Serial.print(rcode, HEX);
#endif #endif
NotifyFail(rcode);
Release(); Release();
return rcode; return rcode;
} }

27
adk.cpp
View file

@ -176,7 +176,7 @@ uint8_t ADK::Init(uint8_t parent, uint8_t port, bool lowspeed) {
// Set Configuration Value // Set Configuration Value
rcode = pUsb->setConf(bAddress, 0, bConfNum); rcode = pUsb->setConf(bAddress, 0, bConfNum);
if (rcode) { if (rcode) {
goto FailSetConf; goto FailSetConfDescr;
} }
/* print endpoint structure */ /* print endpoint structure */
// USBTRACE("\r\nEndpoint Structure:"); // USBTRACE("\r\nEndpoint Structure:");
@ -227,11 +227,19 @@ uint8_t ADK::Init(uint8_t parent, uint8_t port, bool lowspeed) {
/* diagnostic messages */ /* diagnostic messages */
FailGetDevDescr: FailGetDevDescr:
USBTRACE("\r\ngetDevDescr:"); NotifyFailGetDevDescr();
goto Fail; goto Fail;
FailSetDevTblEntry: FailSetDevTblEntry:
USBTRACE("\r\nsetDevTblEn:"); NotifyFailSetDevTblEntry();
goto Fail;
FailGetConfDescr:
NotifyFailGetConfDescr();
goto Fail;
FailSetConfDescr:
NotifyFailSetConfDescr();
goto Fail; goto Fail;
FailGetProto: FailGetProto:
@ -244,22 +252,15 @@ FailSwAcc:
SwAttempt: SwAttempt:
USBTRACE("\r\nAccessory mode switch attempt"); USBTRACE("\r\nAccessory mode switch attempt");
goto Fail; // goto Fail;
FailGetConfDescr: //FailOnInit:
// USBTRACE("getConf:");
goto Fail;
//
FailSetConf:
// USBTRACE("setConf:");
goto Fail;
//
//FailOnInit:
// USBTRACE("OnInit:"); // USBTRACE("OnInit:");
// goto Fail; // goto Fail;
// //
Fail: Fail:
//USBTRACE2("\r\nADK Init Failed, error code: ", rcode); //USBTRACE2("\r\nADK Init Failed, error code: ", rcode);
//NotifyFail(rcode);
Release(); Release();
return rcode; return rcode;
} }

View file

@ -165,7 +165,7 @@ uint8_t ACM::Init(uint8_t parent, uint8_t port, bool lowspeed) {
rcode = pUsb->setConf(bAddress, 0, bConfNum); rcode = pUsb->setConf(bAddress, 0, bConfNum);
if (rcode) if (rcode)
goto FailSetConf; goto FailSetConfDescr;
rcode = pAsync->OnInit(this); rcode = pAsync->OnInit(this);
@ -180,29 +180,26 @@ uint8_t ACM::Init(uint8_t parent, uint8_t port, bool lowspeed) {
return 0; return 0;
FailGetDevDescr: FailGetDevDescr:
USBTRACE("getDevDescr:"); NotifyFailGetDevDescr();
goto Fail; goto Fail;
FailSetDevTblEntry: FailSetDevTblEntry:
USBTRACE("setDevTblEn:"); NotifyFailSetDevTblEntry();
goto Fail; goto Fail;
FailGetConfDescr: FailGetConfDescr:
USBTRACE("getConf:"); NotifyFailGetConfDescr();
goto Fail; goto Fail;
FailSetConf: FailSetConfDescr:
USBTRACE("setConf:"); NotifyFailSetConfDescr();
goto Fail; goto Fail;
FailOnInit: FailOnInit:
USBTRACE("OnInit:"); USBTRACE("OnInit:");
goto Fail;
Fail: Fail:
PrintHex<uint8_t > (rcode, 0x80); NotifyFail(rcode);
Notify(PSTR("\r\n"), 0x80);
// Serial.println(rcode, HEX);
Release(); Release();
return rcode; return rcode;
} }

View file

@ -178,29 +178,26 @@ uint8_t FTDI::Init(uint8_t parent, uint8_t port, bool lowspeed) {
return 0; return 0;
FailGetDevDescr: FailGetDevDescr:
USBTRACE("getDevDescr:"); NotifyFailGetDevDescr();
goto Fail; goto Fail;
FailSetDevTblEntry: FailSetDevTblEntry:
USBTRACE("setDevTblEn:"); NotifyFailSetDevTblEntry();
goto Fail; goto Fail;
FailGetConfDescr: FailGetConfDescr:
USBTRACE("getConf:"); NotifyFailGetConfDescr();
goto Fail; goto Fail;
FailSetConfDescr: FailSetConfDescr:
USBTRACE("setConf:"); NotifyFailSetConfDescr();
goto Fail; goto Fail;
FailOnInit: FailOnInit:
USBTRACE("OnInit:"); USBTRACE("OnInit:");
goto Fail;
Fail: Fail:
PrintHex<uint8_t > (rcode, 0x80); NotifyFail(rcode);
Notify(PSTR("\r\n"), 0x80);
//Serial.println(rcode, HEX);
Release(); Release();
return rcode; return rcode;
} }

View file

@ -155,29 +155,26 @@ uint8_t PL2303::Init(uint8_t parent, uint8_t port, bool lowspeed) {
return 0; return 0;
FailGetDevDescr: FailGetDevDescr:
USBTRACE("getDevDescr:"); NotifyFailGetDevDescr();
goto Fail; goto Fail;
FailSetDevTblEntry: FailSetDevTblEntry:
USBTRACE("setDevTblEn:"); NotifyFailSetDevTblEntry();
goto Fail; goto Fail;
FailGetConfDescr: FailGetConfDescr:
USBTRACE("getConf:"); NotifyFailGetConfDescr();
goto Fail; goto Fail;
FailSetConfDescr: FailSetConfDescr:
USBTRACE("setConf:"); NotifyFailSetConfDescr();
goto Fail; goto Fail;
FailOnInit: FailOnInit:
USBTRACE("OnInit:"); USBTRACE("OnInit:");
goto Fail;
Fail: Fail:
PrintHex<uint8_t > (rcode, 0x80); NotifyFail(rcode);
Notify(PSTR("\r\n"), 0x80);
//Serial.println(rcode, HEX);
Release(); Release();
return rcode; return rcode;
} }

View file

@ -20,8 +20,6 @@ e-mail : support@circuitsathome.com
#include <inttypes.h> #include <inttypes.h>
#include <avr/pgmspace.h> #include <avr/pgmspace.h>
#include "printhex.h"
#include "hexdump.h"
#include "message.h" #include "message.h"
#include "parsetools.h" #include "parsetools.h"

View file

@ -19,7 +19,6 @@ e-mail : support@circuitsathome.com
#include <inttypes.h> #include <inttypes.h>
#include <avr/pgmspace.h> #include <avr/pgmspace.h>
#include "printhex.h"
template <class BASE_CLASS, class LEN_TYPE, class OFFSET_TYPE> template <class BASE_CLASS, class LEN_TYPE, class OFFSET_TYPE>
class HexDumper : public BASE_CLASS { class HexDumper : public BASE_CLASS {
@ -41,19 +40,23 @@ public:
template <class BASE_CLASS, class LEN_TYPE, class OFFSET_TYPE> template <class BASE_CLASS, class LEN_TYPE, class OFFSET_TYPE>
void HexDumper<BASE_CLASS, LEN_TYPE, OFFSET_TYPE>::Parse(const LEN_TYPE len, const uint8_t *pbuf, const OFFSET_TYPE &offset) { void HexDumper<BASE_CLASS, LEN_TYPE, OFFSET_TYPE>::Parse(const LEN_TYPE len, const uint8_t *pbuf, const OFFSET_TYPE &offset) {
for(LEN_TYPE j = 0; j < len; j++, byteCount++, byteTotal++) { #ifdef DEBUG
if(!byteCount) { if(UsbDEBUGlvl >= 0x80) { // Fully bypass this block of code if we do not debug.
SerialPrintHex<OFFSET_TYPE > (byteTotal); for(LEN_TYPE j = 0; j < len; j++, byteCount++, byteTotal++) {
Serial.print(": "); if(!byteCount) {
} PrintHex<OFFSET_TYPE > (byteTotal, 0x80);
SerialPrintHex<uint8_t > (pbuf[j]); Notify(PSTR(": "), 0x80);
Serial.print(" "); }
PrintHex<uint8_t > (pbuf[j], 0x80);
Notify(PSTR(" "), 0x80);
if(byteCount == 15) { if(byteCount == 15) {
Serial.println(""); Notify(PSTR("\r\n"), 0x80);
byteCount = 0xFF; byteCount = 0xFF;
}
} }
} }
#endif
} }
#endif // __HEXDUMP_H__ #endif // __HEXDUMP_H__

View file

@ -390,17 +390,22 @@ uint8_t HIDBoot<BOOT_PROTOCOL>::Init(uint8_t parent, uint8_t port, bool lowspeed
return 0; return 0;
FailGetDevDescr: FailGetDevDescr:
USBTRACE("getDevDescr:"); NotifyFailGetDevDescr();
goto Fail; goto Fail;
FailSetDevTblEntry: FailSetDevTblEntry:
USBTRACE("setDevTblEn:"); NotifyFailSetDevTblEntry();
goto Fail; goto Fail;
FailGetConfDescr: FailGetConfDescr:
USBTRACE("getConf:"); NotifyFailGetConfDescr();
goto Fail; goto Fail;
FailSetConfDescr:
NotifyFailSetConfDescr();
goto Fail;
FailSetProtocol: FailSetProtocol:
USBTRACE("SetProto:"); USBTRACE("SetProto:");
goto Fail; goto Fail;
@ -409,14 +414,8 @@ FailSetIdle:
USBTRACE("SetIdle:"); USBTRACE("SetIdle:");
goto Fail; goto Fail;
FailSetConfDescr:
USBTRACE("setConf:");
goto Fail;
Fail: Fail:
PrintHex<uint8_t > (rcode, 0x80); NotifyFail(rcode);
Notify(PSTR("\n"), 0x80);
// Serial.println(rcode, HEX);
Release(); Release();
return rcode; return rcode;
} }

View file

@ -1623,4 +1623,4 @@ void UniversalReportParser::Parse(HID *hid, bool is_rpt_id, uint8_t len, uint8_t
if (ret) if (ret)
ErrorMessage<uint8_t > (PSTR("GetReportDescr-2"), ret); ErrorMessage<uint8_t > (PSTR("GetReportDescr-2"), ret);
} }

View file

@ -221,29 +221,27 @@ uint8_t HIDUniversal::Init(uint8_t parent, uint8_t port, bool lowspeed) {
return 0; return 0;
FailGetDevDescr: FailGetDevDescr:
USBTRACE("getDevDescr:"); NotifyFailGetDevDescr();
goto Fail; goto Fail;
FailSetDevTblEntry: FailSetDevTblEntry:
USBTRACE("setDevTblEn:"); NotifyFailSetDevTblEntry();
goto Fail; goto Fail;
FailGetConfDescr: FailGetConfDescr:
USBTRACE("getConf:"); NotifyFailGetConfDescr();
goto Fail; goto Fail;
FailSetConfDescr: FailSetConfDescr:
USBTRACE("setConf:"); NotifyFailSetConfDescr();
goto Fail; goto Fail;
FailSetIdle: FailSetIdle:
USBTRACE("SetIdle:"); USBTRACE("SetIdle:");
goto Fail;
Fail: Fail:
PrintHex<uint8_t > (rcode, 0x80); NotifyFail(rcode);
Notify(PSTR("\r\n"), 0x80);
//Serial.println(rcode, HEX);
Release(); Release();
return rcode; return rcode;
} }

View file

@ -238,6 +238,7 @@ getPitch KEYWORD2
getRoll KEYWORD2 getRoll KEYWORD2
getYaw KEYWORD2 getYaw KEYWORD2
PAIR KEYWORD2 PAIR KEYWORD2
statusRequest KEYWORD2
getBatteryLevel KEYWORD2 getBatteryLevel KEYWORD2
getWiiState KEYWORD2 getWiiState KEYWORD2

View file

@ -1,4 +1,5 @@
#include "masstorage.h" #include "masstorage.h"
const uint8_t BulkOnly::epDataInIndex = 1; const uint8_t BulkOnly::epDataInIndex = 1;
const uint8_t BulkOnly::epDataOutIndex = 2; const uint8_t BulkOnly::epDataOutIndex = 2;
const uint8_t BulkOnly::epInterruptInIndex = 3; const uint8_t BulkOnly::epInterruptInIndex = 3;
@ -160,7 +161,7 @@ uint8_t BulkOnly::Init(uint8_t parent, uint8_t port, bool lowspeed) {
rcode = pUsb->setConf(bAddress, 0, bConfNum); rcode = pUsb->setConf(bAddress, 0, bConfNum);
if (rcode) if (rcode)
goto FailSetConf; goto FailSetConfDescr;
delay(10000); delay(10000);
@ -280,19 +281,19 @@ uint8_t BulkOnly::Init(uint8_t parent, uint8_t port, bool lowspeed) {
return 0; return 0;
FailGetDevDescr: FailGetDevDescr:
USBTRACE("getDevDescr:"); NotifyFailGetDevDescr();
goto Fail; goto Fail;
FailSetDevTblEntry: FailSetDevTblEntry:
USBTRACE("setDevTblEn:"); NotifyFailSetDevTblEntry();
goto Fail; goto Fail;
FailGetConfDescr: FailGetConfDescr:
USBTRACE("getConf:"); NotifyFailGetConfDescr();
goto Fail; goto Fail;
FailSetConf: FailSetConfDescr:
USBTRACE("setConf:"); NotifyFailSetConfDescr();
goto Fail; goto Fail;
FailOnInit: FailOnInit:
@ -325,12 +326,9 @@ FailModeSense0:
FailModeSense1: FailModeSense1:
USBTRACE("ModeSense1:"); USBTRACE("ModeSense1:");
goto Fail;
Fail: Fail:
PrintHex<uint8_t > (rcode, 0x80); NotifyFail(rcode);
Notify(PSTR("\r\n"), 0x80);
//Serial.println(rcode, HEX);
Release(); Release();
return rcode; return rcode;
} }

View file

@ -1,6 +1,8 @@
#if !defined(__MASSTORAGE_H__) #if !defined(__MASSTORAGE_H__)
#define __MASSTORAGE_H__ #define __MASSTORAGE_H__
#define DEBUG
#include <inttypes.h> #include <inttypes.h>
#include "avrpins.h" #include "avrpins.h"
#include <avr/pgmspace.h> #include <avr/pgmspace.h>
@ -15,10 +17,6 @@
#include <WProgram.h> #include <WProgram.h>
#endif #endif
#include "printhex.h"
#include "hexdump.h"
#include "message.h"
#include <confdescparser.h> #include <confdescparser.h>
#define SWAP(a, b) (((a) ^= (b)), ((b) ^= (a)), ((a) ^= (b))) #define SWAP(a, b) (((a) ^= (b)), ((b) ^= (a)), ((a) ^= (b)))

View file

@ -14,6 +14,8 @@ Circuits At Home, LTD
Web : http://www.circuitsathome.com Web : http://www.circuitsathome.com
e-mail : support@circuitsathome.com e-mail : support@circuitsathome.com
*/ */
#define DEBUG
#include "message.h" #include "message.h"
// 0x80 is the default (i.e. trace) to turn off set this global to something lower. // 0x80 is the default (i.e. trace) to turn off set this global to something lower.
// this allows for 126 other debugging levels. // this allows for 126 other debugging levels.
@ -45,3 +47,30 @@ void NotifyStr(char const * msg, int lvl) {
while (c = *msg++) Notifyc(c, lvl); while (c = *msg++) Notifyc(c, lvl);
} }
void NotifyFailGetDevDescr(void) {
Notify(PSTR("\r\ngetDevDescr"), 0x80);
}
void NotifyFailSetDevTblEntry(void) {
Notify(PSTR("\r\nsetDevTblEn"), 0x80);
}
void NotifyFailGetConfDescr(void) {
Notify(PSTR("\r\ngetConf"), 0x80);
}
void NotifyFailSetConfDescr(void) {
Notify(PSTR("\r\nsetConf"), 0x80);
}
void NotifyFailUnknownDevice(uint16_t VID, uint16_t PID) {
Notify(PSTR("\r\nUnknown Device Connected - VID: "), 0x80);
PrintHex<uint16_t > (VID, 0x80);
Notify(PSTR(" PID: "), 0x80);
PrintHex<uint16_t > (PID, 0x80);
}
void NotifyFail(uint8_t rcode) {
PrintHex<uint8_t > (rcode, 0x80);
Notify(PSTR("\r\n"), 0x80);
}

View file

@ -20,12 +20,27 @@ e-mail : support@circuitsathome.com
#include <inttypes.h> #include <inttypes.h>
#include <avr/pgmspace.h> #include <avr/pgmspace.h>
void Notify(char const * msg, int lvl); extern int UsbDEBUGlvl;
void NotifyStr(char const * msg, int lvl);
#include "printhex.h" #include "printhex.h"
//void Notify(const char* msg); void Notify(char const * msg, int lvl);
void NotifyStr(char const * msg, int lvl);
#ifdef DEBUG
void NotifyFailGetDevDescr(void);
void NotifyFailSetDevTblEntry(void);
void NotifyFailGetConfDescr(void);
void NotifyFailSetConfDescr(void);
void NotifyFailUnknownDevice(uint16_t VID, uint16_t PID);
void NotifyFail(uint8_t rcode);
#else
#define NotifyFailGetDevDescr()
#define NotifyFailSetDevTblEntry()
#define NotifyFailGetConfDescr()
#define NotifyFailSetConfDescr()
#define NotifyFailUnknownDevice(VID, PID)
#define NotifyFail(rcode)
#endif
template <class ERROR_TYPE> template <class ERROR_TYPE>
void ErrorMessage(char const * msg, ERROR_TYPE rcode = 0) { void ErrorMessage(char const * msg, ERROR_TYPE rcode = 0) {
@ -35,5 +50,6 @@ void ErrorMessage(char const * msg, ERROR_TYPE rcode = 0) {
Notify(PSTR("\r\n"), 0x80); Notify(PSTR("\r\n"), 0x80);
} }
#include "hexdump.h"
#endif // __MESSAGE_H__ #endif // __MESSAGE_H__

View file

@ -185,6 +185,7 @@ uint8_t USBHub::Init(uint8_t parent, uint8_t port, bool lowspeed) {
bInitState = 0; bInitState = 0;
return 0; return 0;
// Oleg, No debugging?? -- xxxajk
FailGetDevDescr: FailGetDevDescr:
goto Fail; goto Fail;