mirror of
https://github.com/felis/USB_Host_Shield_2.0.git
synced 2024-03-22 11:31:26 +01:00
fix all warnings for ARM, fix a few small bugs
This commit is contained in:
parent
8715cbde67
commit
e18eb57752
25 changed files with 456 additions and 333 deletions
11
BTD.cpp
11
BTD.cpp
|
@ -46,6 +46,7 @@ bPollEnable(false) // Don't start polling before dongle is connected
|
||||||
uint8_t BTD::ConfigureDevice(uint8_t parent, uint8_t port, bool lowspeed) {
|
uint8_t BTD::ConfigureDevice(uint8_t parent, uint8_t port, bool lowspeed) {
|
||||||
const uint8_t constBufSize = sizeof (USB_DEVICE_DESCRIPTOR);
|
const uint8_t constBufSize = sizeof (USB_DEVICE_DESCRIPTOR);
|
||||||
uint8_t buf[constBufSize];
|
uint8_t buf[constBufSize];
|
||||||
|
USB_DEVICE_DESCRIPTOR * udd = reinterpret_cast<USB_DEVICE_DESCRIPTOR*>(buf);
|
||||||
uint8_t rcode;
|
uint8_t rcode;
|
||||||
UsbDevice *p = NULL;
|
UsbDevice *p = NULL;
|
||||||
EpInfo *oldep_ptr = NULL;
|
EpInfo *oldep_ptr = NULL;
|
||||||
|
@ -98,11 +99,11 @@ uint8_t BTD::ConfigureDevice(uint8_t parent, uint8_t port, bool lowspeed) {
|
||||||
return USB_ERROR_OUT_OF_ADDRESS_SPACE_IN_POOL;
|
return USB_ERROR_OUT_OF_ADDRESS_SPACE_IN_POOL;
|
||||||
}
|
}
|
||||||
|
|
||||||
epInfo[0].maxPktSize = (uint8_t)((USB_DEVICE_DESCRIPTOR*)buf)->bMaxPacketSize0; // Extract Max Packet Size from device descriptor
|
epInfo[0].maxPktSize = udd->bMaxPacketSize0; // Extract Max Packet Size from device descriptor
|
||||||
epInfo[1].epAddr = ((USB_DEVICE_DESCRIPTOR*)buf)->bNumConfigurations; // Steal and abuse from epInfo structure to save memory
|
epInfo[1].epAddr = udd->bNumConfigurations; // Steal and abuse from epInfo structure to save memory
|
||||||
|
|
||||||
VID = ((USB_DEVICE_DESCRIPTOR*)buf)->idVendor;
|
VID = udd->idVendor;
|
||||||
PID = ((USB_DEVICE_DESCRIPTOR*)buf)->idProduct;
|
PID = udd->idProduct;
|
||||||
|
|
||||||
return USB_ERROR_CONFIG_REQUIRES_ADDITIONAL_RESET;
|
return USB_ERROR_CONFIG_REQUIRES_ADDITIONAL_RESET;
|
||||||
|
|
||||||
|
@ -249,8 +250,8 @@ uint8_t BTD::Init(uint8_t parent, uint8_t port, bool lowspeed) {
|
||||||
return 0; // Successful configuration
|
return 0; // Successful configuration
|
||||||
|
|
||||||
/* diagnostic messages */
|
/* diagnostic messages */
|
||||||
FailGetDevDescr:
|
|
||||||
#ifdef DEBUG_USB_HOST
|
#ifdef DEBUG_USB_HOST
|
||||||
|
FailGetDevDescr:
|
||||||
NotifyFailGetDevDescr();
|
NotifyFailGetDevDescr();
|
||||||
goto Fail;
|
goto Fail;
|
||||||
#endif
|
#endif
|
||||||
|
|
4
BTD.h
4
BTD.h
|
@ -468,13 +468,13 @@ private:
|
||||||
|
|
||||||
uint16_t PID, VID; // PID and VID of device connected
|
uint16_t PID, VID; // PID and VID of device connected
|
||||||
|
|
||||||
bool bPollEnable;
|
|
||||||
uint8_t pollInterval;
|
uint8_t pollInterval;
|
||||||
|
bool bPollEnable;
|
||||||
|
|
||||||
/* Variables used by high level HCI task */
|
/* Variables used by high level HCI task */
|
||||||
uint8_t hci_state; //current state of bluetooth hci connection
|
uint8_t hci_state; //current state of bluetooth hci connection
|
||||||
uint16_t hci_counter; // counter used for bluetooth hci reset loops
|
uint16_t hci_counter; // counter used for bluetooth hci reset loops
|
||||||
uint8_t hci_num_reset_loops; // this value indicate how many times it should read before trying to reset
|
uint16_t hci_num_reset_loops; // this value indicate how many times it should read before trying to reset
|
||||||
uint16_t hci_event_flag; // hci flags of received bluetooth events
|
uint16_t hci_event_flag; // hci flags of received bluetooth events
|
||||||
uint8_t inquiry_counter;
|
uint8_t inquiry_counter;
|
||||||
|
|
||||||
|
|
20
PS3USB.cpp
20
PS3USB.cpp
|
@ -45,6 +45,7 @@ bPollEnable(false) // don't start polling before dongle is connected
|
||||||
|
|
||||||
uint8_t PS3USB::Init(uint8_t parent, uint8_t port, bool lowspeed) {
|
uint8_t PS3USB::Init(uint8_t parent, uint8_t port, bool lowspeed) {
|
||||||
uint8_t buf[sizeof (USB_DEVICE_DESCRIPTOR)];
|
uint8_t buf[sizeof (USB_DEVICE_DESCRIPTOR)];
|
||||||
|
USB_DEVICE_DESCRIPTOR * udd = reinterpret_cast<USB_DEVICE_DESCRIPTOR*>(buf);
|
||||||
uint8_t rcode;
|
uint8_t rcode;
|
||||||
UsbDevice *p = NULL;
|
UsbDevice *p = NULL;
|
||||||
EpInfo *oldep_ptr = NULL;
|
EpInfo *oldep_ptr = NULL;
|
||||||
|
@ -97,8 +98,8 @@ uint8_t PS3USB::Init(uint8_t parent, uint8_t port, bool lowspeed) {
|
||||||
if (rcode)
|
if (rcode)
|
||||||
goto FailGetDevDescr;
|
goto FailGetDevDescr;
|
||||||
|
|
||||||
VID = ((USB_DEVICE_DESCRIPTOR*)buf)->idVendor;
|
VID = udd->idVendor;
|
||||||
PID = ((USB_DEVICE_DESCRIPTOR*)buf)->idProduct;
|
PID = udd->idProduct;
|
||||||
|
|
||||||
if (VID != PS3_VID || (PID != PS3_PID && PID != PS3NAVIGATION_PID && PID != PS3MOVE_PID))
|
if (VID != PS3_VID || (PID != PS3_PID && PID != PS3NAVIGATION_PID && PID != PS3MOVE_PID))
|
||||||
goto FailUnknownDevice;
|
goto FailUnknownDevice;
|
||||||
|
@ -110,7 +111,7 @@ uint8_t PS3USB::Init(uint8_t parent, uint8_t port, bool lowspeed) {
|
||||||
return USB_ERROR_OUT_OF_ADDRESS_SPACE_IN_POOL;
|
return USB_ERROR_OUT_OF_ADDRESS_SPACE_IN_POOL;
|
||||||
|
|
||||||
// Extract Max Packet Size from device descriptor
|
// Extract Max Packet Size from device descriptor
|
||||||
epInfo[0].maxPktSize = (uint8_t)((USB_DEVICE_DESCRIPTOR*)buf)->bMaxPacketSize0;
|
epInfo[0].maxPktSize = udd->bMaxPacketSize0;
|
||||||
|
|
||||||
// Assign new address to the device
|
// Assign new address to the device
|
||||||
rcode = pUsb->setAddr(0, 0, bAddress);
|
rcode = pUsb->setAddr(0, 0, bAddress);
|
||||||
|
@ -154,14 +155,14 @@ uint8_t PS3USB::Init(uint8_t parent, uint8_t port, bool lowspeed) {
|
||||||
epInfo[ PS3_OUTPUT_PIPE ].epAttribs = EP_INTERRUPT;
|
epInfo[ PS3_OUTPUT_PIPE ].epAttribs = EP_INTERRUPT;
|
||||||
epInfo[ PS3_OUTPUT_PIPE ].bmNakPower = USB_NAK_NOWAIT; // Only poll once for interrupt endpoints
|
epInfo[ PS3_OUTPUT_PIPE ].bmNakPower = USB_NAK_NOWAIT; // Only poll once for interrupt endpoints
|
||||||
epInfo[ PS3_OUTPUT_PIPE ].maxPktSize = EP_MAXPKTSIZE;
|
epInfo[ PS3_OUTPUT_PIPE ].maxPktSize = EP_MAXPKTSIZE;
|
||||||
epInfo[ PS3_OUTPUT_PIPE ].bmSndToggle = bmSNDTOG0;
|
epInfo[ PS3_OUTPUT_PIPE ].bmSndToggle = 0;
|
||||||
epInfo[ PS3_OUTPUT_PIPE ].bmRcvToggle = bmRCVTOG0;
|
epInfo[ PS3_OUTPUT_PIPE ].bmRcvToggle = 0;
|
||||||
epInfo[ PS3_INPUT_PIPE ].epAddr = 0x01; // PS3 report endpoint
|
epInfo[ PS3_INPUT_PIPE ].epAddr = 0x01; // PS3 report endpoint
|
||||||
epInfo[ PS3_INPUT_PIPE ].epAttribs = EP_INTERRUPT;
|
epInfo[ PS3_INPUT_PIPE ].epAttribs = EP_INTERRUPT;
|
||||||
epInfo[ PS3_INPUT_PIPE ].bmNakPower = USB_NAK_NOWAIT; // Only poll once for interrupt endpoints
|
epInfo[ PS3_INPUT_PIPE ].bmNakPower = USB_NAK_NOWAIT; // Only poll once for interrupt endpoints
|
||||||
epInfo[ PS3_INPUT_PIPE ].maxPktSize = EP_MAXPKTSIZE;
|
epInfo[ PS3_INPUT_PIPE ].maxPktSize = EP_MAXPKTSIZE;
|
||||||
epInfo[ PS3_INPUT_PIPE ].bmSndToggle = bmSNDTOG0;
|
epInfo[ PS3_INPUT_PIPE ].bmSndToggle = 0;
|
||||||
epInfo[ PS3_INPUT_PIPE ].bmRcvToggle = bmRCVTOG0;
|
epInfo[ PS3_INPUT_PIPE ].bmRcvToggle = 0;
|
||||||
|
|
||||||
rcode = pUsb->setEpInfoEntry(bAddress, 3, epInfo);
|
rcode = pUsb->setEpInfoEntry(bAddress, 3, epInfo);
|
||||||
if (rcode)
|
if (rcode)
|
||||||
|
@ -237,16 +238,17 @@ FailSetDevTblEntry:
|
||||||
FailSetConfDescr:
|
FailSetConfDescr:
|
||||||
#ifdef DEBUG_USB_HOST
|
#ifdef DEBUG_USB_HOST
|
||||||
NotifyFailSetConfDescr();
|
NotifyFailSetConfDescr();
|
||||||
#endif
|
|
||||||
goto Fail;
|
goto Fail;
|
||||||
|
#endif
|
||||||
|
|
||||||
FailUnknownDevice:
|
FailUnknownDevice:
|
||||||
#ifdef DEBUG_USB_HOST
|
#ifdef DEBUG_USB_HOST
|
||||||
NotifyFailUnknownDevice(VID, PID);
|
NotifyFailUnknownDevice(VID, PID);
|
||||||
#endif
|
#endif
|
||||||
rcode = USB_DEV_CONFIG_ERROR_DEVICE_NOT_SUPPORTED;
|
rcode = USB_DEV_CONFIG_ERROR_DEVICE_NOT_SUPPORTED;
|
||||||
Fail:
|
|
||||||
|
|
||||||
#ifdef DEBUG_USB_HOST
|
#ifdef DEBUG_USB_HOST
|
||||||
|
Fail:
|
||||||
Notify(PSTR("\r\nPS3 Init Failed, error code: "), 0x80);
|
Notify(PSTR("\r\nPS3 Init Failed, error code: "), 0x80);
|
||||||
NotifyFail(rcode);
|
NotifyFail(rcode);
|
||||||
#endif
|
#endif
|
||||||
|
|
11
Usb.cpp
11
Usb.cpp
|
@ -650,6 +650,7 @@ uint8_t USB::Configuring(uint8_t parent, uint8_t port, bool lowspeed) {
|
||||||
uint8_t devConfigIndex;
|
uint8_t devConfigIndex;
|
||||||
uint8_t rcode = 0;
|
uint8_t rcode = 0;
|
||||||
uint8_t buf[sizeof (USB_DEVICE_DESCRIPTOR)];
|
uint8_t buf[sizeof (USB_DEVICE_DESCRIPTOR)];
|
||||||
|
USB_DEVICE_DESCRIPTOR *udd = reinterpret_cast<USB_DEVICE_DESCRIPTOR *>(buf);
|
||||||
UsbDevice *p = NULL;
|
UsbDevice *p = NULL;
|
||||||
EpInfo *oldep_ptr = NULL;
|
EpInfo *oldep_ptr = NULL;
|
||||||
EpInfo epInfo;
|
EpInfo epInfo;
|
||||||
|
@ -694,10 +695,9 @@ uint8_t USB::Configuring(uint8_t parent, uint8_t port, bool lowspeed) {
|
||||||
|
|
||||||
//if (!bAddress)
|
//if (!bAddress)
|
||||||
// return USB_ERROR_OUT_OF_ADDRESS_SPACE_IN_POOL;
|
// return USB_ERROR_OUT_OF_ADDRESS_SPACE_IN_POOL;
|
||||||
|
uint16_t vid = udd->idVendor;
|
||||||
uint16_t vid = (uint16_t)((USB_DEVICE_DESCRIPTOR*)buf)->idVendor;
|
uint16_t pid = udd->idProduct;
|
||||||
uint16_t pid = (uint16_t)((USB_DEVICE_DESCRIPTOR*)buf)->idProduct;
|
uint8_t klass = udd->bDeviceClass;
|
||||||
uint8_t klass = ((USB_DEVICE_DESCRIPTOR*)buf)->bDeviceClass;
|
|
||||||
|
|
||||||
// Attempt to configure if VID/PID or device class matches with a driver
|
// Attempt to configure if VID/PID or device class matches with a driver
|
||||||
for (devConfigIndex = 0; devConfigIndex < USB_NUMDEVICES; devConfigIndex++) {
|
for (devConfigIndex = 0; devConfigIndex < USB_NUMDEVICES; devConfigIndex++) {
|
||||||
|
@ -767,13 +767,14 @@ uint8_t USB::getConfDescr(uint8_t addr, uint8_t ep, uint16_t nbytes, uint8_t con
|
||||||
uint8_t USB::getConfDescr(uint8_t addr, uint8_t ep, uint8_t conf, USBReadParser *p) {
|
uint8_t USB::getConfDescr(uint8_t addr, uint8_t ep, uint8_t conf, USBReadParser *p) {
|
||||||
const uint8_t bufSize = 64;
|
const uint8_t bufSize = 64;
|
||||||
uint8_t buf[bufSize];
|
uint8_t buf[bufSize];
|
||||||
|
USB_CONFIGURATION_DESCRIPTOR *ucd = reinterpret_cast<USB_CONFIGURATION_DESCRIPTOR *>(buf);
|
||||||
|
|
||||||
uint8_t ret = getConfDescr(addr, ep, 9, conf, buf);
|
uint8_t ret = getConfDescr(addr, ep, 9, conf, buf);
|
||||||
|
|
||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
uint16_t total = ((USB_CONFIGURATION_DESCRIPTOR*)buf)->wTotalLength;
|
uint16_t total = ucd->wTotalLength;
|
||||||
|
|
||||||
//USBTRACE2("\r\ntotal conf.size:", total);
|
//USBTRACE2("\r\ntotal conf.size:", total);
|
||||||
|
|
||||||
|
|
17
XBOXOLD.cpp
17
XBOXOLD.cpp
|
@ -61,6 +61,7 @@ bPollEnable(false) { // don't start polling before dongle is connected
|
||||||
|
|
||||||
uint8_t XBOXOLD::Init(uint8_t parent, uint8_t port, bool lowspeed) {
|
uint8_t XBOXOLD::Init(uint8_t parent, uint8_t port, bool lowspeed) {
|
||||||
uint8_t buf[sizeof (USB_DEVICE_DESCRIPTOR)];
|
uint8_t buf[sizeof (USB_DEVICE_DESCRIPTOR)];
|
||||||
|
USB_DEVICE_DESCRIPTOR * udd = reinterpret_cast<USB_DEVICE_DESCRIPTOR*>(buf);
|
||||||
uint8_t rcode;
|
uint8_t rcode;
|
||||||
UsbDevice *p = NULL;
|
UsbDevice *p = NULL;
|
||||||
EpInfo *oldep_ptr = NULL;
|
EpInfo *oldep_ptr = NULL;
|
||||||
|
@ -113,8 +114,8 @@ uint8_t XBOXOLD::Init(uint8_t parent, uint8_t port, bool lowspeed) {
|
||||||
if (rcode)
|
if (rcode)
|
||||||
goto FailGetDevDescr;
|
goto FailGetDevDescr;
|
||||||
|
|
||||||
VID = ((USB_DEVICE_DESCRIPTOR*)buf)->idVendor;
|
VID = udd->idVendor;
|
||||||
PID = ((USB_DEVICE_DESCRIPTOR*)buf)->idProduct;
|
PID = udd->idProduct;
|
||||||
|
|
||||||
if ((VID != XBOX_VID && VID != MADCATZ_VID && VID != JOYTECH_VID) || (PID != XBOX_OLD_PID1 && PID != XBOX_OLD_PID2 && PID != XBOX_OLD_PID3 && PID != XBOX_OLD_PID4)) // Check if VID and PID match
|
if ((VID != XBOX_VID && VID != MADCATZ_VID && VID != JOYTECH_VID) || (PID != XBOX_OLD_PID1 && PID != XBOX_OLD_PID2 && PID != XBOX_OLD_PID3 && PID != XBOX_OLD_PID4)) // Check if VID and PID match
|
||||||
goto FailUnknownDevice;
|
goto FailUnknownDevice;
|
||||||
|
@ -126,7 +127,7 @@ uint8_t XBOXOLD::Init(uint8_t parent, uint8_t port, bool lowspeed) {
|
||||||
return USB_ERROR_OUT_OF_ADDRESS_SPACE_IN_POOL;
|
return USB_ERROR_OUT_OF_ADDRESS_SPACE_IN_POOL;
|
||||||
|
|
||||||
// Extract Max Packet Size from device descriptor
|
// Extract Max Packet Size from device descriptor
|
||||||
epInfo[0].maxPktSize = (uint8_t)((USB_DEVICE_DESCRIPTOR*)buf)->bMaxPacketSize0;
|
epInfo[0].maxPktSize = udd->bMaxPacketSize0;
|
||||||
|
|
||||||
// Assign new address to the device
|
// Assign new address to the device
|
||||||
rcode = pUsb->setAddr(0, 0, bAddress);
|
rcode = pUsb->setAddr(0, 0, bAddress);
|
||||||
|
@ -169,14 +170,14 @@ uint8_t XBOXOLD::Init(uint8_t parent, uint8_t port, bool lowspeed) {
|
||||||
epInfo[ XBOX_INPUT_PIPE ].epAttribs = EP_INTERRUPT;
|
epInfo[ XBOX_INPUT_PIPE ].epAttribs = EP_INTERRUPT;
|
||||||
epInfo[ XBOX_INPUT_PIPE ].bmNakPower = USB_NAK_NOWAIT; // Only poll once for interrupt endpoints
|
epInfo[ XBOX_INPUT_PIPE ].bmNakPower = USB_NAK_NOWAIT; // Only poll once for interrupt endpoints
|
||||||
epInfo[ XBOX_INPUT_PIPE ].maxPktSize = EP_MAXPKTSIZE;
|
epInfo[ XBOX_INPUT_PIPE ].maxPktSize = EP_MAXPKTSIZE;
|
||||||
epInfo[ XBOX_INPUT_PIPE ].bmSndToggle = bmSNDTOG0;
|
epInfo[ XBOX_INPUT_PIPE ].bmSndToggle = 0;
|
||||||
epInfo[ XBOX_INPUT_PIPE ].bmRcvToggle = bmRCVTOG0;
|
epInfo[ XBOX_INPUT_PIPE ].bmRcvToggle = 0;
|
||||||
epInfo[ XBOX_OUTPUT_PIPE ].epAddr = 0x02; // XBOX output endpoint
|
epInfo[ XBOX_OUTPUT_PIPE ].epAddr = 0x02; // XBOX output endpoint
|
||||||
epInfo[ XBOX_OUTPUT_PIPE ].epAttribs = EP_INTERRUPT;
|
epInfo[ XBOX_OUTPUT_PIPE ].epAttribs = EP_INTERRUPT;
|
||||||
epInfo[ XBOX_OUTPUT_PIPE ].bmNakPower = USB_NAK_NOWAIT; // Only poll once for interrupt endpoints
|
epInfo[ XBOX_OUTPUT_PIPE ].bmNakPower = USB_NAK_NOWAIT; // Only poll once for interrupt endpoints
|
||||||
epInfo[ XBOX_OUTPUT_PIPE ].maxPktSize = EP_MAXPKTSIZE;
|
epInfo[ XBOX_OUTPUT_PIPE ].maxPktSize = EP_MAXPKTSIZE;
|
||||||
epInfo[ XBOX_OUTPUT_PIPE ].bmSndToggle = bmSNDTOG0;
|
epInfo[ XBOX_OUTPUT_PIPE ].bmSndToggle = 0;
|
||||||
epInfo[ XBOX_OUTPUT_PIPE ].bmRcvToggle = bmRCVTOG0;
|
epInfo[ XBOX_OUTPUT_PIPE ].bmRcvToggle = 0;
|
||||||
|
|
||||||
rcode = pUsb->setEpInfoEntry(bAddress, 3, epInfo);
|
rcode = pUsb->setEpInfoEntry(bAddress, 3, epInfo);
|
||||||
if (rcode)
|
if (rcode)
|
||||||
|
@ -221,8 +222,8 @@ FailUnknownDevice:
|
||||||
#endif
|
#endif
|
||||||
rcode = USB_DEV_CONFIG_ERROR_DEVICE_NOT_SUPPORTED;
|
rcode = USB_DEV_CONFIG_ERROR_DEVICE_NOT_SUPPORTED;
|
||||||
|
|
||||||
Fail:
|
|
||||||
#ifdef DEBUG_USB_HOST
|
#ifdef DEBUG_USB_HOST
|
||||||
|
Fail:
|
||||||
Notify(PSTR("\r\nXbox Init Failed, error code: "), 0x80);
|
Notify(PSTR("\r\nXbox Init Failed, error code: "), 0x80);
|
||||||
NotifyFail(rcode);
|
NotifyFail(rcode);
|
||||||
#endif
|
#endif
|
||||||
|
|
51
XBOXRECV.cpp
51
XBOXRECV.cpp
|
@ -39,6 +39,7 @@ bPollEnable(false) { // don't start polling before dongle is connected
|
||||||
|
|
||||||
uint8_t XBOXRECV::Init(uint8_t parent, uint8_t port, bool lowspeed) {
|
uint8_t XBOXRECV::Init(uint8_t parent, uint8_t port, bool lowspeed) {
|
||||||
uint8_t buf[sizeof (USB_DEVICE_DESCRIPTOR)];
|
uint8_t buf[sizeof (USB_DEVICE_DESCRIPTOR)];
|
||||||
|
USB_DEVICE_DESCRIPTOR * udd = reinterpret_cast<USB_DEVICE_DESCRIPTOR*>(buf);
|
||||||
uint8_t rcode;
|
uint8_t rcode;
|
||||||
UsbDevice *p = NULL;
|
UsbDevice *p = NULL;
|
||||||
EpInfo *oldep_ptr = NULL;
|
EpInfo *oldep_ptr = NULL;
|
||||||
|
@ -91,8 +92,8 @@ uint8_t XBOXRECV::Init(uint8_t parent, uint8_t port, bool lowspeed) {
|
||||||
if (rcode)
|
if (rcode)
|
||||||
goto FailGetDevDescr;
|
goto FailGetDevDescr;
|
||||||
|
|
||||||
VID = ((USB_DEVICE_DESCRIPTOR*)buf)->idVendor;
|
VID = udd->idVendor;
|
||||||
PID = ((USB_DEVICE_DESCRIPTOR*)buf)->idProduct;
|
PID = udd->idProduct;
|
||||||
|
|
||||||
if (VID != XBOX_VID && VID != MADCATZ_VID) // We just check if it's a Xbox receiver using the Vendor ID
|
if (VID != XBOX_VID && VID != MADCATZ_VID) // We just check if it's a Xbox receiver using the Vendor ID
|
||||||
goto FailUnknownDevice;
|
goto FailUnknownDevice;
|
||||||
|
@ -110,7 +111,7 @@ uint8_t XBOXRECV::Init(uint8_t parent, uint8_t port, bool lowspeed) {
|
||||||
return USB_ERROR_OUT_OF_ADDRESS_SPACE_IN_POOL;
|
return USB_ERROR_OUT_OF_ADDRESS_SPACE_IN_POOL;
|
||||||
|
|
||||||
// Extract Max Packet Size from device descriptor
|
// Extract Max Packet Size from device descriptor
|
||||||
epInfo[0].maxPktSize = (uint8_t)((USB_DEVICE_DESCRIPTOR*)buf)->bMaxPacketSize0;
|
epInfo[0].maxPktSize = udd->bMaxPacketSize0;
|
||||||
|
|
||||||
// Assign new address to the device
|
// Assign new address to the device
|
||||||
rcode = pUsb->setAddr(0, 0, bAddress);
|
rcode = pUsb->setAddr(0, 0, bAddress);
|
||||||
|
@ -153,53 +154,53 @@ uint8_t XBOXRECV::Init(uint8_t parent, uint8_t port, bool lowspeed) {
|
||||||
epInfo[ XBOX_INPUT_PIPE_1 ].epAttribs = EP_INTERRUPT;
|
epInfo[ XBOX_INPUT_PIPE_1 ].epAttribs = EP_INTERRUPT;
|
||||||
epInfo[ XBOX_INPUT_PIPE_1 ].bmNakPower = USB_NAK_NOWAIT; // Only poll once for interrupt endpoints
|
epInfo[ XBOX_INPUT_PIPE_1 ].bmNakPower = USB_NAK_NOWAIT; // Only poll once for interrupt endpoints
|
||||||
epInfo[ XBOX_INPUT_PIPE_1 ].maxPktSize = EP_MAXPKTSIZE;
|
epInfo[ XBOX_INPUT_PIPE_1 ].maxPktSize = EP_MAXPKTSIZE;
|
||||||
epInfo[ XBOX_INPUT_PIPE_1 ].bmSndToggle = bmSNDTOG0;
|
epInfo[ XBOX_INPUT_PIPE_1 ].bmSndToggle = 0;
|
||||||
epInfo[ XBOX_INPUT_PIPE_1 ].bmRcvToggle = bmRCVTOG0;
|
epInfo[ XBOX_INPUT_PIPE_1 ].bmRcvToggle = 0;
|
||||||
epInfo[ XBOX_OUTPUT_PIPE_1 ].epAddr = 0x01; // XBOX 360 output endpoint - poll interval 8ms
|
epInfo[ XBOX_OUTPUT_PIPE_1 ].epAddr = 0x01; // XBOX 360 output endpoint - poll interval 8ms
|
||||||
epInfo[ XBOX_OUTPUT_PIPE_1 ].epAttribs = EP_INTERRUPT;
|
epInfo[ XBOX_OUTPUT_PIPE_1 ].epAttribs = EP_INTERRUPT;
|
||||||
epInfo[ XBOX_OUTPUT_PIPE_1 ].bmNakPower = USB_NAK_NOWAIT; // Only poll once for interrupt endpoints
|
epInfo[ XBOX_OUTPUT_PIPE_1 ].bmNakPower = USB_NAK_NOWAIT; // Only poll once for interrupt endpoints
|
||||||
epInfo[ XBOX_OUTPUT_PIPE_1 ].maxPktSize = EP_MAXPKTSIZE;
|
epInfo[ XBOX_OUTPUT_PIPE_1 ].maxPktSize = EP_MAXPKTSIZE;
|
||||||
epInfo[ XBOX_OUTPUT_PIPE_1 ].bmSndToggle = bmSNDTOG0;
|
epInfo[ XBOX_OUTPUT_PIPE_1 ].bmSndToggle = 0;
|
||||||
epInfo[ XBOX_OUTPUT_PIPE_1 ].bmRcvToggle = bmRCVTOG0;
|
epInfo[ XBOX_OUTPUT_PIPE_1 ].bmRcvToggle = 0;
|
||||||
|
|
||||||
epInfo[ XBOX_INPUT_PIPE_2 ].epAddr = 0x03; // XBOX 360 report endpoint - poll interval 1ms
|
epInfo[ XBOX_INPUT_PIPE_2 ].epAddr = 0x03; // XBOX 360 report endpoint - poll interval 1ms
|
||||||
epInfo[ XBOX_INPUT_PIPE_2 ].epAttribs = EP_INTERRUPT;
|
epInfo[ XBOX_INPUT_PIPE_2 ].epAttribs = EP_INTERRUPT;
|
||||||
epInfo[ XBOX_INPUT_PIPE_2 ].bmNakPower = USB_NAK_NOWAIT; // Only poll once for interrupt endpoints
|
epInfo[ XBOX_INPUT_PIPE_2 ].bmNakPower = USB_NAK_NOWAIT; // Only poll once for interrupt endpoints
|
||||||
epInfo[ XBOX_INPUT_PIPE_2 ].maxPktSize = EP_MAXPKTSIZE;
|
epInfo[ XBOX_INPUT_PIPE_2 ].maxPktSize = EP_MAXPKTSIZE;
|
||||||
epInfo[ XBOX_INPUT_PIPE_2 ].bmSndToggle = bmSNDTOG0;
|
epInfo[ XBOX_INPUT_PIPE_2 ].bmSndToggle = 0;
|
||||||
epInfo[ XBOX_INPUT_PIPE_2 ].bmRcvToggle = bmRCVTOG0;
|
epInfo[ XBOX_INPUT_PIPE_2 ].bmRcvToggle = 0;
|
||||||
epInfo[ XBOX_OUTPUT_PIPE_2 ].epAddr = 0x03; // XBOX 360 output endpoint - poll interval 8ms
|
epInfo[ XBOX_OUTPUT_PIPE_2 ].epAddr = 0x03; // XBOX 360 output endpoint - poll interval 8ms
|
||||||
epInfo[ XBOX_OUTPUT_PIPE_2 ].epAttribs = EP_INTERRUPT;
|
epInfo[ XBOX_OUTPUT_PIPE_2 ].epAttribs = EP_INTERRUPT;
|
||||||
epInfo[ XBOX_OUTPUT_PIPE_2 ].bmNakPower = USB_NAK_NOWAIT; // Only poll once for interrupt endpoints
|
epInfo[ XBOX_OUTPUT_PIPE_2 ].bmNakPower = USB_NAK_NOWAIT; // Only poll once for interrupt endpoints
|
||||||
epInfo[ XBOX_OUTPUT_PIPE_2 ].maxPktSize = EP_MAXPKTSIZE;
|
epInfo[ XBOX_OUTPUT_PIPE_2 ].maxPktSize = EP_MAXPKTSIZE;
|
||||||
epInfo[ XBOX_OUTPUT_PIPE_2 ].bmSndToggle = bmSNDTOG0;
|
epInfo[ XBOX_OUTPUT_PIPE_2 ].bmSndToggle = 0;
|
||||||
epInfo[ XBOX_OUTPUT_PIPE_2 ].bmRcvToggle = bmRCVTOG0;
|
epInfo[ XBOX_OUTPUT_PIPE_2 ].bmRcvToggle = 0;
|
||||||
|
|
||||||
epInfo[ XBOX_INPUT_PIPE_3 ].epAddr = 0x05; // XBOX 360 report endpoint - poll interval 1ms
|
epInfo[ XBOX_INPUT_PIPE_3 ].epAddr = 0x05; // XBOX 360 report endpoint - poll interval 1ms
|
||||||
epInfo[ XBOX_INPUT_PIPE_3 ].epAttribs = EP_INTERRUPT;
|
epInfo[ XBOX_INPUT_PIPE_3 ].epAttribs = EP_INTERRUPT;
|
||||||
epInfo[ XBOX_INPUT_PIPE_3 ].bmNakPower = USB_NAK_NOWAIT; // Only poll once for interrupt endpoints
|
epInfo[ XBOX_INPUT_PIPE_3 ].bmNakPower = USB_NAK_NOWAIT; // Only poll once for interrupt endpoints
|
||||||
epInfo[ XBOX_INPUT_PIPE_3 ].maxPktSize = EP_MAXPKTSIZE;
|
epInfo[ XBOX_INPUT_PIPE_3 ].maxPktSize = EP_MAXPKTSIZE;
|
||||||
epInfo[ XBOX_INPUT_PIPE_3 ].bmSndToggle = bmSNDTOG0;
|
epInfo[ XBOX_INPUT_PIPE_3 ].bmSndToggle = 0;
|
||||||
epInfo[ XBOX_INPUT_PIPE_3 ].bmRcvToggle = bmRCVTOG0;
|
epInfo[ XBOX_INPUT_PIPE_3 ].bmRcvToggle = 0;
|
||||||
epInfo[ XBOX_OUTPUT_PIPE_3 ].epAddr = 0x05; // XBOX 360 output endpoint - poll interval 8ms
|
epInfo[ XBOX_OUTPUT_PIPE_3 ].epAddr = 0x05; // XBOX 360 output endpoint - poll interval 8ms
|
||||||
epInfo[ XBOX_OUTPUT_PIPE_3 ].epAttribs = EP_INTERRUPT;
|
epInfo[ XBOX_OUTPUT_PIPE_3 ].epAttribs = EP_INTERRUPT;
|
||||||
epInfo[ XBOX_OUTPUT_PIPE_3 ].bmNakPower = USB_NAK_NOWAIT; // Only poll once for interrupt endpoints
|
epInfo[ XBOX_OUTPUT_PIPE_3 ].bmNakPower = USB_NAK_NOWAIT; // Only poll once for interrupt endpoints
|
||||||
epInfo[ XBOX_OUTPUT_PIPE_3 ].maxPktSize = EP_MAXPKTSIZE;
|
epInfo[ XBOX_OUTPUT_PIPE_3 ].maxPktSize = EP_MAXPKTSIZE;
|
||||||
epInfo[ XBOX_OUTPUT_PIPE_3 ].bmSndToggle = bmSNDTOG0;
|
epInfo[ XBOX_OUTPUT_PIPE_3 ].bmSndToggle = 0;
|
||||||
epInfo[ XBOX_OUTPUT_PIPE_3 ].bmRcvToggle = bmRCVTOG0;
|
epInfo[ XBOX_OUTPUT_PIPE_3 ].bmRcvToggle = 0;
|
||||||
|
|
||||||
epInfo[ XBOX_INPUT_PIPE_4 ].epAddr = 0x07; // XBOX 360 report endpoint - poll interval 1ms
|
epInfo[ XBOX_INPUT_PIPE_4 ].epAddr = 0x07; // XBOX 360 report endpoint - poll interval 1ms
|
||||||
epInfo[ XBOX_INPUT_PIPE_4 ].epAttribs = EP_INTERRUPT;
|
epInfo[ XBOX_INPUT_PIPE_4 ].epAttribs = EP_INTERRUPT;
|
||||||
epInfo[ XBOX_INPUT_PIPE_4 ].bmNakPower = USB_NAK_NOWAIT; // Only poll once for interrupt endpoints
|
epInfo[ XBOX_INPUT_PIPE_4 ].bmNakPower = USB_NAK_NOWAIT; // Only poll once for interrupt endpoints
|
||||||
epInfo[ XBOX_INPUT_PIPE_4 ].maxPktSize = EP_MAXPKTSIZE;
|
epInfo[ XBOX_INPUT_PIPE_4 ].maxPktSize = EP_MAXPKTSIZE;
|
||||||
epInfo[ XBOX_INPUT_PIPE_4 ].bmSndToggle = bmSNDTOG0;
|
epInfo[ XBOX_INPUT_PIPE_4 ].bmSndToggle = 0;
|
||||||
epInfo[ XBOX_INPUT_PIPE_4 ].bmRcvToggle = bmRCVTOG0;
|
epInfo[ XBOX_INPUT_PIPE_4 ].bmRcvToggle = 0;
|
||||||
epInfo[ XBOX_OUTPUT_PIPE_4 ].epAddr = 0x07; // XBOX 360 output endpoint - poll interval 8ms
|
epInfo[ XBOX_OUTPUT_PIPE_4 ].epAddr = 0x07; // XBOX 360 output endpoint - poll interval 8ms
|
||||||
epInfo[ XBOX_OUTPUT_PIPE_4 ].epAttribs = EP_INTERRUPT;
|
epInfo[ XBOX_OUTPUT_PIPE_4 ].epAttribs = EP_INTERRUPT;
|
||||||
epInfo[ XBOX_OUTPUT_PIPE_4 ].bmNakPower = USB_NAK_NOWAIT; // Only poll once for interrupt endpoints
|
epInfo[ XBOX_OUTPUT_PIPE_4 ].bmNakPower = USB_NAK_NOWAIT; // Only poll once for interrupt endpoints
|
||||||
epInfo[ XBOX_OUTPUT_PIPE_4 ].maxPktSize = EP_MAXPKTSIZE;
|
epInfo[ XBOX_OUTPUT_PIPE_4 ].maxPktSize = EP_MAXPKTSIZE;
|
||||||
epInfo[ XBOX_OUTPUT_PIPE_4 ].bmSndToggle = bmSNDTOG0;
|
epInfo[ XBOX_OUTPUT_PIPE_4 ].bmSndToggle = 0;
|
||||||
epInfo[ XBOX_OUTPUT_PIPE_4 ].bmRcvToggle = bmRCVTOG0;
|
epInfo[ XBOX_OUTPUT_PIPE_4 ].bmRcvToggle = 0;
|
||||||
|
|
||||||
rcode = pUsb->setEpInfoEntry(bAddress, 9, epInfo);
|
rcode = pUsb->setEpInfoEntry(bAddress, 9, epInfo);
|
||||||
if (rcode)
|
if (rcode)
|
||||||
|
@ -235,7 +236,6 @@ FailSetConfDescr:
|
||||||
#ifdef DEBUG_USB_HOST
|
#ifdef DEBUG_USB_HOST
|
||||||
NotifyFailSetConfDescr();
|
NotifyFailSetConfDescr();
|
||||||
#endif
|
#endif
|
||||||
goto Fail;
|
|
||||||
|
|
||||||
FailUnknownDevice:
|
FailUnknownDevice:
|
||||||
#ifdef DEBUG_USB_HOST
|
#ifdef DEBUG_USB_HOST
|
||||||
|
@ -243,8 +243,8 @@ FailUnknownDevice:
|
||||||
#endif
|
#endif
|
||||||
rcode = USB_DEV_CONFIG_ERROR_DEVICE_NOT_SUPPORTED;
|
rcode = USB_DEV_CONFIG_ERROR_DEVICE_NOT_SUPPORTED;
|
||||||
|
|
||||||
Fail:
|
|
||||||
#ifdef DEBUG_USB_HOST
|
#ifdef DEBUG_USB_HOST
|
||||||
|
Fail:
|
||||||
Notify(PSTR("\r\nXbox 360 Init Failed, error code: "), 0x80);
|
Notify(PSTR("\r\nXbox 360 Init Failed, error code: "), 0x80);
|
||||||
NotifyFail(rcode);
|
NotifyFail(rcode);
|
||||||
#endif
|
#endif
|
||||||
|
@ -442,7 +442,9 @@ uint8_t XBOXRECV::getBatteryLevel(uint8_t controller) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void XBOXRECV::XboxCommand(uint8_t controller, uint8_t* data, uint16_t nbytes) {
|
void XBOXRECV::XboxCommand(uint8_t controller, uint8_t* data, uint16_t nbytes) {
|
||||||
|
#ifdef EXTRADEBUG
|
||||||
uint8_t rcode;
|
uint8_t rcode;
|
||||||
|
#endif
|
||||||
uint8_t outputPipe;
|
uint8_t outputPipe;
|
||||||
switch (controller) {
|
switch (controller) {
|
||||||
case 0: outputPipe = XBOX_OUTPUT_PIPE_1;
|
case 0: outputPipe = XBOX_OUTPUT_PIPE_1;
|
||||||
|
@ -453,8 +455,13 @@ void XBOXRECV::XboxCommand(uint8_t controller, uint8_t* data, uint16_t nbytes) {
|
||||||
break;
|
break;
|
||||||
case 3: outputPipe = XBOX_OUTPUT_PIPE_4;
|
case 3: outputPipe = XBOX_OUTPUT_PIPE_4;
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
rcode = pUsb->outTransfer(bAddress, epInfo[ outputPipe ].epAddr, nbytes, data);
|
#ifdef EXTRADEBUG
|
||||||
|
rcode =
|
||||||
|
#endif
|
||||||
|
pUsb->outTransfer(bAddress, epInfo[ outputPipe ].epAddr, nbytes, data);
|
||||||
#ifdef EXTRADEBUG
|
#ifdef EXTRADEBUG
|
||||||
if (rcode)
|
if (rcode)
|
||||||
Notify(PSTR("Error sending Xbox message\r\n"), 0x80);
|
Notify(PSTR("Error sending Xbox message\r\n"), 0x80);
|
||||||
|
|
17
XBOXUSB.cpp
17
XBOXUSB.cpp
|
@ -37,6 +37,7 @@ bPollEnable(false) { // don't start polling before dongle is connected
|
||||||
|
|
||||||
uint8_t XBOXUSB::Init(uint8_t parent, uint8_t port, bool lowspeed) {
|
uint8_t XBOXUSB::Init(uint8_t parent, uint8_t port, bool lowspeed) {
|
||||||
uint8_t buf[sizeof (USB_DEVICE_DESCRIPTOR)];
|
uint8_t buf[sizeof (USB_DEVICE_DESCRIPTOR)];
|
||||||
|
USB_DEVICE_DESCRIPTOR * udd = reinterpret_cast<USB_DEVICE_DESCRIPTOR*>(buf);
|
||||||
uint8_t rcode;
|
uint8_t rcode;
|
||||||
UsbDevice *p = NULL;
|
UsbDevice *p = NULL;
|
||||||
EpInfo *oldep_ptr = NULL;
|
EpInfo *oldep_ptr = NULL;
|
||||||
|
@ -89,8 +90,8 @@ uint8_t XBOXUSB::Init(uint8_t parent, uint8_t port, bool lowspeed) {
|
||||||
if (rcode)
|
if (rcode)
|
||||||
goto FailGetDevDescr;
|
goto FailGetDevDescr;
|
||||||
|
|
||||||
VID = ((USB_DEVICE_DESCRIPTOR*)buf)->idVendor;
|
VID = udd->idVendor;
|
||||||
PID = ((USB_DEVICE_DESCRIPTOR*)buf)->idProduct;
|
PID = udd->idProduct;
|
||||||
|
|
||||||
if (VID != XBOX_VID && VID != MADCATZ_VID && VID != JOYTECH_VID && VID != GAMESTOP_VID) // Check VID
|
if (VID != XBOX_VID && VID != MADCATZ_VID && VID != JOYTECH_VID && VID != GAMESTOP_VID) // Check VID
|
||||||
goto FailUnknownDevice;
|
goto FailUnknownDevice;
|
||||||
|
@ -114,7 +115,7 @@ uint8_t XBOXUSB::Init(uint8_t parent, uint8_t port, bool lowspeed) {
|
||||||
return USB_ERROR_OUT_OF_ADDRESS_SPACE_IN_POOL;
|
return USB_ERROR_OUT_OF_ADDRESS_SPACE_IN_POOL;
|
||||||
|
|
||||||
// Extract Max Packet Size from device descriptor
|
// Extract Max Packet Size from device descriptor
|
||||||
epInfo[0].maxPktSize = (uint8_t)((USB_DEVICE_DESCRIPTOR*)buf)->bMaxPacketSize0;
|
epInfo[0].maxPktSize = udd->bMaxPacketSize0;
|
||||||
|
|
||||||
// Assign new address to the device
|
// Assign new address to the device
|
||||||
rcode = pUsb->setAddr(0, 0, bAddress);
|
rcode = pUsb->setAddr(0, 0, bAddress);
|
||||||
|
@ -157,14 +158,14 @@ uint8_t XBOXUSB::Init(uint8_t parent, uint8_t port, bool lowspeed) {
|
||||||
epInfo[ XBOX_INPUT_PIPE ].epAttribs = EP_INTERRUPT;
|
epInfo[ XBOX_INPUT_PIPE ].epAttribs = EP_INTERRUPT;
|
||||||
epInfo[ XBOX_INPUT_PIPE ].bmNakPower = USB_NAK_NOWAIT; // Only poll once for interrupt endpoints
|
epInfo[ XBOX_INPUT_PIPE ].bmNakPower = USB_NAK_NOWAIT; // Only poll once for interrupt endpoints
|
||||||
epInfo[ XBOX_INPUT_PIPE ].maxPktSize = EP_MAXPKTSIZE;
|
epInfo[ XBOX_INPUT_PIPE ].maxPktSize = EP_MAXPKTSIZE;
|
||||||
epInfo[ XBOX_INPUT_PIPE ].bmSndToggle = bmSNDTOG0;
|
epInfo[ XBOX_INPUT_PIPE ].bmSndToggle = 0;
|
||||||
epInfo[ XBOX_INPUT_PIPE ].bmRcvToggle = bmRCVTOG0;
|
epInfo[ XBOX_INPUT_PIPE ].bmRcvToggle = 0;
|
||||||
epInfo[ XBOX_OUTPUT_PIPE ].epAddr = 0x02; // XBOX 360 output endpoint
|
epInfo[ XBOX_OUTPUT_PIPE ].epAddr = 0x02; // XBOX 360 output endpoint
|
||||||
epInfo[ XBOX_OUTPUT_PIPE ].epAttribs = EP_INTERRUPT;
|
epInfo[ XBOX_OUTPUT_PIPE ].epAttribs = EP_INTERRUPT;
|
||||||
epInfo[ XBOX_OUTPUT_PIPE ].bmNakPower = USB_NAK_NOWAIT; // Only poll once for interrupt endpoints
|
epInfo[ XBOX_OUTPUT_PIPE ].bmNakPower = USB_NAK_NOWAIT; // Only poll once for interrupt endpoints
|
||||||
epInfo[ XBOX_OUTPUT_PIPE ].maxPktSize = EP_MAXPKTSIZE;
|
epInfo[ XBOX_OUTPUT_PIPE ].maxPktSize = EP_MAXPKTSIZE;
|
||||||
epInfo[ XBOX_OUTPUT_PIPE ].bmSndToggle = bmSNDTOG0;
|
epInfo[ XBOX_OUTPUT_PIPE ].bmSndToggle = 0;
|
||||||
epInfo[ XBOX_OUTPUT_PIPE ].bmRcvToggle = bmRCVTOG0;
|
epInfo[ XBOX_OUTPUT_PIPE ].bmRcvToggle = 0;
|
||||||
|
|
||||||
rcode = pUsb->setEpInfoEntry(bAddress, 3, epInfo);
|
rcode = pUsb->setEpInfoEntry(bAddress, 3, epInfo);
|
||||||
if (rcode)
|
if (rcode)
|
||||||
|
@ -208,8 +209,8 @@ FailUnknownDevice:
|
||||||
#endif
|
#endif
|
||||||
rcode = USB_DEV_CONFIG_ERROR_DEVICE_NOT_SUPPORTED;
|
rcode = USB_DEV_CONFIG_ERROR_DEVICE_NOT_SUPPORTED;
|
||||||
|
|
||||||
Fail:
|
|
||||||
#ifdef DEBUG_USB_HOST
|
#ifdef DEBUG_USB_HOST
|
||||||
|
Fail:
|
||||||
Notify(PSTR("\r\nXbox 360 Init Failed, error code: "), 0x80);
|
Notify(PSTR("\r\nXbox 360 Init Failed, error code: "), 0x80);
|
||||||
NotifyFail(rcode);
|
NotifyFail(rcode);
|
||||||
#endif
|
#endif
|
||||||
|
|
20
address.h
20
address.h
|
@ -122,7 +122,8 @@ class AddressPoolImpl : public AddressPool {
|
||||||
|
|
||||||
uint8_t FindChildIndex(UsbDeviceAddress addr, uint8_t start = 1) {
|
uint8_t FindChildIndex(UsbDeviceAddress addr, uint8_t start = 1) {
|
||||||
for(uint8_t i = (start < 1 || start >= MAX_DEVICES_ALLOWED) ? 1 : start; i < MAX_DEVICES_ALLOWED; i++) {
|
for(uint8_t i = (start < 1 || start >= MAX_DEVICES_ALLOWED) ? 1 : start; i < MAX_DEVICES_ALLOWED; i++) {
|
||||||
if(((UsbDeviceAddress*) & thePool[i].address)->bmParent == addr.bmAddress)
|
UsbDeviceAddress* uda = reinterpret_cast<UsbDeviceAddress *>(&thePool[i].address);
|
||||||
|
if(uda->bmParent == addr.bmAddress)
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -133,14 +134,14 @@ class AddressPoolImpl : public AddressPool {
|
||||||
// Zerro field is reserved and should not be affected
|
// Zerro field is reserved and should not be affected
|
||||||
if(index == 0)
|
if(index == 0)
|
||||||
return;
|
return;
|
||||||
|
UsbDeviceAddress* uda = reinterpret_cast<UsbDeviceAddress *>(& thePool[index].address);
|
||||||
// If a hub was switched off all port addresses should be freed
|
// If a hub was switched off all port addresses should be freed
|
||||||
if(((UsbDeviceAddress*) & thePool[index].address)->bmHub == 1) {
|
if(uda->bmHub == 1) {
|
||||||
for(uint8_t i = 1; (i = FindChildIndex(*((UsbDeviceAddress*) & thePool[index].address), i));)
|
for(uint8_t i = 1; (i = FindChildIndex(*uda, i));)
|
||||||
FreeAddressByIndex(i);
|
FreeAddressByIndex(i);
|
||||||
|
|
||||||
// If the hub had the last allocated address, hubCounter should be decremented
|
// If the hub had the last allocated address, hubCounter should be decremented
|
||||||
if(hubCounter == ((UsbDeviceAddress*) & thePool[index].address)->bmAddress)
|
if(hubCounter == uda->bmAddress)
|
||||||
hubCounter--;
|
hubCounter--;
|
||||||
}
|
}
|
||||||
InitEntry(index);
|
InitEntry(index);
|
||||||
|
@ -220,8 +221,9 @@ public:
|
||||||
|
|
||||||
UsbDeviceAddress addr;
|
UsbDeviceAddress addr;
|
||||||
addr.devAddress = 0; // Ensure all bits are zero
|
addr.devAddress = 0; // Ensure all bits are zero
|
||||||
|
UsbDeviceAddress* uda = reinterpret_cast<UsbDeviceAddress *>(&parent);
|
||||||
addr.bmParent = ((UsbDeviceAddress*) & parent)->bmAddress;
|
//addr.bmParent = ((UsbDeviceAddress*) & parent)->bmAddress;
|
||||||
|
addr.bmParent = uda->bmAddress;
|
||||||
|
|
||||||
if(is_hub) {
|
if(is_hub) {
|
||||||
addr.bmHub = 1;
|
addr.bmHub = 1;
|
||||||
|
@ -230,7 +232,9 @@ public:
|
||||||
addr.bmHub = 0;
|
addr.bmHub = 0;
|
||||||
addr.bmAddress = port;
|
addr.bmAddress = port;
|
||||||
}
|
}
|
||||||
thePool[index].address = *((uint8_t*) & addr);
|
uint8_t* uaddr = reinterpret_cast<uint8_t*>(&addr);
|
||||||
|
//thePool[index].address = *((uint8_t*) & addr);
|
||||||
|
thePool[index].address = *uaddr;
|
||||||
/*
|
/*
|
||||||
USB_HOST_SERIAL.print("Addr:");
|
USB_HOST_SERIAL.print("Addr:");
|
||||||
USB_HOST_SERIAL.print(addr.bmHub, HEX);
|
USB_HOST_SERIAL.print(addr.bmHub, HEX);
|
||||||
|
|
17
adk.cpp
17
adk.cpp
|
@ -66,6 +66,7 @@ uint8_t ADK::ConfigureDevice(uint8_t parent, uint8_t port, bool lowspeed) {
|
||||||
uint8_t ADK::Init(uint8_t parent, uint8_t port, bool lowspeed) {
|
uint8_t ADK::Init(uint8_t parent, uint8_t port, bool lowspeed) {
|
||||||
|
|
||||||
uint8_t buf[sizeof (USB_DEVICE_DESCRIPTOR)];
|
uint8_t buf[sizeof (USB_DEVICE_DESCRIPTOR)];
|
||||||
|
USB_DEVICE_DESCRIPTOR * udd = reinterpret_cast<USB_DEVICE_DESCRIPTOR*>(buf);
|
||||||
uint8_t rcode;
|
uint8_t rcode;
|
||||||
uint8_t num_of_conf; // number of configurations
|
uint8_t num_of_conf; // number of configurations
|
||||||
UsbDevice *p = NULL;
|
UsbDevice *p = NULL;
|
||||||
|
@ -117,7 +118,7 @@ uint8_t ADK::Init(uint8_t parent, uint8_t port, bool lowspeed) {
|
||||||
bAddress = addrPool.AllocAddress(parent, false, port);
|
bAddress = addrPool.AllocAddress(parent, false, port);
|
||||||
|
|
||||||
// Extract Max Packet Size from device descriptor
|
// Extract Max Packet Size from device descriptor
|
||||||
epInfo[0].maxPktSize = (uint8_t)((USB_DEVICE_DESCRIPTOR*)buf)->bMaxPacketSize0;
|
epInfo[0].maxPktSize = udd->bMaxPacketSize0;
|
||||||
// Assign new address to the device
|
// Assign new address to the device
|
||||||
rcode = pUsb->setAddr(0, 0, bAddress);
|
rcode = pUsb->setAddr(0, 0, bAddress);
|
||||||
if (rcode) {
|
if (rcode) {
|
||||||
|
@ -149,11 +150,11 @@ uint8_t ADK::Init(uint8_t parent, uint8_t port, bool lowspeed) {
|
||||||
}
|
}
|
||||||
|
|
||||||
//check if ADK device is already in accessory mode; if yes, configure and exit
|
//check if ADK device is already in accessory mode; if yes, configure and exit
|
||||||
if (((USB_DEVICE_DESCRIPTOR*)buf)->idVendor == ADK_VID &&
|
if (udd->idVendor == ADK_VID &&
|
||||||
(((USB_DEVICE_DESCRIPTOR*)buf)->idProduct == ADK_PID || ((USB_DEVICE_DESCRIPTOR*)buf)->idProduct == ADB_PID)) {
|
(udd->idProduct == ADK_PID || udd->idProduct == ADB_PID)) {
|
||||||
USBTRACE("\r\nAcc.mode device detected");
|
USBTRACE("\r\nAcc.mode device detected");
|
||||||
/* go through configurations, find first bulk-IN, bulk-OUT EP, fill epInfo and quit */
|
/* go through configurations, find first bulk-IN, bulk-OUT EP, fill epInfo and quit */
|
||||||
num_of_conf = ((USB_DEVICE_DESCRIPTOR*)buf)->bNumConfigurations;
|
num_of_conf = udd->bNumConfigurations;
|
||||||
|
|
||||||
//USBTRACE2("\r\nNC:",num_of_conf);
|
//USBTRACE2("\r\nNC:",num_of_conf);
|
||||||
|
|
||||||
|
@ -268,15 +269,15 @@ FailSwAcc:
|
||||||
goto Fail;
|
goto Fail;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
SwAttempt:
|
|
||||||
#ifdef DEBUG_USB_HOST
|
|
||||||
USBTRACE("\r\nAccessory mode switch attempt");
|
|
||||||
#endif
|
|
||||||
//FailOnInit:
|
//FailOnInit:
|
||||||
// USBTRACE("OnInit:");
|
// USBTRACE("OnInit:");
|
||||||
// goto Fail;
|
// goto Fail;
|
||||||
//
|
//
|
||||||
|
SwAttempt:
|
||||||
|
#ifdef DEBUG_USB_HOST
|
||||||
|
USBTRACE("\r\nAccessory mode switch attempt");
|
||||||
Fail:
|
Fail:
|
||||||
|
#endif
|
||||||
//USBTRACE2("\r\nADK Init Failed, error code: ", rcode);
|
//USBTRACE2("\r\nADK Init Failed, error code: ", rcode);
|
||||||
//NotifyFail(rcode);
|
//NotifyFail(rcode);
|
||||||
Release();
|
Release();
|
||||||
|
|
|
@ -821,4 +821,5 @@ MAKE_PIN(P33, CORE_PIN33_PORTREG, CORE_PIN33_BIT, CORE_PIN33_CONFIG);
|
||||||
|
|
||||||
#endif // __arm__
|
#endif // __arm__
|
||||||
|
|
||||||
|
#define output_pgm_message(wa, fp, mp , el) wa = &mp, fp((char *)pgm_read_pointer(wa), el)
|
||||||
#endif //_avrpins_h_
|
#endif //_avrpins_h_
|
||||||
|
|
12
cdcacm.cpp
12
cdcacm.cpp
|
@ -28,8 +28,8 @@ bControlIface(0),
|
||||||
bDataIface(0),
|
bDataIface(0),
|
||||||
bNumEP(1),
|
bNumEP(1),
|
||||||
qNextPollTime(0),
|
qNextPollTime(0),
|
||||||
ready(false),
|
bPollEnable(false),
|
||||||
bPollEnable(false) {
|
ready(false) {
|
||||||
for (uint8_t i = 0; i < ACM_MAX_ENDPOINTS; i++) {
|
for (uint8_t i = 0; i < ACM_MAX_ENDPOINTS; i++) {
|
||||||
epInfo[i].epAddr = 0;
|
epInfo[i].epAddr = 0;
|
||||||
epInfo[i].maxPktSize = (i) ? 0 : 8;
|
epInfo[i].maxPktSize = (i) ? 0 : 8;
|
||||||
|
@ -48,6 +48,8 @@ uint8_t ACM::Init(uint8_t parent, uint8_t port, bool lowspeed) {
|
||||||
const uint8_t constBufSize = sizeof (USB_DEVICE_DESCRIPTOR);
|
const uint8_t constBufSize = sizeof (USB_DEVICE_DESCRIPTOR);
|
||||||
|
|
||||||
uint8_t buf[constBufSize];
|
uint8_t buf[constBufSize];
|
||||||
|
USB_DEVICE_DESCRIPTOR * udd = reinterpret_cast<USB_DEVICE_DESCRIPTOR*>(buf);
|
||||||
|
|
||||||
uint8_t rcode;
|
uint8_t rcode;
|
||||||
UsbDevice *p = NULL;
|
UsbDevice *p = NULL;
|
||||||
EpInfo *oldep_ptr = NULL;
|
EpInfo *oldep_ptr = NULL;
|
||||||
|
@ -95,7 +97,7 @@ uint8_t ACM::Init(uint8_t parent, uint8_t port, bool lowspeed) {
|
||||||
return USB_ERROR_OUT_OF_ADDRESS_SPACE_IN_POOL;
|
return USB_ERROR_OUT_OF_ADDRESS_SPACE_IN_POOL;
|
||||||
|
|
||||||
// Extract Max Packet Size from the device descriptor
|
// Extract Max Packet Size from the device descriptor
|
||||||
epInfo[0].maxPktSize = (uint8_t)((USB_DEVICE_DESCRIPTOR*)buf)->bMaxPacketSize0;
|
epInfo[0].maxPktSize = udd->bMaxPacketSize0;
|
||||||
|
|
||||||
// Assign new address to the device
|
// Assign new address to the device
|
||||||
rcode = pUsb->setAddr(0, 0, bAddress);
|
rcode = pUsb->setAddr(0, 0, bAddress);
|
||||||
|
@ -119,7 +121,7 @@ uint8_t ACM::Init(uint8_t parent, uint8_t port, bool lowspeed) {
|
||||||
|
|
||||||
p->lowspeed = lowspeed;
|
p->lowspeed = lowspeed;
|
||||||
|
|
||||||
num_of_conf = ((USB_DEVICE_DESCRIPTOR*)buf)->bNumConfigurations;
|
num_of_conf = udd->bNumConfigurations;
|
||||||
|
|
||||||
// Assign epInfo to epinfo pointer
|
// Assign epInfo to epinfo pointer
|
||||||
rcode = pUsb->setEpInfoEntry(bAddress, 1, epInfo);
|
rcode = pUsb->setEpInfoEntry(bAddress, 1, epInfo);
|
||||||
|
@ -211,8 +213,8 @@ FailOnInit:
|
||||||
USBTRACE("OnInit:");
|
USBTRACE("OnInit:");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
Fail:
|
|
||||||
#ifdef DEBUG_USB_HOST
|
#ifdef DEBUG_USB_HOST
|
||||||
|
Fail:
|
||||||
NotifyFail(rcode);
|
NotifyFail(rcode);
|
||||||
#endif
|
#endif
|
||||||
Release();
|
Release();
|
||||||
|
|
14
cdcftdi.cpp
14
cdcftdi.cpp
|
@ -42,6 +42,7 @@ uint8_t FTDI::Init(uint8_t parent, uint8_t port, bool lowspeed) {
|
||||||
const uint8_t constBufSize = sizeof (USB_DEVICE_DESCRIPTOR);
|
const uint8_t constBufSize = sizeof (USB_DEVICE_DESCRIPTOR);
|
||||||
|
|
||||||
uint8_t buf[constBufSize];
|
uint8_t buf[constBufSize];
|
||||||
|
USB_DEVICE_DESCRIPTOR * udd = reinterpret_cast<USB_DEVICE_DESCRIPTOR*>(buf);
|
||||||
uint8_t rcode;
|
uint8_t rcode;
|
||||||
UsbDevice *p = NULL;
|
UsbDevice *p = NULL;
|
||||||
EpInfo *oldep_ptr = NULL;
|
EpInfo *oldep_ptr = NULL;
|
||||||
|
@ -78,19 +79,18 @@ uint8_t FTDI::Init(uint8_t parent, uint8_t port, bool lowspeed) {
|
||||||
p->lowspeed = lowspeed;
|
p->lowspeed = lowspeed;
|
||||||
|
|
||||||
// Get device descriptor
|
// Get device descriptor
|
||||||
rcode = pUsb->getDevDescr(0, 0, sizeof (USB_DEVICE_DESCRIPTOR), (uint8_t*)buf);
|
rcode = pUsb->getDevDescr(0, 0, sizeof (USB_DEVICE_DESCRIPTOR), buf);
|
||||||
|
|
||||||
// Restore p->epinfo
|
// Restore p->epinfo
|
||||||
p->epinfo = oldep_ptr;
|
p->epinfo = oldep_ptr;
|
||||||
|
|
||||||
if (rcode)
|
if (rcode)
|
||||||
goto FailGetDevDescr;
|
goto FailGetDevDescr;
|
||||||
|
if (udd->idVendor != FTDI_VID || udd->idProduct != FTDI_PID)
|
||||||
if (((USB_DEVICE_DESCRIPTOR*)buf)->idVendor != FTDI_VID || ((USB_DEVICE_DESCRIPTOR*)buf)->idProduct != FTDI_PID)
|
|
||||||
return USB_DEV_CONFIG_ERROR_DEVICE_NOT_SUPPORTED;
|
return USB_DEV_CONFIG_ERROR_DEVICE_NOT_SUPPORTED;
|
||||||
|
|
||||||
// Save type of FTDI chip
|
// Save type of FTDI chip
|
||||||
wFTDIType = ((USB_DEVICE_DESCRIPTOR*)buf)->bcdDevice;
|
wFTDIType = udd->bcdDevice;
|
||||||
|
|
||||||
// Allocate new address according to device class
|
// Allocate new address according to device class
|
||||||
bAddress = addrPool.AllocAddress(parent, false, port);
|
bAddress = addrPool.AllocAddress(parent, false, port);
|
||||||
|
@ -99,7 +99,7 @@ uint8_t FTDI::Init(uint8_t parent, uint8_t port, bool lowspeed) {
|
||||||
return USB_ERROR_OUT_OF_ADDRESS_SPACE_IN_POOL;
|
return USB_ERROR_OUT_OF_ADDRESS_SPACE_IN_POOL;
|
||||||
|
|
||||||
// Extract Max Packet Size from the device descriptor
|
// Extract Max Packet Size from the device descriptor
|
||||||
epInfo[0].maxPktSize = (uint8_t)((USB_DEVICE_DESCRIPTOR*)buf)->bMaxPacketSize0;
|
epInfo[0].maxPktSize = udd->bMaxPacketSize0;
|
||||||
|
|
||||||
// Assign new address to the device
|
// Assign new address to the device
|
||||||
rcode = pUsb->setAddr(0, 0, bAddress);
|
rcode = pUsb->setAddr(0, 0, bAddress);
|
||||||
|
@ -123,7 +123,7 @@ uint8_t FTDI::Init(uint8_t parent, uint8_t port, bool lowspeed) {
|
||||||
|
|
||||||
p->lowspeed = lowspeed;
|
p->lowspeed = lowspeed;
|
||||||
|
|
||||||
num_of_conf = ((USB_DEVICE_DESCRIPTOR*)buf)->bNumConfigurations;
|
num_of_conf = udd->bNumConfigurations;
|
||||||
|
|
||||||
// Assign epInfo to epinfo pointer
|
// Assign epInfo to epinfo pointer
|
||||||
rcode = pUsb->setEpInfoEntry(bAddress, 1, epInfo);
|
rcode = pUsb->setEpInfoEntry(bAddress, 1, epInfo);
|
||||||
|
@ -204,10 +204,8 @@ FailSetConfDescr:
|
||||||
FailOnInit:
|
FailOnInit:
|
||||||
#ifdef DEBUG_USB_HOST
|
#ifdef DEBUG_USB_HOST
|
||||||
USBTRACE("OnInit:");
|
USBTRACE("OnInit:");
|
||||||
#endif
|
|
||||||
|
|
||||||
Fail:
|
Fail:
|
||||||
#ifdef DEBUG_USB_HOST
|
|
||||||
NotifyFail(rcode);
|
NotifyFail(rcode);
|
||||||
#endif
|
#endif
|
||||||
Release();
|
Release();
|
||||||
|
|
|
@ -25,6 +25,7 @@ uint8_t PL2303::Init(uint8_t parent, uint8_t port, bool lowspeed) {
|
||||||
const uint8_t constBufSize = sizeof (USB_DEVICE_DESCRIPTOR);
|
const uint8_t constBufSize = sizeof (USB_DEVICE_DESCRIPTOR);
|
||||||
|
|
||||||
uint8_t buf[constBufSize];
|
uint8_t buf[constBufSize];
|
||||||
|
USB_DEVICE_DESCRIPTOR * udd = reinterpret_cast<USB_DEVICE_DESCRIPTOR*>(buf);
|
||||||
uint8_t rcode;
|
uint8_t rcode;
|
||||||
UsbDevice *p = NULL;
|
UsbDevice *p = NULL;
|
||||||
EpInfo *oldep_ptr = NULL;
|
EpInfo *oldep_ptr = NULL;
|
||||||
|
@ -65,11 +66,11 @@ uint8_t PL2303::Init(uint8_t parent, uint8_t port, bool lowspeed) {
|
||||||
if (rcode)
|
if (rcode)
|
||||||
goto FailGetDevDescr;
|
goto FailGetDevDescr;
|
||||||
|
|
||||||
if (((USB_DEVICE_DESCRIPTOR*)buf)->idVendor != PL_VID && ((USB_DEVICE_DESCRIPTOR*)buf)->idProduct != PL_PID)
|
if (udd->idVendor != PL_VID && udd->idProduct != PL_PID)
|
||||||
return USB_DEV_CONFIG_ERROR_DEVICE_NOT_SUPPORTED;
|
return USB_DEV_CONFIG_ERROR_DEVICE_NOT_SUPPORTED;
|
||||||
|
|
||||||
// Save type of PL chip
|
// Save type of PL chip
|
||||||
wPLType = ((USB_DEVICE_DESCRIPTOR*)buf)->bcdDevice;
|
wPLType = udd->bcdDevice;
|
||||||
|
|
||||||
// Allocate new address according to device class
|
// Allocate new address according to device class
|
||||||
bAddress = addrPool.AllocAddress(parent, false, port);
|
bAddress = addrPool.AllocAddress(parent, false, port);
|
||||||
|
@ -78,7 +79,7 @@ uint8_t PL2303::Init(uint8_t parent, uint8_t port, bool lowspeed) {
|
||||||
return USB_ERROR_OUT_OF_ADDRESS_SPACE_IN_POOL;
|
return USB_ERROR_OUT_OF_ADDRESS_SPACE_IN_POOL;
|
||||||
|
|
||||||
// Extract Max Packet Size from the device descriptor
|
// Extract Max Packet Size from the device descriptor
|
||||||
epInfo[0].maxPktSize = (uint8_t)((USB_DEVICE_DESCRIPTOR*)buf)->bMaxPacketSize0;
|
epInfo[0].maxPktSize = udd->bMaxPacketSize0;
|
||||||
|
|
||||||
// Assign new address to the device
|
// Assign new address to the device
|
||||||
rcode = pUsb->setAddr(0, 0, bAddress);
|
rcode = pUsb->setAddr(0, 0, bAddress);
|
||||||
|
@ -102,7 +103,7 @@ uint8_t PL2303::Init(uint8_t parent, uint8_t port, bool lowspeed) {
|
||||||
|
|
||||||
p->lowspeed = lowspeed;
|
p->lowspeed = lowspeed;
|
||||||
|
|
||||||
num_of_conf = ((USB_DEVICE_DESCRIPTOR*)buf)->bNumConfigurations;
|
num_of_conf = udd->bNumConfigurations;
|
||||||
|
|
||||||
// Assign epInfo to epinfo pointer
|
// Assign epInfo to epinfo pointer
|
||||||
rcode = pUsb->setEpInfoEntry(bAddress, 1, epInfo);
|
rcode = pUsb->setEpInfoEntry(bAddress, 1, epInfo);
|
||||||
|
@ -184,8 +185,8 @@ FailOnInit:
|
||||||
USBTRACE("OnInit:");
|
USBTRACE("OnInit:");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
Fail:
|
|
||||||
#ifdef DEBUG_USB_HOST
|
#ifdef DEBUG_USB_HOST
|
||||||
|
Fail:
|
||||||
NotifyFail(rcode);
|
NotifyFail(rcode);
|
||||||
#endif
|
#endif
|
||||||
Release();
|
Release();
|
||||||
|
|
|
@ -88,6 +88,8 @@ void ConfigDescParser<CLASS_ID, SUBCLASS_ID, PROTOCOL_ID, MASK>::Parse(const uin
|
||||||
compare masks for them. When the match is found, calls EndpointXtract passing buffer containing endpoint descriptor */
|
compare masks for them. When the match is found, calls EndpointXtract passing buffer containing endpoint descriptor */
|
||||||
template <const uint8_t CLASS_ID, const uint8_t SUBCLASS_ID, const uint8_t PROTOCOL_ID, const uint8_t MASK>
|
template <const uint8_t CLASS_ID, const uint8_t SUBCLASS_ID, const uint8_t PROTOCOL_ID, const uint8_t MASK>
|
||||||
bool ConfigDescParser<CLASS_ID, SUBCLASS_ID, PROTOCOL_ID, MASK>::ParseDescriptor(uint8_t **pp, uint16_t *pcntdn) {
|
bool ConfigDescParser<CLASS_ID, SUBCLASS_ID, PROTOCOL_ID, MASK>::ParseDescriptor(uint8_t **pp, uint16_t *pcntdn) {
|
||||||
|
USB_CONFIGURATION_DESCRIPTOR* ucd= reinterpret_cast<USB_CONFIGURATION_DESCRIPTOR*>(varBuffer);
|
||||||
|
USB_INTERFACE_DESCRIPTOR* uid= reinterpret_cast<USB_INTERFACE_DESCRIPTOR*>(varBuffer);
|
||||||
switch(stateParseDescr) {
|
switch(stateParseDescr) {
|
||||||
case 0:
|
case 0:
|
||||||
theBuffer.valueSize = 2;
|
theBuffer.valueSize = 2;
|
||||||
|
@ -128,22 +130,22 @@ bool ConfigDescParser<CLASS_ID, SUBCLASS_ID, PROTOCOL_ID, MASK>::ParseDescriptor
|
||||||
case USB_DESCRIPTOR_CONFIGURATION:
|
case USB_DESCRIPTOR_CONFIGURATION:
|
||||||
if(!valParser.Parse(pp, pcntdn))
|
if(!valParser.Parse(pp, pcntdn))
|
||||||
return false;
|
return false;
|
||||||
confValue = ((USB_CONFIGURATION_DESCRIPTOR*) varBuffer)->bConfigurationValue;
|
confValue = ucd->bConfigurationValue;
|
||||||
break;
|
break;
|
||||||
case USB_DESCRIPTOR_INTERFACE:
|
case USB_DESCRIPTOR_INTERFACE:
|
||||||
if(!valParser.Parse(pp, pcntdn))
|
if(!valParser.Parse(pp, pcntdn))
|
||||||
return false;
|
return false;
|
||||||
if((MASK & CP_MASK_COMPARE_CLASS) && ((USB_INTERFACE_DESCRIPTOR*) varBuffer)->bInterfaceClass != CLASS_ID)
|
if((MASK & CP_MASK_COMPARE_CLASS) && uid->bInterfaceClass != CLASS_ID)
|
||||||
break;
|
break;
|
||||||
if((MASK & CP_MASK_COMPARE_SUBCLASS) && ((USB_INTERFACE_DESCRIPTOR*) varBuffer)->bInterfaceSubClass != SUBCLASS_ID)
|
if((MASK & CP_MASK_COMPARE_SUBCLASS) && uid->bInterfaceSubClass != SUBCLASS_ID)
|
||||||
break;
|
break;
|
||||||
if((MASK & CP_MASK_COMPARE_PROTOCOL) && ((USB_INTERFACE_DESCRIPTOR*) varBuffer)->bInterfaceProtocol != PROTOCOL_ID)
|
if((MASK & CP_MASK_COMPARE_PROTOCOL) && uid->bInterfaceProtocol != PROTOCOL_ID)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
isGoodInterface = true;
|
isGoodInterface = true;
|
||||||
ifaceNumber = ((USB_INTERFACE_DESCRIPTOR*) varBuffer)->bInterfaceNumber;
|
ifaceNumber = uid->bInterfaceNumber;
|
||||||
ifaceAltSet = ((USB_INTERFACE_DESCRIPTOR*) varBuffer)->bAlternateSetting;
|
ifaceAltSet = uid->bAlternateSetting;
|
||||||
protoValue = ((USB_INTERFACE_DESCRIPTOR*) varBuffer)->bInterfaceProtocol;
|
protoValue = uid->bInterfaceProtocol;
|
||||||
break;
|
break;
|
||||||
case USB_DESCRIPTOR_ENDPOINT:
|
case USB_DESCRIPTOR_ENDPOINT:
|
||||||
if(!valParser.Parse(pp, pcntdn))
|
if(!valParser.Parse(pp, pcntdn))
|
||||||
|
|
|
@ -2,7 +2,9 @@
|
||||||
#include <hiduniversal.h>
|
#include <hiduniversal.h>
|
||||||
#include <hidescriptorparser.h>
|
#include <hidescriptorparser.h>
|
||||||
#include <usbhub.h>
|
#include <usbhub.h>
|
||||||
|
#ifdef arm
|
||||||
|
#include <spi4teensy3.h>
|
||||||
|
#endif
|
||||||
#include "pgmstrings.h"
|
#include "pgmstrings.h"
|
||||||
|
|
||||||
class HIDUniversal2 : public HIDUniversal
|
class HIDUniversal2 : public HIDUniversal
|
||||||
|
|
17
hid.h
17
hid.h
|
@ -20,6 +20,9 @@ e-mail : support@circuitsathome.com
|
||||||
#include "Usb.h"
|
#include "Usb.h"
|
||||||
#include "hidusagestr.h"
|
#include "hidusagestr.h"
|
||||||
|
|
||||||
|
#define MAX_REPORT_PARSERS 2
|
||||||
|
#define HID_MAX_HID_CLASS_DESCRIPTORS 5
|
||||||
|
|
||||||
#define DATA_SIZE_MASK 0x03
|
#define DATA_SIZE_MASK 0x03
|
||||||
#define TYPE_MASK 0x0C
|
#define TYPE_MASK 0x0C
|
||||||
#define TAG_MASK 0xF0
|
#define TAG_MASK 0xF0
|
||||||
|
@ -90,12 +93,6 @@ e-mail : support@circuitsathome.com
|
||||||
#define HID_PROTOCOL_KEYBOARD 0x01
|
#define HID_PROTOCOL_KEYBOARD 0x01
|
||||||
#define HID_PROTOCOL_MOUSE 0x02
|
#define HID_PROTOCOL_MOUSE 0x02
|
||||||
|
|
||||||
struct HidItemPrefix {
|
|
||||||
uint8_t bSize : 2;
|
|
||||||
uint8_t bType : 2;
|
|
||||||
uint8_t bTag : 4;
|
|
||||||
};
|
|
||||||
|
|
||||||
#define HID_ITEM_TYPE_MAIN 0
|
#define HID_ITEM_TYPE_MAIN 0
|
||||||
#define HID_ITEM_TYPE_GLOBAL 1
|
#define HID_ITEM_TYPE_GLOBAL 1
|
||||||
#define HID_ITEM_TYPE_LOCAL 2
|
#define HID_ITEM_TYPE_LOCAL 2
|
||||||
|
@ -119,6 +116,12 @@ struct HidItemPrefix {
|
||||||
#define HID_MAIN_ITEM_COLLECTION_USAGE_SWITCH 5
|
#define HID_MAIN_ITEM_COLLECTION_USAGE_SWITCH 5
|
||||||
#define HID_MAIN_ITEM_COLLECTION_USAGE_MODIFIER 6
|
#define HID_MAIN_ITEM_COLLECTION_USAGE_MODIFIER 6
|
||||||
|
|
||||||
|
struct HidItemPrefix {
|
||||||
|
uint8_t bSize : 2;
|
||||||
|
uint8_t bType : 2;
|
||||||
|
uint8_t bTag : 4;
|
||||||
|
};
|
||||||
|
|
||||||
struct MainItemIOFeature {
|
struct MainItemIOFeature {
|
||||||
uint8_t bmIsConstantOrData : 1;
|
uint8_t bmIsConstantOrData : 1;
|
||||||
uint8_t bmIsArrayOrVariable : 1;
|
uint8_t bmIsArrayOrVariable : 1;
|
||||||
|
@ -137,8 +140,6 @@ public:
|
||||||
virtual void Parse(HID *hid, bool is_rpt_id, uint8_t len, uint8_t *buf) = 0;
|
virtual void Parse(HID *hid, bool is_rpt_id, uint8_t len, uint8_t *buf) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
#define MAX_REPORT_PARSERS 2
|
|
||||||
#define HID_MAX_HID_CLASS_DESCRIPTORS 5
|
|
||||||
|
|
||||||
class HID : public USBDeviceConfig, public UsbConfigXtracter {
|
class HID : public USBDeviceConfig, public UsbConfigXtracter {
|
||||||
protected:
|
protected:
|
||||||
|
|
40
hidboot.h
40
hidboot.h
|
@ -19,12 +19,44 @@ e-mail : support@circuitsathome.com
|
||||||
|
|
||||||
#include "hid.h"
|
#include "hid.h"
|
||||||
|
|
||||||
#define KEY_SPACE 0x2c
|
//
|
||||||
|
// FIX-ME:
|
||||||
|
// Prevent teensy HID collisions.
|
||||||
|
// These are problematic. Who changes?
|
||||||
|
// The best policy for now is to take over these definitions.
|
||||||
|
// This is a classic reason why a library should prefix defines with something unique.
|
||||||
|
// I suggest prefixing with 'UHS_' for every define in the entire library.
|
||||||
|
// Yes, this could break things, but what is one to do?
|
||||||
|
//
|
||||||
|
#ifdef KEY_SPACE
|
||||||
|
#undef KEY_SPACE
|
||||||
|
#endif
|
||||||
|
#ifdef KEY_ENTER
|
||||||
|
#undef KEY_ENTER
|
||||||
|
#endif
|
||||||
|
#ifdef KEY_PERIOD
|
||||||
|
#undef KEY_PERIOD
|
||||||
|
#endif
|
||||||
|
#ifdef KEY_NUM_LOCK
|
||||||
|
#undef KEY_NUM_LOCK
|
||||||
|
#endif
|
||||||
|
#ifdef KEY_CAPS_LOCK
|
||||||
|
#undef KEY_CAPS_LOCK
|
||||||
|
#endif
|
||||||
|
#ifdef KEY_SCROLL_LOCK
|
||||||
|
#undef KEY_SCROLL_LOCK
|
||||||
|
#endif
|
||||||
|
|
||||||
#define KEY_ZERO 0x27
|
#define KEY_ZERO 0x27
|
||||||
#define KEY_ZERO2 0x62
|
|
||||||
#define KEY_ENTER 0x28
|
#define KEY_ENTER 0x28
|
||||||
|
#define KEY_SPACE 0x2c
|
||||||
|
#define KEY_CAPS_LOCK 0x39
|
||||||
|
#define KEY_SCROLL_LOCK 0x47
|
||||||
|
#define KEY_NUM_LOCK 0x53
|
||||||
|
#define KEY_ZERO2 0x62
|
||||||
#define KEY_PERIOD 0x63
|
#define KEY_PERIOD 0x63
|
||||||
|
|
||||||
|
|
||||||
struct MOUSEINFO {
|
struct MOUSEINFO {
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
|
@ -107,10 +139,6 @@ struct KBDLEDS {
|
||||||
uint8_t bmReserved : 3;
|
uint8_t bmReserved : 3;
|
||||||
};
|
};
|
||||||
|
|
||||||
#define KEY_NUM_LOCK 0x53
|
|
||||||
#define KEY_CAPS_LOCK 0x39
|
|
||||||
#define KEY_SCROLL_LOCK 0x47
|
|
||||||
|
|
||||||
class KeyboardReportParser : public HIDReportParser {
|
class KeyboardReportParser : public HIDReportParser {
|
||||||
static const uint8_t numKeys[];
|
static const uint8_t numKeys[];
|
||||||
static const uint8_t symKeysUp[];
|
static const uint8_t symKeysUp[];
|
||||||
|
|
|
@ -1073,8 +1073,8 @@ void ReportDescParserBase::PrintItemTitle(uint8_t prefix) {
|
||||||
|
|
||||||
uint8_t ReportDescParserBase::ParseItem(uint8_t **pp, uint16_t *pcntdn) {
|
uint8_t ReportDescParserBase::ParseItem(uint8_t **pp, uint16_t *pcntdn) {
|
||||||
//uint8_t ret = enErrorSuccess;
|
//uint8_t ret = enErrorSuccess;
|
||||||
|
//reinterpret_cast<>(varBuffer);
|
||||||
switch (itemParseState) {
|
switch (itemParseState) {
|
||||||
case 0:
|
case 0:
|
||||||
if (**pp == HID_LONG_ITEM_PREFIX)
|
if (**pp == HID_LONG_ITEM_PREFIX)
|
||||||
USBTRACE("\r\nLONG\r\n");
|
USBTRACE("\r\nLONG\r\n");
|
||||||
|
@ -1113,9 +1113,10 @@ uint8_t ReportDescParserBase::ParseItem(uint8_t **pp, uint16_t *pcntdn) {
|
||||||
switch (itemPrefix & (TYPE_MASK | TAG_MASK)) {
|
switch (itemPrefix & (TYPE_MASK | TAG_MASK)) {
|
||||||
case (TYPE_LOCAL | TAG_LOCAL_USAGE):
|
case (TYPE_LOCAL | TAG_LOCAL_USAGE):
|
||||||
if (pfUsage) {
|
if (pfUsage) {
|
||||||
if (theBuffer.valueSize > 1)
|
if (theBuffer.valueSize > 1) {
|
||||||
pfUsage(*((uint16_t*)varBuffer));
|
uint16_t* ui16 = reinterpret_cast<uint16_t *>(varBuffer);
|
||||||
else
|
pfUsage(*ui16);
|
||||||
|
} else
|
||||||
pfUsage(data);
|
pfUsage(data);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -1237,16 +1238,19 @@ void ReportDescParserBase::SetUsagePage(uint16_t page) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void ReportDescParserBase::PrintUsagePage(uint16_t page) {
|
void ReportDescParserBase::PrintUsagePage(uint16_t page) {
|
||||||
|
const char * const * w;
|
||||||
E_Notify(pstrSpace, 0x80);
|
E_Notify(pstrSpace, 0x80);
|
||||||
|
|
||||||
if (page > 0x00 && page < 0x11)
|
if (page > 0x00 && page < 0x11)
|
||||||
E_Notify((char*)pgm_read_pointer(&usagePageTitles0[page - 1]), 0x80);
|
//E_Notify((char*)pgm_read_pointer(&usagePageTitles0[page - 1]), 0x80);
|
||||||
|
output_pgm_message(w, E_Notify, usagePageTitles0[page - 1], 0x80);
|
||||||
else if (page > 0x7f && page < 0x84)
|
else if (page > 0x7f && page < 0x84)
|
||||||
E_Notify(pstrUsagePageMonitor, 0x80);
|
E_Notify(pstrUsagePageMonitor, 0x80);
|
||||||
else if (page > 0x83 && page < 0x8c)
|
else if (page > 0x83 && page < 0x8c)
|
||||||
E_Notify(pstrUsagePagePower, 0x80);
|
E_Notify(pstrUsagePagePower, 0x80);
|
||||||
else if (page > 0x8b && page < 0x92)
|
else if (page > 0x8b && page < 0x92)
|
||||||
E_Notify((char*)pgm_read_pointer(&usagePageTitles1[page - 0x8c]), 0x80);
|
//E_Notify((char*)pgm_read_pointer(&usagePageTitles1[page - 0x8c]), 0x80);
|
||||||
|
output_pgm_message(w, E_Notify, usagePageTitles1[page - 0x8c], 0x80);
|
||||||
else if (page > 0xfeff && page <= 0xffff)
|
else if (page > 0xfeff && page <= 0xffff)
|
||||||
E_Notify(pstrUsagePageVendorDefined, 0x80);
|
E_Notify(pstrUsagePageVendorDefined, 0x80);
|
||||||
else
|
else
|
||||||
|
@ -1280,187 +1284,248 @@ void ReportDescParserBase::PrintOrdinalPageUsage(uint16_t usage) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void ReportDescParserBase::PrintGenericDesktopPageUsage(uint16_t usage) {
|
void ReportDescParserBase::PrintGenericDesktopPageUsage(uint16_t usage) {
|
||||||
|
const char * const * w;
|
||||||
E_Notify(pstrSpace, 0x80);
|
E_Notify(pstrSpace, 0x80);
|
||||||
|
|
||||||
if (usage > 0x00 && usage < 0x0a)
|
if (usage > 0x00 && usage < 0x0a)
|
||||||
E_Notify((char*)pgm_read_pointer(&genDesktopTitles0[usage - 1]), 0x80);
|
//E_Notify((char*)pgm_read_pointer(&genDesktopTitles0[usage - 1]), 0x80);
|
||||||
|
output_pgm_message(w, E_Notify, genDesktopTitles0[usage - 1], 0x80);
|
||||||
else if (usage > 0x2f && usage < 0x49)
|
else if (usage > 0x2f && usage < 0x49)
|
||||||
E_Notify((char*)pgm_read_pointer(&genDesktopTitles1[usage - 0x30]), 0x80);
|
//E_Notify((char*)pgm_read_pointer(&genDesktopTitles1[usage - 0x30]), 0x80);
|
||||||
|
output_pgm_message(w, E_Notify, genDesktopTitles1[usage - 0x30], 0x80);
|
||||||
else if (usage > 0x7f && usage < 0x94)
|
else if (usage > 0x7f && usage < 0x94)
|
||||||
E_Notify((char*)pgm_read_pointer(&genDesktopTitles2[usage - 0x80]), 0x80);
|
//E_Notify((char*)pgm_read_pointer(&genDesktopTitles2[usage - 0x80]), 0x80);
|
||||||
|
output_pgm_message(w, E_Notify, genDesktopTitles2[usage - 0x80], 0x80);
|
||||||
else if (usage > 0x9f && usage < 0xa9)
|
else if (usage > 0x9f && usage < 0xa9)
|
||||||
E_Notify((char*)pgm_read_pointer(&genDesktopTitles3[usage - 0xa0]), 0x80);
|
//E_Notify((char*)pgm_read_pointer(&genDesktopTitles3[usage - 0xa0]), 0x80);
|
||||||
|
output_pgm_message(w, E_Notify, genDesktopTitles3[usage - 0xa0], 0x80);
|
||||||
else if (usage > 0xaf && usage < 0xb8)
|
else if (usage > 0xaf && usage < 0xb8)
|
||||||
E_Notify((char*)pgm_read_pointer(&genDesktopTitles4[usage - 0xb0]), 0x80);
|
//E_Notify((char*)pgm_read_pointer(&genDesktopTitles4[usage - 0xb0]), 0x80);
|
||||||
|
output_pgm_message(w, E_Notify, genDesktopTitles4[usage - 0xb0], 0x80);
|
||||||
else
|
else
|
||||||
E_Notify(pstrUsagePageUndefined, 0x80);
|
E_Notify(pstrUsagePageUndefined, 0x80);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ReportDescParserBase::PrintSimulationControlsPageUsage(uint16_t usage) {
|
void ReportDescParserBase::PrintSimulationControlsPageUsage(uint16_t usage) {
|
||||||
|
const char * const * w;
|
||||||
E_Notify(pstrSpace, 0x80);
|
E_Notify(pstrSpace, 0x80);
|
||||||
|
|
||||||
if (usage > 0x00 && usage < 0x0d)
|
if (usage > 0x00 && usage < 0x0d)
|
||||||
E_Notify((char*)pgm_read_pointer(&simuTitles0[usage - 1]), 0x80);
|
//E_Notify((char*)pgm_read_pointer(&simuTitles0[usage - 1]), 0x80);
|
||||||
|
output_pgm_message(w, E_Notify, simuTitles0[usage - 1], 0x80);
|
||||||
else if (usage > 0x1f && usage < 0x26)
|
else if (usage > 0x1f && usage < 0x26)
|
||||||
E_Notify((char*)pgm_read_pointer(&simuTitles1[usage - 0x20]), 0x80);
|
//E_Notify((char*)pgm_read_pointer(&simuTitles1[usage - 0x20]), 0x80);
|
||||||
|
output_pgm_message(w, E_Notify, simuTitles1[usage - 0x20], 0x80);
|
||||||
else if (usage > 0xaf && usage < 0xd1)
|
else if (usage > 0xaf && usage < 0xd1)
|
||||||
E_Notify((char*)pgm_read_pointer(&simuTitles2[usage - 0xb0]), 0x80);
|
//E_Notify((char*)pgm_read_pointer(&simuTitles2[usage - 0xb0]), 0x80);
|
||||||
|
output_pgm_message(w, E_Notify, simuTitles2[usage - 0xb0], 0x80);
|
||||||
else
|
else
|
||||||
E_Notify(pstrUsagePageUndefined, 0x80);
|
E_Notify(pstrUsagePageUndefined, 0x80);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ReportDescParserBase::PrintVRControlsPageUsage(uint16_t usage) {
|
void ReportDescParserBase::PrintVRControlsPageUsage(uint16_t usage) {
|
||||||
|
const char * const * w;
|
||||||
E_Notify(pstrSpace, 0x80);
|
E_Notify(pstrSpace, 0x80);
|
||||||
|
|
||||||
if (usage > 0x00 && usage < 0x0b)
|
if (usage > 0x00 && usage < 0x0b)
|
||||||
E_Notify((char*)pgm_read_pointer(&vrTitles0[usage - 1]), 0x80);
|
//E_Notify((char*)pgm_read_pointer(&vrTitles0[usage - 1]), 0x80);
|
||||||
|
output_pgm_message(w, E_Notify, vrTitles0[usage - 1], 0x80);
|
||||||
else if (usage > 0x1f && usage < 0x22)
|
else if (usage > 0x1f && usage < 0x22)
|
||||||
E_Notify((char*)pgm_read_pointer(&vrTitles1[usage - 0x20]), 0x80);
|
//E_Notify((char*)pgm_read_pointer(&vrTitles1[usage - 0x20]), 0x80);
|
||||||
|
output_pgm_message(w, E_Notify, vrTitles1[usage - 0x20], 0x80);
|
||||||
else
|
else
|
||||||
E_Notify(pstrUsagePageUndefined, 0x80);
|
E_Notify(pstrUsagePageUndefined, 0x80);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ReportDescParserBase::PrintSportsControlsPageUsage(uint16_t usage) {
|
void ReportDescParserBase::PrintSportsControlsPageUsage(uint16_t usage) {
|
||||||
|
const char * const * w;
|
||||||
E_Notify(pstrSpace, 0x80);
|
E_Notify(pstrSpace, 0x80);
|
||||||
|
|
||||||
if (usage > 0x00 && usage < 0x05)
|
if (usage > 0x00 && usage < 0x05)
|
||||||
E_Notify((char*)pgm_read_pointer(&sportsCtrlTitles0[usage - 1]), 0x80);
|
//E_Notify((char*)pgm_read_pointer(&sportsCtrlTitles0[usage - 1]), 0x80);
|
||||||
|
output_pgm_message(w, E_Notify, sportsCtrlTitles0[usage - 1], 0x80);
|
||||||
else if (usage > 0x2f && usage < 0x3a)
|
else if (usage > 0x2f && usage < 0x3a)
|
||||||
E_Notify((char*)pgm_read_pointer(&sportsCtrlTitles1[usage - 0x30]), 0x80);
|
//E_Notify((char*)pgm_read_pointer(&sportsCtrlTitles1[usage - 0x30]), 0x80);
|
||||||
|
output_pgm_message(w, E_Notify, sportsCtrlTitles1[usage - 0x30], 0x80);
|
||||||
else if (usage > 0x4f && usage < 0x64)
|
else if (usage > 0x4f && usage < 0x64)
|
||||||
E_Notify((char*)pgm_read_pointer(&sportsCtrlTitles2[usage - 0x50]), 0x80);
|
//E_Notify((char*)pgm_read_pointer(&sportsCtrlTitles2[usage - 0x50]), 0x80);
|
||||||
|
output_pgm_message(w, E_Notify, sportsCtrlTitles2[usage - 0x50], 0x80);
|
||||||
else
|
else
|
||||||
E_Notify(pstrUsagePageUndefined, 0x80);
|
E_Notify(pstrUsagePageUndefined, 0x80);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ReportDescParserBase::PrintGameControlsPageUsage(uint16_t usage) {
|
void ReportDescParserBase::PrintGameControlsPageUsage(uint16_t usage) {
|
||||||
|
const char * const * w;
|
||||||
E_Notify(pstrSpace, 0x80);
|
E_Notify(pstrSpace, 0x80);
|
||||||
|
|
||||||
if (usage > 0x00 && usage < 0x04)
|
if (usage > 0x00 && usage < 0x04)
|
||||||
E_Notify((char*)pgm_read_pointer(&gameTitles0[usage - 1]), 0x80);
|
//E_Notify((char*)pgm_read_pointer(&gameTitles0[usage - 1]), 0x80);
|
||||||
|
output_pgm_message(w, E_Notify, gameTitles0[usage - 1], 0x80);
|
||||||
else if (usage > 0x1f && usage < 0x3a)
|
else if (usage > 0x1f && usage < 0x3a)
|
||||||
E_Notify((char*)pgm_read_pointer(&gameTitles1[usage - 0x20]), 0x80);
|
//E_Notify((char*)pgm_read_pointer(&gameTitles1[usage - 0x20]), 0x80);
|
||||||
|
output_pgm_message(w, E_Notify, gameTitles1[usage - 0x20], 0x80);
|
||||||
else
|
else
|
||||||
E_Notify(pstrUsagePageUndefined, 0x80);
|
E_Notify(pstrUsagePageUndefined, 0x80);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ReportDescParserBase::PrintGenericDeviceControlsPageUsage(uint16_t usage) {
|
void ReportDescParserBase::PrintGenericDeviceControlsPageUsage(uint16_t usage) {
|
||||||
|
const char * const * w;
|
||||||
E_Notify(pstrSpace, 0x80);
|
E_Notify(pstrSpace, 0x80);
|
||||||
|
|
||||||
if (usage > 0x1f && usage < 0x27)
|
if (usage > 0x1f && usage < 0x27)
|
||||||
E_Notify((char*)pgm_read_pointer(&genDevCtrlTitles[usage - 0x20]), 0x80);
|
//E_Notify((char*)pgm_read_pointer(&genDevCtrlTitles[usage - 0x20]), 0x80);
|
||||||
|
output_pgm_message(w, E_Notify, genDevCtrlTitles[usage - 0x20], 0x80);
|
||||||
else
|
else
|
||||||
E_Notify(pstrUsagePageUndefined, 0x80);
|
E_Notify(pstrUsagePageUndefined, 0x80);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ReportDescParserBase::PrintLEDPageUsage(uint16_t usage) {
|
void ReportDescParserBase::PrintLEDPageUsage(uint16_t usage) {
|
||||||
|
const char * const * w;
|
||||||
E_Notify(pstrSpace, 0x80);
|
E_Notify(pstrSpace, 0x80);
|
||||||
|
|
||||||
if (usage > 0x00 && usage < 0x4e)
|
if (usage > 0x00 && usage < 0x4e)
|
||||||
E_Notify((char*)pgm_read_pointer(&ledTitles[usage - 1]), 0x80);
|
//E_Notify((char*)pgm_read_pointer(&ledTitles[usage - 1]), 0x80);
|
||||||
|
output_pgm_message(w, E_Notify, ledTitles[usage - 1], 0x80);
|
||||||
else
|
else
|
||||||
E_Notify(pstrUsagePageUndefined, 0x80);
|
E_Notify(pstrUsagePageUndefined, 0x80);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ReportDescParserBase::PrintTelephonyPageUsage(uint16_t usage) {
|
void ReportDescParserBase::PrintTelephonyPageUsage(uint16_t usage) {
|
||||||
|
const char * const * w;
|
||||||
E_Notify(pstrSpace, 0x80);
|
E_Notify(pstrSpace, 0x80);
|
||||||
|
|
||||||
if (usage > 0x00 && usage < 0x08)
|
if (usage > 0x00 && usage < 0x08)
|
||||||
E_Notify((char*)pgm_read_pointer(&telTitles0[usage - 1]), 0x80);
|
//E_Notify((char*)pgm_read_pointer(&telTitles0[usage - 1]), 0x80);
|
||||||
|
output_pgm_message(w, E_Notify, telTitles0[usage - 1], 0x80);
|
||||||
else if (usage > 0x1f && usage < 0x32)
|
else if (usage > 0x1f && usage < 0x32)
|
||||||
E_Notify((char*)pgm_read_pointer(&telTitles1[usage - 0x1f]), 0x80);
|
//E_Notify((char*)pgm_read_pointer(&telTitles1[usage - 0x1f]), 0x80);
|
||||||
|
output_pgm_message(w, E_Notify, telTitles1[usage - 0x1f], 0x80);
|
||||||
else if (usage > 0x4f && usage < 0x54)
|
else if (usage > 0x4f && usage < 0x54)
|
||||||
E_Notify((char*)pgm_read_pointer(&telTitles2[usage - 0x4f]), 0x80);
|
//E_Notify((char*)pgm_read_pointer(&telTitles2[usage - 0x4f]), 0x80);
|
||||||
|
output_pgm_message(w, E_Notify, telTitles2[usage - 0x4f], 0x80);
|
||||||
else if (usage > 0x6f && usage < 0x75)
|
else if (usage > 0x6f && usage < 0x75)
|
||||||
E_Notify((char*)pgm_read_pointer(&telTitles3[usage - 0x6f]), 0x80);
|
//E_Notify((char*)pgm_read_pointer(&telTitles3[usage - 0x6f]), 0x80);
|
||||||
|
output_pgm_message(w, E_Notify, telTitles3[usage - 0x6f], 0x80);
|
||||||
else if (usage > 0x8f && usage < 0x9f)
|
else if (usage > 0x8f && usage < 0x9f)
|
||||||
E_Notify((char*)pgm_read_pointer(&telTitles4[usage - 0x8f]), 0x80);
|
//E_Notify((char*)pgm_read_pointer(&telTitles4[usage - 0x8f]), 0x80);
|
||||||
|
output_pgm_message(w, E_Notify, telTitles4[usage - 0x8f], 0x80);
|
||||||
else if (usage > 0xaf && usage < 0xc0)
|
else if (usage > 0xaf && usage < 0xc0)
|
||||||
E_Notify((char*)pgm_read_pointer(&telTitles5[usage - 0xaf]), 0x80);
|
//E_Notify((char*)pgm_read_pointer(&telTitles5[usage - 0xaf]), 0x80);
|
||||||
|
output_pgm_message(w, E_Notify, telTitles5[usage - 0xaf], 0x80);
|
||||||
else
|
else
|
||||||
E_Notify(pstrUsagePageUndefined, 0x80);
|
E_Notify(pstrUsagePageUndefined, 0x80);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ReportDescParserBase::PrintConsumerPageUsage(uint16_t usage) {
|
void ReportDescParserBase::PrintConsumerPageUsage(uint16_t usage) {
|
||||||
|
const char * const * w;
|
||||||
E_Notify(pstrSpace, 0x80);
|
E_Notify(pstrSpace, 0x80);
|
||||||
|
|
||||||
if (usage > 0x00 && usage < 0x07)
|
if (usage > 0x00 && usage < 0x07)
|
||||||
E_Notify((char*)pgm_read_pointer(&consTitles0[usage - 1]), 0x80);
|
//E_Notify((char*)pgm_read_pointer(&consTitles0[usage - 1]), 0x80);
|
||||||
|
output_pgm_message(w, E_Notify, consTitles0[usage - 1], 0x80);
|
||||||
else if (usage > 0x1f && usage < 0x23)
|
else if (usage > 0x1f && usage < 0x23)
|
||||||
E_Notify((char*)pgm_read_pointer(&consTitles1[usage - 0x1f]), 0x80);
|
//E_Notify((char*)pgm_read_pointer(&consTitles1[usage - 0x1f]), 0x80);
|
||||||
|
output_pgm_message(w, E_Notify, consTitles1[usage - 0x1f], 0x80);
|
||||||
else if (usage > 0x2f && usage < 0x37)
|
else if (usage > 0x2f && usage < 0x37)
|
||||||
E_Notify((char*)pgm_read_pointer(&consTitles2[usage - 0x2f]), 0x80);
|
//E_Notify((char*)pgm_read_pointer(&consTitles2[usage - 0x2f]), 0x80);
|
||||||
|
output_pgm_message(w, E_Notify, consTitles2[usage - 0x2f], 0x80);
|
||||||
else if (usage > 0x3f && usage < 0x49)
|
else if (usage > 0x3f && usage < 0x49)
|
||||||
E_Notify((char*)pgm_read_pointer(&consTitles3[usage - 0x3f]), 0x80);
|
//E_Notify((char*)pgm_read_pointer(&consTitles3[usage - 0x3f]), 0x80);
|
||||||
|
output_pgm_message(w, E_Notify, consTitles3[usage - 0x3f], 0x80);
|
||||||
else if (usage > 0x5f && usage < 0x67)
|
else if (usage > 0x5f && usage < 0x67)
|
||||||
E_Notify((char*)pgm_read_pointer(&consTitles4[usage - 0x5f]), 0x80);
|
//E_Notify((char*)pgm_read_pointer(&consTitles4[usage - 0x5f]), 0x80);
|
||||||
|
output_pgm_message(w, E_Notify, consTitles4[usage - 0x5f], 0x80);
|
||||||
else if (usage > 0x7f && usage < 0xa5)
|
else if (usage > 0x7f && usage < 0xa5)
|
||||||
E_Notify((char*)pgm_read_pointer(&consTitles5[usage - 0x7f]), 0x80);
|
//E_Notify((char*)pgm_read_pointer(&consTitles5[usage - 0x7f]), 0x80);
|
||||||
|
output_pgm_message(w, E_Notify, consTitles5[usage - 0x7f], 0x80);
|
||||||
else if (usage > 0xaf && usage < 0xcf)
|
else if (usage > 0xaf && usage < 0xcf)
|
||||||
E_Notify((char*)pgm_read_pointer(&consTitles6[usage - 0xaf]), 0x80);
|
//E_Notify((char*)pgm_read_pointer(&consTitles6[usage - 0xaf]), 0x80);
|
||||||
|
output_pgm_message(w, E_Notify, consTitles6[usage - 0xaf], 0x80);
|
||||||
else if (usage > 0xdf && usage < 0xeb)
|
else if (usage > 0xdf && usage < 0xeb)
|
||||||
E_Notify((char*)pgm_read_pointer(&consTitles7[usage - 0xdf]), 0x80);
|
//E_Notify((char*)pgm_read_pointer(&consTitles7[usage - 0xdf]), 0x80);
|
||||||
|
output_pgm_message(w, E_Notify, consTitles7[usage - 0xdf], 0x80);
|
||||||
else if (usage > 0xef && usage < 0xf6)
|
else if (usage > 0xef && usage < 0xf6)
|
||||||
E_Notify((char*)pgm_read_pointer(&consTitles8[usage - 0xef]), 0x80);
|
//E_Notify((char*)pgm_read_pointer(&consTitles8[usage - 0xef]), 0x80);
|
||||||
|
output_pgm_message(w, E_Notify, consTitles8[usage - 0xef], 0x80);
|
||||||
else if (usage > 0xff && usage < 0x10e)
|
else if (usage > 0xff && usage < 0x10e)
|
||||||
E_Notify((char*)pgm_read_pointer(&consTitles9[usage - 0xff]), 0x80);
|
//E_Notify((char*)pgm_read_pointer(&consTitles9[usage - 0xff]), 0x80);
|
||||||
|
output_pgm_message(w, E_Notify, consTitles9[usage - 0xff], 0x80);
|
||||||
else if (usage > 0x14f && usage < 0x156)
|
else if (usage > 0x14f && usage < 0x156)
|
||||||
E_Notify((char*)pgm_read_pointer(&consTitlesA[usage - 0x14f]), 0x80);
|
//E_Notify((char*)pgm_read_pointer(&consTitlesA[usage - 0x14f]), 0x80);
|
||||||
|
output_pgm_message(w, E_Notify, consTitlesA[usage - 0x14f], 0x80);
|
||||||
else if (usage > 0x15f && usage < 0x16b)
|
else if (usage > 0x15f && usage < 0x16b)
|
||||||
E_Notify((char*)pgm_read_pointer(&consTitlesB[usage - 0x15f]), 0x80);
|
//E_Notify((char*)pgm_read_pointer(&consTitlesB[usage - 0x15f]), 0x80);
|
||||||
|
output_pgm_message(w, E_Notify, consTitlesB[usage - 0x15f], 0x80);
|
||||||
else if (usage > 0x16f && usage < 0x175)
|
else if (usage > 0x16f && usage < 0x175)
|
||||||
E_Notify((char*)pgm_read_pointer(&consTitlesC[usage - 0x16f]), 0x80);
|
//E_Notify((char*)pgm_read_pointer(&consTitlesC[usage - 0x16f]), 0x80);
|
||||||
|
output_pgm_message(w, E_Notify, consTitlesC[usage - 0x16f], 0x80);
|
||||||
else if (usage > 0x17f && usage < 0x1c8)
|
else if (usage > 0x17f && usage < 0x1c8)
|
||||||
E_Notify((char*)pgm_read_pointer(&consTitlesD[usage - 0x17f]), 0x80);
|
//E_Notify((char*)pgm_read_pointer(&consTitlesD[usage - 0x17f]), 0x80);
|
||||||
|
output_pgm_message(w, E_Notify, consTitlesD[usage - 0x17f], 0x80);
|
||||||
else if (usage > 0x1ff && usage < 0x29d)
|
else if (usage > 0x1ff && usage < 0x29d)
|
||||||
E_Notify((char*)pgm_read_pointer(&consTitlesE[usage - 0x1ff]), 0x80);
|
//E_Notify((char*)pgm_read_pointer(&consTitlesE[usage - 0x1ff]), 0x80);
|
||||||
|
output_pgm_message(w, E_Notify, consTitlesE[usage - 0x1ff], 0x80);
|
||||||
else
|
else
|
||||||
E_Notify(pstrUsagePageUndefined, 0x80);
|
E_Notify(pstrUsagePageUndefined, 0x80);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ReportDescParserBase::PrintDigitizerPageUsage(uint16_t usage) {
|
void ReportDescParserBase::PrintDigitizerPageUsage(uint16_t usage) {
|
||||||
|
const char * const * w;
|
||||||
E_Notify(pstrSpace, 0x80);
|
E_Notify(pstrSpace, 0x80);
|
||||||
|
|
||||||
if (usage > 0x00 && usage < 0x0e)
|
if (usage > 0x00 && usage < 0x0e)
|
||||||
E_Notify((char*)pgm_read_pointer(&digitTitles0[usage - 1]), 0x80);
|
//E_Notify((char*)pgm_read_pointer(&digitTitles0[usage - 1]), 0x80);
|
||||||
|
output_pgm_message(w, E_Notify, digitTitles0[usage - 1], 0x80);
|
||||||
else if (usage > 0x1f && usage < 0x23)
|
else if (usage > 0x1f && usage < 0x23)
|
||||||
E_Notify((char*)pgm_read_pointer(&digitTitles1[usage - 0x1f]), 0x80);
|
//E_Notify((char*)pgm_read_pointer(&digitTitles1[usage - 0x1f]), 0x80);
|
||||||
|
output_pgm_message(w, E_Notify, digitTitles1[usage - 0x1f], 0x80);
|
||||||
else if (usage > 0x2f && usage < 0x47)
|
else if (usage > 0x2f && usage < 0x47)
|
||||||
E_Notify((char*)pgm_read_pointer(&digitTitles2[usage - 0x2f]), 0x80);
|
//E_Notify((char*)pgm_read_pointer(&digitTitles2[usage - 0x2f]), 0x80);
|
||||||
|
output_pgm_message(w, E_Notify, digitTitles2[usage - 0x2f], 0x80);
|
||||||
else
|
else
|
||||||
E_Notify(pstrUsagePageUndefined, 0x80);
|
E_Notify(pstrUsagePageUndefined, 0x80);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ReportDescParserBase::PrintAlphanumDisplayPageUsage(uint16_t usage) {
|
void ReportDescParserBase::PrintAlphanumDisplayPageUsage(uint16_t usage) {
|
||||||
|
const char * const * w;
|
||||||
E_Notify(pstrSpace, 0x80);
|
E_Notify(pstrSpace, 0x80);
|
||||||
|
|
||||||
if (usage > 0x00 && usage < 0x03)
|
if (usage > 0x00 && usage < 0x03)
|
||||||
E_Notify((char*)pgm_read_pointer(&aplphanumTitles0[usage - 1]), 0x80);
|
//E_Notify((char*)pgm_read_pointer(&aplphanumTitles0[usage - 1]), 0x80);
|
||||||
|
output_pgm_message(w, E_Notify, aplphanumTitles0[usage - 1], 0x80);
|
||||||
else if (usage > 0x1f && usage < 0x4e)
|
else if (usage > 0x1f && usage < 0x4e)
|
||||||
E_Notify((char*)pgm_read_pointer(&aplphanumTitles1[usage - 0x1f]), 0x80);
|
//E_Notify((char*)pgm_read_pointer(&aplphanumTitles1[usage - 0x1f]), 0x80);
|
||||||
|
output_pgm_message(w, E_Notify, aplphanumTitles1[usage - 0x1f], 0x80);
|
||||||
else if (usage > 0x7f && usage < 0x96)
|
else if (usage > 0x7f && usage < 0x96)
|
||||||
E_Notify((char*)pgm_read_pointer(&digitTitles2[usage - 0x80]), 0x80);
|
//E_Notify((char*)pgm_read_pointer(&digitTitles2[usage - 0x80]), 0x80);
|
||||||
|
output_pgm_message(w, E_Notify, digitTitles2[usage - 0x80], 0x80);
|
||||||
else
|
else
|
||||||
E_Notify(pstrUsagePageUndefined, 0x80);
|
E_Notify(pstrUsagePageUndefined, 0x80);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ReportDescParserBase::PrintMedicalInstrumentPageUsage(uint16_t usage) {
|
void ReportDescParserBase::PrintMedicalInstrumentPageUsage(uint16_t usage) {
|
||||||
|
const char * const * w;
|
||||||
E_Notify(pstrSpace, 0x80);
|
E_Notify(pstrSpace, 0x80);
|
||||||
|
//output_pgm_message(w, E_Notify, , 0x80);
|
||||||
if (usage == 1)
|
if (usage == 1)
|
||||||
E_Notify(pstrUsageMedicalUltrasound, 0x80);
|
E_Notify(pstrUsageMedicalUltrasound, 0x80);
|
||||||
else if (usage > 0x1f && usage < 0x28)
|
else if (usage > 0x1f && usage < 0x28)
|
||||||
E_Notify((char*)pgm_read_pointer(&medInstrTitles0[usage - 0x1f]), 0x80);
|
//E_Notify((char*)pgm_read_pointer(&medInstrTitles0[usage - 0x1f]), 0x80);
|
||||||
|
output_pgm_message(w, E_Notify, medInstrTitles0[usage - 0x1f], 0x80);
|
||||||
else if (usage > 0x3f && usage < 0x45)
|
else if (usage > 0x3f && usage < 0x45)
|
||||||
E_Notify((char*)pgm_read_pointer(&medInstrTitles1[usage - 0x40]), 0x80);
|
//E_Notify((char*)pgm_read_pointer(&medInstrTitles1[usage - 0x40]), 0x80);
|
||||||
|
output_pgm_message(w, E_Notify, medInstrTitles1[usage - 0x40], 0x80);
|
||||||
else if (usage > 0x5f && usage < 0x62)
|
else if (usage > 0x5f && usage < 0x62)
|
||||||
E_Notify((char*)pgm_read_pointer(&medInstrTitles2[usage - 0x60]), 0x80);
|
//E_Notify((char*)pgm_read_pointer(&medInstrTitles2[usage - 0x60]), 0x80);
|
||||||
|
output_pgm_message(w, E_Notify, medInstrTitles2[usage - 0x60], 0x80);
|
||||||
else if (usage == 0x70)
|
else if (usage == 0x70)
|
||||||
E_Notify(pstrUsageDepthGainCompensation, 0x80);
|
E_Notify(pstrUsageDepthGainCompensation, 0x80);
|
||||||
else if (usage > 0x7f && usage < 0x8a)
|
else if (usage > 0x7f && usage < 0x8a)
|
||||||
E_Notify((char*)pgm_read_pointer(&medInstrTitles3[usage - 0x80]), 0x80);
|
//E_Notify((char*)pgm_read_pointer(&medInstrTitles3[usage - 0x80]), 0x80);
|
||||||
|
output_pgm_message(w, E_Notify, medInstrTitles3[usage - 0x80], 0x80);
|
||||||
else if (usage > 0x9f && usage < 0xa2)
|
else if (usage > 0x9f && usage < 0xa2)
|
||||||
E_Notify((char*)pgm_read_pointer(&medInstrTitles4[usage - 0xa0]), 0x80);
|
// E_Notify((char*)pgm_read_pointer(&medInstrTitles4[usage - 0xa0]), 0x80);
|
||||||
|
output_pgm_message(w, E_Notify, medInstrTitles4[usage - 0xa0], 0x80);
|
||||||
else
|
else
|
||||||
E_Notify(pstrUsagePageUndefined, 0x80);
|
E_Notify(pstrUsagePageUndefined, 0x80);
|
||||||
}
|
}
|
||||||
|
@ -1502,9 +1567,10 @@ uint8_t ReportDescParser2::ParseItem(uint8_t **pp, uint16_t *pcntdn) {
|
||||||
switch (itemPrefix & (TYPE_MASK | TAG_MASK)) {
|
switch (itemPrefix & (TYPE_MASK | TAG_MASK)) {
|
||||||
case (TYPE_LOCAL | TAG_LOCAL_USAGE):
|
case (TYPE_LOCAL | TAG_LOCAL_USAGE):
|
||||||
if (pfUsage) {
|
if (pfUsage) {
|
||||||
if (theBuffer.valueSize > 1)
|
if (theBuffer.valueSize > 1) {
|
||||||
pfUsage(*((uint16_t*)varBuffer));
|
uint16_t* ui16 = reinterpret_cast<uint16_t *>(varBuffer);
|
||||||
else
|
pfUsage(*ui16);
|
||||||
|
} else
|
||||||
pfUsage(data);
|
pfUsage(data);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -126,7 +126,8 @@ public:
|
||||||
itemPrefix(0),
|
itemPrefix(0),
|
||||||
rptSize(0),
|
rptSize(0),
|
||||||
rptCount(0),
|
rptCount(0),
|
||||||
pfUsage(NULL) {
|
pfUsage(NULL)
|
||||||
|
{
|
||||||
theBuffer.pValue = varBuffer;
|
theBuffer.pValue = varBuffer;
|
||||||
valParser.Initialize(&theBuffer);
|
valParser.Initialize(&theBuffer);
|
||||||
theSkipper.Initialize(&theBuffer);
|
theSkipper.Initialize(&theBuffer);
|
||||||
|
|
|
@ -77,6 +77,7 @@ uint8_t HIDUniversal::Init(uint8_t parent, uint8_t port, bool lowspeed) {
|
||||||
const uint8_t constBufSize = sizeof (USB_DEVICE_DESCRIPTOR);
|
const uint8_t constBufSize = sizeof (USB_DEVICE_DESCRIPTOR);
|
||||||
|
|
||||||
uint8_t buf[constBufSize];
|
uint8_t buf[constBufSize];
|
||||||
|
USB_DEVICE_DESCRIPTOR * udd = reinterpret_cast<USB_DEVICE_DESCRIPTOR*>(buf);
|
||||||
uint8_t rcode;
|
uint8_t rcode;
|
||||||
UsbDevice *p = NULL;
|
UsbDevice *p = NULL;
|
||||||
EpInfo *oldep_ptr = NULL;
|
EpInfo *oldep_ptr = NULL;
|
||||||
|
@ -134,7 +135,7 @@ uint8_t HIDUniversal::Init(uint8_t parent, uint8_t port, bool lowspeed) {
|
||||||
return USB_ERROR_OUT_OF_ADDRESS_SPACE_IN_POOL;
|
return USB_ERROR_OUT_OF_ADDRESS_SPACE_IN_POOL;
|
||||||
|
|
||||||
// Extract Max Packet Size from the device descriptor
|
// Extract Max Packet Size from the device descriptor
|
||||||
epInfo[0].maxPktSize = (uint8_t)((USB_DEVICE_DESCRIPTOR*)buf)->bMaxPacketSize0;
|
epInfo[0].maxPktSize = udd->bMaxPacketSize0;
|
||||||
|
|
||||||
// Assign new address to the device
|
// Assign new address to the device
|
||||||
rcode = pUsb->setAddr(0, 0, bAddress);
|
rcode = pUsb->setAddr(0, 0, bAddress);
|
||||||
|
@ -166,7 +167,7 @@ uint8_t HIDUniversal::Init(uint8_t parent, uint8_t port, bool lowspeed) {
|
||||||
if (rcode)
|
if (rcode)
|
||||||
goto FailGetDevDescr;
|
goto FailGetDevDescr;
|
||||||
|
|
||||||
num_of_conf = ((USB_DEVICE_DESCRIPTOR*)buf)->bNumConfigurations;
|
num_of_conf = udd->bNumConfigurations;
|
||||||
|
|
||||||
// Assign epInfo to epinfo pointer
|
// Assign epInfo to epinfo pointer
|
||||||
rcode = pUsb->setEpInfoEntry(bAddress, 1, epInfo);
|
rcode = pUsb->setEpInfoEntry(bAddress, 1, epInfo);
|
||||||
|
@ -252,8 +253,8 @@ FailSetIdle:
|
||||||
USBTRACE("SetIdle:");
|
USBTRACE("SetIdle:");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
Fail:
|
|
||||||
#ifdef DEBUG_USB_HOST
|
#ifdef DEBUG_USB_HOST
|
||||||
|
Fail:
|
||||||
NotifyFail(rcode);
|
NotifyFail(rcode);
|
||||||
#endif
|
#endif
|
||||||
Release();
|
Release();
|
||||||
|
|
|
@ -236,6 +236,7 @@ uint8_t BulkOnly::ConfigureDevice(uint8_t parent, uint8_t port, bool lowspeed) {
|
||||||
const uint8_t constBufSize = sizeof (USB_DEVICE_DESCRIPTOR);
|
const uint8_t constBufSize = sizeof (USB_DEVICE_DESCRIPTOR);
|
||||||
|
|
||||||
uint8_t buf[constBufSize];
|
uint8_t buf[constBufSize];
|
||||||
|
USB_DEVICE_DESCRIPTOR * udd = reinterpret_cast<USB_DEVICE_DESCRIPTOR*>(buf);
|
||||||
uint8_t rcode;
|
uint8_t rcode;
|
||||||
UsbDevice *p = NULL;
|
UsbDevice *p = NULL;
|
||||||
EpInfo *oldep_ptr = NULL;
|
EpInfo *oldep_ptr = NULL;
|
||||||
|
@ -282,9 +283,9 @@ uint8_t BulkOnly::ConfigureDevice(uint8_t parent, uint8_t port, bool lowspeed) {
|
||||||
return USB_ERROR_OUT_OF_ADDRESS_SPACE_IN_POOL;
|
return USB_ERROR_OUT_OF_ADDRESS_SPACE_IN_POOL;
|
||||||
|
|
||||||
// Extract Max Packet Size from the device descriptor
|
// Extract Max Packet Size from the device descriptor
|
||||||
epInfo[0].maxPktSize = (uint8_t)((USB_DEVICE_DESCRIPTOR*)buf)->bMaxPacketSize0;
|
epInfo[0].maxPktSize = udd->bMaxPacketSize0;
|
||||||
// Steal and abuse from epInfo structure to save on memory.
|
// Steal and abuse from epInfo structure to save on memory.
|
||||||
epInfo[1].epAddr = ((USB_DEVICE_DESCRIPTOR*)buf)->bNumConfigurations;
|
epInfo[1].epAddr = udd->bNumConfigurations;
|
||||||
// </TECHNICAL>
|
// </TECHNICAL>
|
||||||
return USB_ERROR_CONFIG_REQUIRES_ADDITIONAL_RESET;
|
return USB_ERROR_CONFIG_REQUIRES_ADDITIONAL_RESET;
|
||||||
|
|
||||||
|
@ -294,7 +295,6 @@ FailGetDevDescr:
|
||||||
#endif
|
#endif
|
||||||
rcode = USB_ERROR_FailGetDevDescr;
|
rcode = USB_ERROR_FailGetDevDescr;
|
||||||
|
|
||||||
Fail:
|
|
||||||
Release();
|
Release();
|
||||||
return rcode;
|
return rcode;
|
||||||
};
|
};
|
||||||
|
@ -436,7 +436,7 @@ uint8_t BulkOnly::Init(uint8_t parent, uint8_t port, bool lowspeed) {
|
||||||
printf(" standards.\r\n");
|
printf(" standards.\r\n");
|
||||||
#endif
|
#endif
|
||||||
uint8_t tries = 0xf0;
|
uint8_t tries = 0xf0;
|
||||||
while (rcode = TestUnitReady(lun)) {
|
while ((rcode = TestUnitReady(lun))) {
|
||||||
if (rcode == 0x08) break; // break on no media, this is OK to do.
|
if (rcode == 0x08) break; // break on no media, this is OK to do.
|
||||||
// try to lock media and spin up
|
// try to lock media and spin up
|
||||||
if (tries < 14) {
|
if (tries < 14) {
|
||||||
|
@ -489,8 +489,8 @@ FailGetMaxLUN:
|
||||||
goto Fail;
|
goto Fail;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
FailInvalidSectorSize:
|
|
||||||
#ifdef DEBUG_USB_HOST
|
#ifdef DEBUG_USB_HOST
|
||||||
|
FailInvalidSectorSize:
|
||||||
USBTRACE("Sector Size is NOT VALID: ");
|
USBTRACE("Sector Size is NOT VALID: ");
|
||||||
goto Fail;
|
goto Fail;
|
||||||
#endif
|
#endif
|
||||||
|
@ -506,8 +506,8 @@ FailGetConfDescr:
|
||||||
NotifyFailGetConfDescr();
|
NotifyFailGetConfDescr();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
Fail:
|
|
||||||
#ifdef DEBUG_USB_HOST
|
#ifdef DEBUG_USB_HOST
|
||||||
|
Fail:
|
||||||
NotifyFail(rcode);
|
NotifyFail(rcode);
|
||||||
#endif
|
#endif
|
||||||
Release();
|
Release();
|
||||||
|
@ -808,9 +808,8 @@ uint8_t BulkOnly::ClearEpHalt(uint8_t index) {
|
||||||
|
|
||||||
uint8_t ret = 0;
|
uint8_t ret = 0;
|
||||||
|
|
||||||
while (ret = (pUsb->ctrlReq(bAddress, 0, USB_SETUP_HOST_TO_DEVICE | USB_SETUP_TYPE_STANDARD | USB_SETUP_RECIPIENT_ENDPOINT,
|
while ((ret = (pUsb->ctrlReq(bAddress, 0, USB_SETUP_HOST_TO_DEVICE | USB_SETUP_TYPE_STANDARD | USB_SETUP_RECIPIENT_ENDPOINT, USB_REQUEST_CLEAR_FEATURE, USB_FEATURE_ENDPOINT_HALT, 0, ((index == epDataInIndex) ? (0x80 | epInfo[index].epAddr) : epInfo[index].epAddr), 0, 0, NULL, NULL)) == 0x01))
|
||||||
USB_REQUEST_CLEAR_FEATURE, USB_FEATURE_ENDPOINT_HALT, 0, ((index == epDataInIndex) ? (0x80 | epInfo[index].epAddr) : epInfo[index].epAddr), 0, 0, NULL, NULL))
|
delay(6);
|
||||||
== 0x01) delay(6);
|
|
||||||
|
|
||||||
if (ret) {
|
if (ret) {
|
||||||
ErrorMessage<uint8_t > (PSTR("ClearEpHalt"), ret);
|
ErrorMessage<uint8_t > (PSTR("ClearEpHalt"), ret);
|
||||||
|
|
|
@ -394,7 +394,7 @@ public:
|
||||||
bmCBWLUN(lu), bmReserved1(0), bmCBWCBLength(cmdlen), bmReserved2(0) {
|
bmCBWLUN(lu), bmReserved1(0), bmCBWCBLength(cmdlen), bmReserved2(0) {
|
||||||
for(int i = 0; i < 16; i++) CBWCB[i] = 0;
|
for(int i = 0; i < 16; i++) CBWCB[i] = 0;
|
||||||
// Type punning can cause optimization problems and bugs.
|
// Type punning can cause optimization problems and bugs.
|
||||||
// Using reinterpret_cast to a different object is the proper way to do this.
|
// Using reinterpret_cast to a dreinterpretifferent object is the proper way to do this.
|
||||||
//(((BASICCDB_t *) CBWCB)->LUN) = cmd;
|
//(((BASICCDB_t *) CBWCB)->LUN) = cmd;
|
||||||
BASICCDB_t *x = reinterpret_cast<BASICCDB_t *> (CBWCB);
|
BASICCDB_t *x = reinterpret_cast<BASICCDB_t *> (CBWCB);
|
||||||
x->LUN = cmd;
|
x->LUN = cmd;
|
||||||
|
|
|
@ -44,7 +44,7 @@ void E_NotifyStr(char const * msg, int lvl) {
|
||||||
if (!msg) return;
|
if (!msg) return;
|
||||||
char c;
|
char c;
|
||||||
|
|
||||||
while (c = *msg++) E_Notifyc(c, lvl);
|
while ((c = *msg++)) E_Notifyc(c, lvl);
|
||||||
}
|
}
|
||||||
|
|
||||||
void E_Notify(uint8_t b, int lvl) {
|
void E_Notify(uint8_t b, int lvl) {
|
||||||
|
|
13
usbhub.cpp
13
usbhub.cpp
|
@ -41,6 +41,9 @@ bPollEnable(false) {
|
||||||
|
|
||||||
uint8_t USBHub::Init(uint8_t parent, uint8_t port, bool lowspeed) {
|
uint8_t USBHub::Init(uint8_t parent, uint8_t port, bool lowspeed) {
|
||||||
uint8_t buf[32];
|
uint8_t buf[32];
|
||||||
|
USB_DEVICE_DESCRIPTOR * udd = reinterpret_cast<USB_DEVICE_DESCRIPTOR*>(buf);
|
||||||
|
HubDescriptor* hd = reinterpret_cast<HubDescriptor*>(buf);
|
||||||
|
USB_CONFIGURATION_DESCRIPTOR * ucd = reinterpret_cast<USB_CONFIGURATION_DESCRIPTOR*>(buf);
|
||||||
uint8_t rcode;
|
uint8_t rcode;
|
||||||
UsbDevice *p = NULL;
|
UsbDevice *p = NULL;
|
||||||
EpInfo *oldep_ptr = NULL;
|
EpInfo *oldep_ptr = NULL;
|
||||||
|
@ -90,17 +93,17 @@ uint8_t USBHub::Init(uint8_t parent, uint8_t port, bool lowspeed) {
|
||||||
|
|
||||||
// Extract device class from device descriptor
|
// Extract device class from device descriptor
|
||||||
// If device class is not a hub return
|
// If device class is not a hub return
|
||||||
if (((USB_DEVICE_DESCRIPTOR*)buf)->bDeviceClass != 0x09)
|
if (udd->bDeviceClass != 0x09)
|
||||||
return USB_DEV_CONFIG_ERROR_DEVICE_NOT_SUPPORTED;
|
return USB_DEV_CONFIG_ERROR_DEVICE_NOT_SUPPORTED;
|
||||||
|
|
||||||
// Allocate new address according to device class
|
// Allocate new address according to device class
|
||||||
bAddress = addrPool.AllocAddress(parent, (((USB_DEVICE_DESCRIPTOR*)buf)->bDeviceClass == 0x09) ? true : false, port);
|
bAddress = addrPool.AllocAddress(parent, (udd->bDeviceClass == 0x09) ? true : false, port);
|
||||||
|
|
||||||
if (!bAddress)
|
if (!bAddress)
|
||||||
return USB_ERROR_OUT_OF_ADDRESS_SPACE_IN_POOL;
|
return USB_ERROR_OUT_OF_ADDRESS_SPACE_IN_POOL;
|
||||||
|
|
||||||
// Extract Max Packet Size from the device descriptor
|
// Extract Max Packet Size from the device descriptor
|
||||||
epInfo[0].maxPktSize = ((USB_DEVICE_DESCRIPTOR*)buf)->bMaxPacketSize0;
|
epInfo[0].maxPktSize = udd->bMaxPacketSize0;
|
||||||
|
|
||||||
// Assign new address to the device
|
// Assign new address to the device
|
||||||
rcode = pUsb->setAddr(0, 0, bAddress);
|
rcode = pUsb->setAddr(0, 0, bAddress);
|
||||||
|
@ -140,7 +143,7 @@ uint8_t USBHub::Init(uint8_t parent, uint8_t port, bool lowspeed) {
|
||||||
goto FailGetHubDescr;
|
goto FailGetHubDescr;
|
||||||
|
|
||||||
// Save number of ports for future use
|
// Save number of ports for future use
|
||||||
bNbrPorts = ((HubDescriptor*)buf)->bNbrPorts;
|
bNbrPorts = hd->bNbrPorts;
|
||||||
|
|
||||||
// bInitState = 2;
|
// bInitState = 2;
|
||||||
|
|
||||||
|
@ -149,7 +152,7 @@ uint8_t USBHub::Init(uint8_t parent, uint8_t port, bool lowspeed) {
|
||||||
rcode = pUsb->getConfDescr(bAddress, 0, 8, 0, buf);
|
rcode = pUsb->getConfDescr(bAddress, 0, 8, 0, buf);
|
||||||
|
|
||||||
if (!rcode) {
|
if (!rcode) {
|
||||||
cd_len = ((USB_CONFIGURATION_DESCRIPTOR*)buf)->wTotalLength;
|
cd_len = ucd->wTotalLength;
|
||||||
rcode = pUsb->getConfDescr(bAddress, 0, cd_len, 0, buf);
|
rcode = pUsb->getConfDescr(bAddress, 0, cd_len, 0, buf);
|
||||||
}
|
}
|
||||||
if (rcode)
|
if (rcode)
|
||||||
|
|
Loading…
Reference in a new issue