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) {
|
||||
const uint8_t constBufSize = sizeof (USB_DEVICE_DESCRIPTOR);
|
||||
uint8_t buf[constBufSize];
|
||||
USB_DEVICE_DESCRIPTOR * udd = reinterpret_cast<USB_DEVICE_DESCRIPTOR*>(buf);
|
||||
uint8_t rcode;
|
||||
UsbDevice *p = 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;
|
||||
}
|
||||
|
||||
epInfo[0].maxPktSize = (uint8_t)((USB_DEVICE_DESCRIPTOR*)buf)->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[0].maxPktSize = udd->bMaxPacketSize0; // Extract Max Packet Size from device descriptor
|
||||
epInfo[1].epAddr = udd->bNumConfigurations; // Steal and abuse from epInfo structure to save memory
|
||||
|
||||
VID = ((USB_DEVICE_DESCRIPTOR*)buf)->idVendor;
|
||||
PID = ((USB_DEVICE_DESCRIPTOR*)buf)->idProduct;
|
||||
VID = udd->idVendor;
|
||||
PID = udd->idProduct;
|
||||
|
||||
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
|
||||
|
||||
/* diagnostic messages */
|
||||
FailGetDevDescr:
|
||||
#ifdef DEBUG_USB_HOST
|
||||
FailGetDevDescr:
|
||||
NotifyFailGetDevDescr();
|
||||
goto Fail;
|
||||
#endif
|
||||
|
|
4
BTD.h
4
BTD.h
|
@ -468,13 +468,13 @@ private:
|
|||
|
||||
uint16_t PID, VID; // PID and VID of device connected
|
||||
|
||||
bool bPollEnable;
|
||||
uint8_t pollInterval;
|
||||
bool bPollEnable;
|
||||
|
||||
/* Variables used by high level HCI task */
|
||||
uint8_t hci_state; //current state of bluetooth hci connection
|
||||
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
|
||||
uint8_t inquiry_counter;
|
||||
|
||||
|
|
22
PS3USB.cpp
22
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 buf[sizeof (USB_DEVICE_DESCRIPTOR)];
|
||||
USB_DEVICE_DESCRIPTOR * udd = reinterpret_cast<USB_DEVICE_DESCRIPTOR*>(buf);
|
||||
uint8_t rcode;
|
||||
UsbDevice *p = NULL;
|
||||
EpInfo *oldep_ptr = NULL;
|
||||
|
@ -97,8 +98,8 @@ uint8_t PS3USB::Init(uint8_t parent, uint8_t port, bool lowspeed) {
|
|||
if (rcode)
|
||||
goto FailGetDevDescr;
|
||||
|
||||
VID = ((USB_DEVICE_DESCRIPTOR*)buf)->idVendor;
|
||||
PID = ((USB_DEVICE_DESCRIPTOR*)buf)->idProduct;
|
||||
VID = udd->idVendor;
|
||||
PID = udd->idProduct;
|
||||
|
||||
if (VID != PS3_VID || (PID != PS3_PID && PID != PS3NAVIGATION_PID && PID != PS3MOVE_PID))
|
||||
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;
|
||||
|
||||
// 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
|
||||
rcode = pUsb->setAddr(0, 0, bAddress);
|
||||
|
@ -129,7 +130,7 @@ uint8_t PS3USB::Init(uint8_t parent, uint8_t port, bool lowspeed) {
|
|||
D_PrintHex<uint8_t > (bAddress, 0x80);
|
||||
#endif
|
||||
delay(300); // Spec says you should wait at least 200ms
|
||||
|
||||
|
||||
p->lowspeed = false;
|
||||
|
||||
//get pointer to assigned address record
|
||||
|
@ -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 ].bmNakPower = USB_NAK_NOWAIT; // Only poll once for interrupt endpoints
|
||||
epInfo[ PS3_OUTPUT_PIPE ].maxPktSize = EP_MAXPKTSIZE;
|
||||
epInfo[ PS3_OUTPUT_PIPE ].bmSndToggle = bmSNDTOG0;
|
||||
epInfo[ PS3_OUTPUT_PIPE ].bmRcvToggle = bmRCVTOG0;
|
||||
epInfo[ PS3_OUTPUT_PIPE ].bmSndToggle = 0;
|
||||
epInfo[ PS3_OUTPUT_PIPE ].bmRcvToggle = 0;
|
||||
epInfo[ PS3_INPUT_PIPE ].epAddr = 0x01; // PS3 report endpoint
|
||||
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 ].maxPktSize = EP_MAXPKTSIZE;
|
||||
epInfo[ PS3_INPUT_PIPE ].bmSndToggle = bmSNDTOG0;
|
||||
epInfo[ PS3_INPUT_PIPE ].bmRcvToggle = bmRCVTOG0;
|
||||
epInfo[ PS3_INPUT_PIPE ].bmSndToggle = 0;
|
||||
epInfo[ PS3_INPUT_PIPE ].bmRcvToggle = 0;
|
||||
|
||||
rcode = pUsb->setEpInfoEntry(bAddress, 3, epInfo);
|
||||
if (rcode)
|
||||
|
@ -237,16 +238,17 @@ FailSetDevTblEntry:
|
|||
FailSetConfDescr:
|
||||
#ifdef DEBUG_USB_HOST
|
||||
NotifyFailSetConfDescr();
|
||||
#endif
|
||||
goto Fail;
|
||||
#endif
|
||||
|
||||
FailUnknownDevice:
|
||||
#ifdef DEBUG_USB_HOST
|
||||
NotifyFailUnknownDevice(VID, PID);
|
||||
#endif
|
||||
rcode = USB_DEV_CONFIG_ERROR_DEVICE_NOT_SUPPORTED;
|
||||
Fail:
|
||||
|
||||
#ifdef DEBUG_USB_HOST
|
||||
Fail:
|
||||
Notify(PSTR("\r\nPS3 Init Failed, error code: "), 0x80);
|
||||
NotifyFail(rcode);
|
||||
#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 rcode = 0;
|
||||
uint8_t buf[sizeof (USB_DEVICE_DESCRIPTOR)];
|
||||
USB_DEVICE_DESCRIPTOR *udd = reinterpret_cast<USB_DEVICE_DESCRIPTOR *>(buf);
|
||||
UsbDevice *p = NULL;
|
||||
EpInfo *oldep_ptr = NULL;
|
||||
EpInfo epInfo;
|
||||
|
@ -694,10 +695,9 @@ uint8_t USB::Configuring(uint8_t parent, uint8_t port, bool lowspeed) {
|
|||
|
||||
//if (!bAddress)
|
||||
// return USB_ERROR_OUT_OF_ADDRESS_SPACE_IN_POOL;
|
||||
|
||||
uint16_t vid = (uint16_t)((USB_DEVICE_DESCRIPTOR*)buf)->idVendor;
|
||||
uint16_t pid = (uint16_t)((USB_DEVICE_DESCRIPTOR*)buf)->idProduct;
|
||||
uint8_t klass = ((USB_DEVICE_DESCRIPTOR*)buf)->bDeviceClass;
|
||||
uint16_t vid = udd->idVendor;
|
||||
uint16_t pid = udd->idProduct;
|
||||
uint8_t klass = udd->bDeviceClass;
|
||||
|
||||
// Attempt to configure if VID/PID or device class matches with a driver
|
||||
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) {
|
||||
const uint8_t bufSize = 64;
|
||||
uint8_t buf[bufSize];
|
||||
USB_CONFIGURATION_DESCRIPTOR *ucd = reinterpret_cast<USB_CONFIGURATION_DESCRIPTOR *>(buf);
|
||||
|
||||
uint8_t ret = getConfDescr(addr, ep, 9, conf, buf);
|
||||
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
uint16_t total = ((USB_CONFIGURATION_DESCRIPTOR*)buf)->wTotalLength;
|
||||
uint16_t total = ucd->wTotalLength;
|
||||
|
||||
//USBTRACE2("\r\ntotal conf.size:", total);
|
||||
|
||||
|
|
23
XBOXOLD.cpp
23
XBOXOLD.cpp
|
@ -42,7 +42,7 @@ const uint8_t XBOXOLDBUTTONS[] PROGMEM = {
|
|||
0, // A
|
||||
2, // X
|
||||
3, // Y
|
||||
};
|
||||
};
|
||||
|
||||
XBOXOLD::XBOXOLD(USB *p) :
|
||||
pUsb(p), // pointer to USB class instance - mandatory
|
||||
|
@ -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 buf[sizeof (USB_DEVICE_DESCRIPTOR)];
|
||||
USB_DEVICE_DESCRIPTOR * udd = reinterpret_cast<USB_DEVICE_DESCRIPTOR*>(buf);
|
||||
uint8_t rcode;
|
||||
UsbDevice *p = NULL;
|
||||
EpInfo *oldep_ptr = NULL;
|
||||
|
@ -113,12 +114,12 @@ uint8_t XBOXOLD::Init(uint8_t parent, uint8_t port, bool lowspeed) {
|
|||
if (rcode)
|
||||
goto FailGetDevDescr;
|
||||
|
||||
VID = ((USB_DEVICE_DESCRIPTOR*)buf)->idVendor;
|
||||
PID = ((USB_DEVICE_DESCRIPTOR*)buf)->idProduct;
|
||||
VID = udd->idVendor;
|
||||
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
|
||||
goto FailUnknownDevice;
|
||||
|
||||
|
||||
// Allocate new address according to device class
|
||||
bAddress = addrPool.AllocAddress(parent, false, port);
|
||||
|
||||
|
@ -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;
|
||||
|
||||
// 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
|
||||
rcode = pUsb->setAddr(0, 0, bAddress);
|
||||
|
@ -145,7 +146,7 @@ uint8_t XBOXOLD::Init(uint8_t parent, uint8_t port, bool lowspeed) {
|
|||
D_PrintHex<uint8_t > (bAddress, 0x80);
|
||||
#endif
|
||||
delay(300); // Spec says you should wait at least 200ms
|
||||
|
||||
|
||||
p->lowspeed = false;
|
||||
|
||||
//get pointer to assigned address record
|
||||
|
@ -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 ].bmNakPower = USB_NAK_NOWAIT; // Only poll once for interrupt endpoints
|
||||
epInfo[ XBOX_INPUT_PIPE ].maxPktSize = EP_MAXPKTSIZE;
|
||||
epInfo[ XBOX_INPUT_PIPE ].bmSndToggle = bmSNDTOG0;
|
||||
epInfo[ XBOX_INPUT_PIPE ].bmRcvToggle = bmRCVTOG0;
|
||||
epInfo[ XBOX_INPUT_PIPE ].bmSndToggle = 0;
|
||||
epInfo[ XBOX_INPUT_PIPE ].bmRcvToggle = 0;
|
||||
epInfo[ XBOX_OUTPUT_PIPE ].epAddr = 0x02; // XBOX output endpoint
|
||||
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 ].maxPktSize = EP_MAXPKTSIZE;
|
||||
epInfo[ XBOX_OUTPUT_PIPE ].bmSndToggle = bmSNDTOG0;
|
||||
epInfo[ XBOX_OUTPUT_PIPE ].bmRcvToggle = bmRCVTOG0;
|
||||
epInfo[ XBOX_OUTPUT_PIPE ].bmSndToggle = 0;
|
||||
epInfo[ XBOX_OUTPUT_PIPE ].bmRcvToggle = 0;
|
||||
|
||||
rcode = pUsb->setEpInfoEntry(bAddress, 3, epInfo);
|
||||
if (rcode)
|
||||
|
@ -221,8 +222,8 @@ FailUnknownDevice:
|
|||
#endif
|
||||
rcode = USB_DEV_CONFIG_ERROR_DEVICE_NOT_SUPPORTED;
|
||||
|
||||
Fail:
|
||||
#ifdef DEBUG_USB_HOST
|
||||
Fail:
|
||||
Notify(PSTR("\r\nXbox Init Failed, error code: "), 0x80);
|
||||
NotifyFail(rcode);
|
||||
#endif
|
||||
|
|
53
XBOXRECV.cpp
53
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 buf[sizeof (USB_DEVICE_DESCRIPTOR)];
|
||||
USB_DEVICE_DESCRIPTOR * udd = reinterpret_cast<USB_DEVICE_DESCRIPTOR*>(buf);
|
||||
uint8_t rcode;
|
||||
UsbDevice *p = NULL;
|
||||
EpInfo *oldep_ptr = NULL;
|
||||
|
@ -91,8 +92,8 @@ uint8_t XBOXRECV::Init(uint8_t parent, uint8_t port, bool lowspeed) {
|
|||
if (rcode)
|
||||
goto FailGetDevDescr;
|
||||
|
||||
VID = ((USB_DEVICE_DESCRIPTOR*)buf)->idVendor;
|
||||
PID = ((USB_DEVICE_DESCRIPTOR*)buf)->idProduct;
|
||||
VID = udd->idVendor;
|
||||
PID = udd->idProduct;
|
||||
|
||||
if (VID != XBOX_VID && VID != MADCATZ_VID) // We just check if it's a Xbox receiver using the Vendor ID
|
||||
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;
|
||||
|
||||
// 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
|
||||
rcode = pUsb->setAddr(0, 0, bAddress);
|
||||
|
@ -129,7 +130,7 @@ uint8_t XBOXRECV::Init(uint8_t parent, uint8_t port, bool lowspeed) {
|
|||
D_PrintHex<uint8_t > (bAddress, 0x80);
|
||||
#endif
|
||||
delay(300); // Spec says you should wait at least 200ms
|
||||
|
||||
|
||||
p->lowspeed = false;
|
||||
|
||||
//get pointer to assigned address record
|
||||
|
@ -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 ].bmNakPower = USB_NAK_NOWAIT; // Only poll once for interrupt endpoints
|
||||
epInfo[ XBOX_INPUT_PIPE_1 ].maxPktSize = EP_MAXPKTSIZE;
|
||||
epInfo[ XBOX_INPUT_PIPE_1 ].bmSndToggle = bmSNDTOG0;
|
||||
epInfo[ XBOX_INPUT_PIPE_1 ].bmRcvToggle = bmRCVTOG0;
|
||||
epInfo[ XBOX_INPUT_PIPE_1 ].bmSndToggle = 0;
|
||||
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 ].epAttribs = EP_INTERRUPT;
|
||||
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 ].bmSndToggle = bmSNDTOG0;
|
||||
epInfo[ XBOX_OUTPUT_PIPE_1 ].bmRcvToggle = bmRCVTOG0;
|
||||
epInfo[ XBOX_OUTPUT_PIPE_1 ].bmSndToggle = 0;
|
||||
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 ].epAttribs = EP_INTERRUPT;
|
||||
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 ].bmSndToggle = bmSNDTOG0;
|
||||
epInfo[ XBOX_INPUT_PIPE_2 ].bmRcvToggle = bmRCVTOG0;
|
||||
epInfo[ XBOX_INPUT_PIPE_2 ].bmSndToggle = 0;
|
||||
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 ].epAttribs = EP_INTERRUPT;
|
||||
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 ].bmSndToggle = bmSNDTOG0;
|
||||
epInfo[ XBOX_OUTPUT_PIPE_2 ].bmRcvToggle = bmRCVTOG0;
|
||||
epInfo[ XBOX_OUTPUT_PIPE_2 ].bmSndToggle = 0;
|
||||
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 ].epAttribs = EP_INTERRUPT;
|
||||
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 ].bmSndToggle = bmSNDTOG0;
|
||||
epInfo[ XBOX_INPUT_PIPE_3 ].bmRcvToggle = bmRCVTOG0;
|
||||
epInfo[ XBOX_INPUT_PIPE_3 ].bmSndToggle = 0;
|
||||
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 ].epAttribs = EP_INTERRUPT;
|
||||
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 ].bmSndToggle = bmSNDTOG0;
|
||||
epInfo[ XBOX_OUTPUT_PIPE_3 ].bmRcvToggle = bmRCVTOG0;
|
||||
epInfo[ XBOX_OUTPUT_PIPE_3 ].bmSndToggle = 0;
|
||||
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 ].epAttribs = EP_INTERRUPT;
|
||||
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 ].bmSndToggle = bmSNDTOG0;
|
||||
epInfo[ XBOX_INPUT_PIPE_4 ].bmRcvToggle = bmRCVTOG0;
|
||||
epInfo[ XBOX_INPUT_PIPE_4 ].bmSndToggle = 0;
|
||||
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 ].epAttribs = EP_INTERRUPT;
|
||||
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 ].bmSndToggle = bmSNDTOG0;
|
||||
epInfo[ XBOX_OUTPUT_PIPE_4 ].bmRcvToggle = bmRCVTOG0;
|
||||
epInfo[ XBOX_OUTPUT_PIPE_4 ].bmSndToggle = 0;
|
||||
epInfo[ XBOX_OUTPUT_PIPE_4 ].bmRcvToggle = 0;
|
||||
|
||||
rcode = pUsb->setEpInfoEntry(bAddress, 9, epInfo);
|
||||
if (rcode)
|
||||
|
@ -235,7 +236,6 @@ FailSetConfDescr:
|
|||
#ifdef DEBUG_USB_HOST
|
||||
NotifyFailSetConfDescr();
|
||||
#endif
|
||||
goto Fail;
|
||||
|
||||
FailUnknownDevice:
|
||||
#ifdef DEBUG_USB_HOST
|
||||
|
@ -243,8 +243,8 @@ FailUnknownDevice:
|
|||
#endif
|
||||
rcode = USB_DEV_CONFIG_ERROR_DEVICE_NOT_SUPPORTED;
|
||||
|
||||
Fail:
|
||||
#ifdef DEBUG_USB_HOST
|
||||
Fail:
|
||||
Notify(PSTR("\r\nXbox 360 Init Failed, error code: "), 0x80);
|
||||
NotifyFail(rcode);
|
||||
#endif
|
||||
|
@ -442,7 +442,9 @@ uint8_t XBOXRECV::getBatteryLevel(uint8_t controller) {
|
|||
}
|
||||
|
||||
void XBOXRECV::XboxCommand(uint8_t controller, uint8_t* data, uint16_t nbytes) {
|
||||
#ifdef EXTRADEBUG
|
||||
uint8_t rcode;
|
||||
#endif
|
||||
uint8_t outputPipe;
|
||||
switch (controller) {
|
||||
case 0: outputPipe = XBOX_OUTPUT_PIPE_1;
|
||||
|
@ -453,8 +455,13 @@ void XBOXRECV::XboxCommand(uint8_t controller, uint8_t* data, uint16_t nbytes) {
|
|||
break;
|
||||
case 3: outputPipe = XBOX_OUTPUT_PIPE_4;
|
||||
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
|
||||
if (rcode)
|
||||
Notify(PSTR("Error sending Xbox message\r\n"), 0x80);
|
||||
|
|
19
XBOXUSB.cpp
19
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 buf[sizeof (USB_DEVICE_DESCRIPTOR)];
|
||||
USB_DEVICE_DESCRIPTOR * udd = reinterpret_cast<USB_DEVICE_DESCRIPTOR*>(buf);
|
||||
uint8_t rcode;
|
||||
UsbDevice *p = NULL;
|
||||
EpInfo *oldep_ptr = NULL;
|
||||
|
@ -89,8 +90,8 @@ uint8_t XBOXUSB::Init(uint8_t parent, uint8_t port, bool lowspeed) {
|
|||
if (rcode)
|
||||
goto FailGetDevDescr;
|
||||
|
||||
VID = ((USB_DEVICE_DESCRIPTOR*)buf)->idVendor;
|
||||
PID = ((USB_DEVICE_DESCRIPTOR*)buf)->idProduct;
|
||||
VID = udd->idVendor;
|
||||
PID = udd->idProduct;
|
||||
|
||||
if (VID != XBOX_VID && VID != MADCATZ_VID && VID != JOYTECH_VID && VID != GAMESTOP_VID) // Check VID
|
||||
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;
|
||||
|
||||
// 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
|
||||
rcode = pUsb->setAddr(0, 0, bAddress);
|
||||
|
@ -133,7 +134,7 @@ uint8_t XBOXUSB::Init(uint8_t parent, uint8_t port, bool lowspeed) {
|
|||
D_PrintHex<uint8_t > (bAddress, 0x80);
|
||||
#endif
|
||||
delay(300); // Spec says you should wait at least 200ms
|
||||
|
||||
|
||||
p->lowspeed = false;
|
||||
|
||||
//get pointer to assigned address record
|
||||
|
@ -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 ].bmNakPower = USB_NAK_NOWAIT; // Only poll once for interrupt endpoints
|
||||
epInfo[ XBOX_INPUT_PIPE ].maxPktSize = EP_MAXPKTSIZE;
|
||||
epInfo[ XBOX_INPUT_PIPE ].bmSndToggle = bmSNDTOG0;
|
||||
epInfo[ XBOX_INPUT_PIPE ].bmRcvToggle = bmRCVTOG0;
|
||||
epInfo[ XBOX_INPUT_PIPE ].bmSndToggle = 0;
|
||||
epInfo[ XBOX_INPUT_PIPE ].bmRcvToggle = 0;
|
||||
epInfo[ XBOX_OUTPUT_PIPE ].epAddr = 0x02; // XBOX 360 output endpoint
|
||||
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 ].maxPktSize = EP_MAXPKTSIZE;
|
||||
epInfo[ XBOX_OUTPUT_PIPE ].bmSndToggle = bmSNDTOG0;
|
||||
epInfo[ XBOX_OUTPUT_PIPE ].bmRcvToggle = bmRCVTOG0;
|
||||
epInfo[ XBOX_OUTPUT_PIPE ].bmSndToggle = 0;
|
||||
epInfo[ XBOX_OUTPUT_PIPE ].bmRcvToggle = 0;
|
||||
|
||||
rcode = pUsb->setEpInfoEntry(bAddress, 3, epInfo);
|
||||
if (rcode)
|
||||
|
@ -208,8 +209,8 @@ FailUnknownDevice:
|
|||
#endif
|
||||
rcode = USB_DEV_CONFIG_ERROR_DEVICE_NOT_SUPPORTED;
|
||||
|
||||
Fail:
|
||||
#ifdef DEBUG_USB_HOST
|
||||
Fail:
|
||||
Notify(PSTR("\r\nXbox 360 Init Failed, error code: "), 0x80);
|
||||
NotifyFail(rcode);
|
||||
#endif
|
||||
|
|
20
address.h
20
address.h
|
@ -122,7 +122,8 @@ class AddressPoolImpl : public AddressPool {
|
|||
|
||||
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++) {
|
||||
if(((UsbDeviceAddress*) & thePool[i].address)->bmParent == addr.bmAddress)
|
||||
UsbDeviceAddress* uda = reinterpret_cast<UsbDeviceAddress *>(&thePool[i].address);
|
||||
if(uda->bmParent == addr.bmAddress)
|
||||
return i;
|
||||
}
|
||||
return 0;
|
||||
|
@ -133,14 +134,14 @@ class AddressPoolImpl : public AddressPool {
|
|||
// Zerro field is reserved and should not be affected
|
||||
if(index == 0)
|
||||
return;
|
||||
|
||||
UsbDeviceAddress* uda = reinterpret_cast<UsbDeviceAddress *>(& thePool[index].address);
|
||||
// If a hub was switched off all port addresses should be freed
|
||||
if(((UsbDeviceAddress*) & thePool[index].address)->bmHub == 1) {
|
||||
for(uint8_t i = 1; (i = FindChildIndex(*((UsbDeviceAddress*) & thePool[index].address), i));)
|
||||
if(uda->bmHub == 1) {
|
||||
for(uint8_t i = 1; (i = FindChildIndex(*uda, i));)
|
||||
FreeAddressByIndex(i);
|
||||
|
||||
// If the hub had the last allocated address, hubCounter should be decremented
|
||||
if(hubCounter == ((UsbDeviceAddress*) & thePool[index].address)->bmAddress)
|
||||
if(hubCounter == uda->bmAddress)
|
||||
hubCounter--;
|
||||
}
|
||||
InitEntry(index);
|
||||
|
@ -220,8 +221,9 @@ public:
|
|||
|
||||
UsbDeviceAddress addr;
|
||||
addr.devAddress = 0; // Ensure all bits are zero
|
||||
|
||||
addr.bmParent = ((UsbDeviceAddress*) & parent)->bmAddress;
|
||||
UsbDeviceAddress* uda = reinterpret_cast<UsbDeviceAddress *>(&parent);
|
||||
//addr.bmParent = ((UsbDeviceAddress*) & parent)->bmAddress;
|
||||
addr.bmParent = uda->bmAddress;
|
||||
|
||||
if(is_hub) {
|
||||
addr.bmHub = 1;
|
||||
|
@ -230,7 +232,9 @@ public:
|
|||
addr.bmHub = 0;
|
||||
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.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 buf[sizeof (USB_DEVICE_DESCRIPTOR)];
|
||||
USB_DEVICE_DESCRIPTOR * udd = reinterpret_cast<USB_DEVICE_DESCRIPTOR*>(buf);
|
||||
uint8_t rcode;
|
||||
uint8_t num_of_conf; // number of configurations
|
||||
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);
|
||||
|
||||
// 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
|
||||
rcode = pUsb->setAddr(0, 0, bAddress);
|
||||
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
|
||||
if (((USB_DEVICE_DESCRIPTOR*)buf)->idVendor == ADK_VID &&
|
||||
(((USB_DEVICE_DESCRIPTOR*)buf)->idProduct == ADK_PID || ((USB_DEVICE_DESCRIPTOR*)buf)->idProduct == ADB_PID)) {
|
||||
if (udd->idVendor == ADK_VID &&
|
||||
(udd->idProduct == ADK_PID || udd->idProduct == ADB_PID)) {
|
||||
USBTRACE("\r\nAcc.mode device detected");
|
||||
/* 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);
|
||||
|
||||
|
@ -268,15 +269,15 @@ FailSwAcc:
|
|||
goto Fail;
|
||||
#endif
|
||||
|
||||
SwAttempt:
|
||||
#ifdef DEBUG_USB_HOST
|
||||
USBTRACE("\r\nAccessory mode switch attempt");
|
||||
#endif
|
||||
//FailOnInit:
|
||||
// USBTRACE("OnInit:");
|
||||
// goto Fail;
|
||||
//
|
||||
SwAttempt:
|
||||
#ifdef DEBUG_USB_HOST
|
||||
USBTRACE("\r\nAccessory mode switch attempt");
|
||||
Fail:
|
||||
#endif
|
||||
//USBTRACE2("\r\nADK Init Failed, error code: ", rcode);
|
||||
//NotifyFail(rcode);
|
||||
Release();
|
||||
|
|
|
@ -821,4 +821,5 @@ MAKE_PIN(P33, CORE_PIN33_PORTREG, CORE_PIN33_BIT, CORE_PIN33_CONFIG);
|
|||
|
||||
#endif // __arm__
|
||||
|
||||
#define output_pgm_message(wa, fp, mp , el) wa = &mp, fp((char *)pgm_read_pointer(wa), el)
|
||||
#endif //_avrpins_h_
|
||||
|
|
12
cdcacm.cpp
12
cdcacm.cpp
|
@ -28,8 +28,8 @@ bControlIface(0),
|
|||
bDataIface(0),
|
||||
bNumEP(1),
|
||||
qNextPollTime(0),
|
||||
ready(false),
|
||||
bPollEnable(false) {
|
||||
bPollEnable(false),
|
||||
ready(false) {
|
||||
for (uint8_t i = 0; i < ACM_MAX_ENDPOINTS; i++) {
|
||||
epInfo[i].epAddr = 0;
|
||||
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);
|
||||
|
||||
uint8_t buf[constBufSize];
|
||||
USB_DEVICE_DESCRIPTOR * udd = reinterpret_cast<USB_DEVICE_DESCRIPTOR*>(buf);
|
||||
|
||||
uint8_t rcode;
|
||||
UsbDevice *p = 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;
|
||||
|
||||
// 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
|
||||
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;
|
||||
|
||||
num_of_conf = ((USB_DEVICE_DESCRIPTOR*)buf)->bNumConfigurations;
|
||||
num_of_conf = udd->bNumConfigurations;
|
||||
|
||||
// Assign epInfo to epinfo pointer
|
||||
rcode = pUsb->setEpInfoEntry(bAddress, 1, epInfo);
|
||||
|
@ -211,8 +213,8 @@ FailOnInit:
|
|||
USBTRACE("OnInit:");
|
||||
#endif
|
||||
|
||||
Fail:
|
||||
#ifdef DEBUG_USB_HOST
|
||||
Fail:
|
||||
NotifyFail(rcode);
|
||||
#endif
|
||||
Release();
|
||||
|
|
102
cdcacm.h
102
cdcacm.h
|
@ -19,67 +19,67 @@ e-mail : support@circuitsathome.com
|
|||
|
||||
#include "Usb.h"
|
||||
|
||||
#define bmREQ_CDCOUT USB_SETUP_HOST_TO_DEVICE|USB_SETUP_TYPE_CLASS|USB_SETUP_RECIPIENT_INTERFACE
|
||||
#define bmREQ_CDCIN USB_SETUP_DEVICE_TO_HOST|USB_SETUP_TYPE_CLASS|USB_SETUP_RECIPIENT_INTERFACE
|
||||
#define bmREQ_CDCOUT USB_SETUP_HOST_TO_DEVICE|USB_SETUP_TYPE_CLASS|USB_SETUP_RECIPIENT_INTERFACE
|
||||
#define bmREQ_CDCIN USB_SETUP_DEVICE_TO_HOST|USB_SETUP_TYPE_CLASS|USB_SETUP_RECIPIENT_INTERFACE
|
||||
|
||||
// CDC Subclass Constants
|
||||
#define CDC_SUBCLASS_DLCM 0x01 // Direct Line Control Model
|
||||
#define CDC_SUBCLASS_ACM 0x02 // Abstract Control Model
|
||||
#define CDC_SUBCLASS_TCM 0x03 // Telephone Control Model
|
||||
#define CDC_SUBCLASS_MCCM 0x04 // Multi Channel Control Model
|
||||
#define CDC_SUBCLASS_CAPI 0x05 // CAPI Control Model
|
||||
#define CDC_SUBCLASS_ETHERNET 0x06 // Ethernet Network Control Model
|
||||
#define CDC_SUBCLASS_ATM 0x07 // ATM Network Control Model
|
||||
#define CDC_SUBCLASS_WIRELESS_HANDSET 0x08 // Wireless Handset Control Model
|
||||
#define CDC_SUBCLASS_DEVICE_MANAGEMENT 0x09 // Device Management
|
||||
#define CDC_SUBCLASS_MOBILE_DIRECT_LINE 0x0A // Mobile Direct Line Model
|
||||
#define CDC_SUBCLASS_OBEX 0x0B // OBEX
|
||||
#define CDC_SUBCLASS_ETHERNET_EMU 0x0C // Ethernet Emulation Model
|
||||
#define CDC_SUBCLASS_DLCM 0x01 // Direct Line Control Model
|
||||
#define CDC_SUBCLASS_ACM 0x02 // Abstract Control Model
|
||||
#define CDC_SUBCLASS_TCM 0x03 // Telephone Control Model
|
||||
#define CDC_SUBCLASS_MCCM 0x04 // Multi Channel Control Model
|
||||
#define CDC_SUBCLASS_CAPI 0x05 // CAPI Control Model
|
||||
#define CDC_SUBCLASS_ETHERNET 0x06 // Ethernet Network Control Model
|
||||
#define CDC_SUBCLASS_ATM 0x07 // ATM Network Control Model
|
||||
#define CDC_SUBCLASS_WIRELESS_HANDSET 0x08 // Wireless Handset Control Model
|
||||
#define CDC_SUBCLASS_DEVICE_MANAGEMENT 0x09 // Device Management
|
||||
#define CDC_SUBCLASS_MOBILE_DIRECT_LINE 0x0A // Mobile Direct Line Model
|
||||
#define CDC_SUBCLASS_OBEX 0x0B // OBEX
|
||||
#define CDC_SUBCLASS_ETHERNET_EMU 0x0C // Ethernet Emulation Model
|
||||
|
||||
// Communication Interface Class Control Protocol Codes
|
||||
#define CDC_PROTOCOL_ITU_T_V_250 0x01 // AT Commands defined by ITU-T V.250
|
||||
#define CDC_PROTOCOL_PCCA_101 0x02 // AT Commands defined by PCCA-101
|
||||
#define CDC_PROTOCOL_PCCA_101_O 0x03 // AT Commands defined by PCCA-101 & Annex O
|
||||
#define CDC_PROTOCOL_GSM_7_07 0x04 // AT Commands defined by GSM 7.07
|
||||
#define CDC_PROTOCOL_3GPP_27_07 0x05 // AT Commands defined by 3GPP 27.007
|
||||
#define CDC_PROTOCOL_C_S0017_0 0x06 // AT Commands defined by TIA for CDMA
|
||||
#define CDC_PROTOCOL_USB_EEM 0x07 // Ethernet Emulation Model
|
||||
#define CDC_PROTOCOL_ITU_T_V_250 0x01 // AT Commands defined by ITU-T V.250
|
||||
#define CDC_PROTOCOL_PCCA_101 0x02 // AT Commands defined by PCCA-101
|
||||
#define CDC_PROTOCOL_PCCA_101_O 0x03 // AT Commands defined by PCCA-101 & Annex O
|
||||
#define CDC_PROTOCOL_GSM_7_07 0x04 // AT Commands defined by GSM 7.07
|
||||
#define CDC_PROTOCOL_3GPP_27_07 0x05 // AT Commands defined by 3GPP 27.007
|
||||
#define CDC_PROTOCOL_C_S0017_0 0x06 // AT Commands defined by TIA for CDMA
|
||||
#define CDC_PROTOCOL_USB_EEM 0x07 // Ethernet Emulation Model
|
||||
|
||||
// CDC Commands defined by CDC 1.2
|
||||
#define CDC_SEND_ENCAPSULATED_COMMAND 0x00
|
||||
#define CDC_GET_ENCAPSULATED_RESPONSE 0x01
|
||||
#define CDC_SEND_ENCAPSULATED_COMMAND 0x00
|
||||
#define CDC_GET_ENCAPSULATED_RESPONSE 0x01
|
||||
|
||||
// CDC Commands defined by PSTN 1.2
|
||||
#define CDC_SET_COMM_FEATURE 0x02
|
||||
#define CDC_GET_COMM_FEATURE 0x03
|
||||
#define CDC_CLEAR_COMM_FEATURE 0x04
|
||||
#define CDC_SET_AUX_LINE_STATE 0x10
|
||||
#define CDC_SET_HOOK_STATE 0x11
|
||||
#define CDC_PULSE_SETUP 0x12
|
||||
#define CDC_SEND_PULSE 0x13
|
||||
#define CDC_SET_PULSE_TIME 0x14
|
||||
#define CDC_RING_AUX_JACK 0x15
|
||||
#define CDC_SET_LINE_CODING 0x20
|
||||
#define CDC_GET_LINE_CODING 0x21
|
||||
#define CDC_SET_CONTROL_LINE_STATE 0x22
|
||||
#define CDC_SEND_BREAK 0x23
|
||||
#define CDC_SET_RINGER_PARMS 0x30
|
||||
#define CDC_GET_RINGER_PARMS 0x31
|
||||
#define CDC_SET_OPERATION_PARMS 0x32
|
||||
#define CDC_GET_OPERATION_PARMS 0x33
|
||||
#define CDC_SET_LINE_PARMS 0x34
|
||||
#define CDC_GET_LINE_PARMS 0x35
|
||||
#define CDC_DIAL_DIGITS 0x36
|
||||
#define CDC_SET_COMM_FEATURE 0x02
|
||||
#define CDC_GET_COMM_FEATURE 0x03
|
||||
#define CDC_CLEAR_COMM_FEATURE 0x04
|
||||
#define CDC_SET_AUX_LINE_STATE 0x10
|
||||
#define CDC_SET_HOOK_STATE 0x11
|
||||
#define CDC_PULSE_SETUP 0x12
|
||||
#define CDC_SEND_PULSE 0x13
|
||||
#define CDC_SET_PULSE_TIME 0x14
|
||||
#define CDC_RING_AUX_JACK 0x15
|
||||
#define CDC_SET_LINE_CODING 0x20
|
||||
#define CDC_GET_LINE_CODING 0x21
|
||||
#define CDC_SET_CONTROL_LINE_STATE 0x22
|
||||
#define CDC_SEND_BREAK 0x23
|
||||
#define CDC_SET_RINGER_PARMS 0x30
|
||||
#define CDC_GET_RINGER_PARMS 0x31
|
||||
#define CDC_SET_OPERATION_PARMS 0x32
|
||||
#define CDC_GET_OPERATION_PARMS 0x33
|
||||
#define CDC_SET_LINE_PARMS 0x34
|
||||
#define CDC_GET_LINE_PARMS 0x35
|
||||
#define CDC_DIAL_DIGITS 0x36
|
||||
|
||||
//Class-Specific Notification Codes
|
||||
#define NETWORK_CONNECTION 0x00
|
||||
#define RESPONSE_AVAILABLE 0x01
|
||||
#define AUX_JACK_HOOK_STATE 0x08
|
||||
#define RING_DETECT 0x09
|
||||
#define SERIAL_STATE 0x20
|
||||
#define CALL_STATE_CHANGE 0x28
|
||||
#define LINE_STATE_CHANGE 0x29
|
||||
#define CONNECTION_SPEED_CHANGE 0x2a
|
||||
#define NETWORK_CONNECTION 0x00
|
||||
#define RESPONSE_AVAILABLE 0x01
|
||||
#define AUX_JACK_HOOK_STATE 0x08
|
||||
#define RING_DETECT 0x09
|
||||
#define SERIAL_STATE 0x20
|
||||
#define CALL_STATE_CHANGE 0x28
|
||||
#define LINE_STATE_CHANGE 0x29
|
||||
#define CONNECTION_SPEED_CHANGE 0x2a
|
||||
|
||||
// CDC Functional Descriptor Structures
|
||||
|
||||
|
|
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);
|
||||
|
||||
uint8_t buf[constBufSize];
|
||||
USB_DEVICE_DESCRIPTOR * udd = reinterpret_cast<USB_DEVICE_DESCRIPTOR*>(buf);
|
||||
uint8_t rcode;
|
||||
UsbDevice *p = NULL;
|
||||
EpInfo *oldep_ptr = NULL;
|
||||
|
@ -78,19 +79,18 @@ uint8_t FTDI::Init(uint8_t parent, uint8_t port, bool lowspeed) {
|
|||
p->lowspeed = lowspeed;
|
||||
|
||||
// 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
|
||||
p->epinfo = oldep_ptr;
|
||||
|
||||
if (rcode)
|
||||
goto FailGetDevDescr;
|
||||
|
||||
if (((USB_DEVICE_DESCRIPTOR*)buf)->idVendor != FTDI_VID || ((USB_DEVICE_DESCRIPTOR*)buf)->idProduct != FTDI_PID)
|
||||
if (udd->idVendor != FTDI_VID || udd->idProduct != FTDI_PID)
|
||||
return USB_DEV_CONFIG_ERROR_DEVICE_NOT_SUPPORTED;
|
||||
|
||||
// Save type of FTDI chip
|
||||
wFTDIType = ((USB_DEVICE_DESCRIPTOR*)buf)->bcdDevice;
|
||||
wFTDIType = udd->bcdDevice;
|
||||
|
||||
// Allocate new address according to device class
|
||||
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;
|
||||
|
||||
// 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
|
||||
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;
|
||||
|
||||
num_of_conf = ((USB_DEVICE_DESCRIPTOR*)buf)->bNumConfigurations;
|
||||
num_of_conf = udd->bNumConfigurations;
|
||||
|
||||
// Assign epInfo to epinfo pointer
|
||||
rcode = pUsb->setEpInfoEntry(bAddress, 1, epInfo);
|
||||
|
@ -204,10 +204,8 @@ FailSetConfDescr:
|
|||
FailOnInit:
|
||||
#ifdef DEBUG_USB_HOST
|
||||
USBTRACE("OnInit:");
|
||||
#endif
|
||||
|
||||
Fail:
|
||||
#ifdef DEBUG_USB_HOST
|
||||
NotifyFail(rcode);
|
||||
#endif
|
||||
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);
|
||||
|
||||
uint8_t buf[constBufSize];
|
||||
USB_DEVICE_DESCRIPTOR * udd = reinterpret_cast<USB_DEVICE_DESCRIPTOR*>(buf);
|
||||
uint8_t rcode;
|
||||
UsbDevice *p = NULL;
|
||||
EpInfo *oldep_ptr = NULL;
|
||||
|
@ -65,11 +66,11 @@ uint8_t PL2303::Init(uint8_t parent, uint8_t port, bool lowspeed) {
|
|||
if (rcode)
|
||||
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;
|
||||
|
||||
// Save type of PL chip
|
||||
wPLType = ((USB_DEVICE_DESCRIPTOR*)buf)->bcdDevice;
|
||||
wPLType = udd->bcdDevice;
|
||||
|
||||
// Allocate new address according to device class
|
||||
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;
|
||||
|
||||
// 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
|
||||
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;
|
||||
|
||||
num_of_conf = ((USB_DEVICE_DESCRIPTOR*)buf)->bNumConfigurations;
|
||||
num_of_conf = udd->bNumConfigurations;
|
||||
|
||||
// Assign epInfo to epinfo pointer
|
||||
rcode = pUsb->setEpInfoEntry(bAddress, 1, epInfo);
|
||||
|
@ -184,8 +185,8 @@ FailOnInit:
|
|||
USBTRACE("OnInit:");
|
||||
#endif
|
||||
|
||||
Fail:
|
||||
#ifdef DEBUG_USB_HOST
|
||||
Fail:
|
||||
NotifyFail(rcode);
|
||||
#endif
|
||||
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 */
|
||||
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) {
|
||||
USB_CONFIGURATION_DESCRIPTOR* ucd= reinterpret_cast<USB_CONFIGURATION_DESCRIPTOR*>(varBuffer);
|
||||
USB_INTERFACE_DESCRIPTOR* uid= reinterpret_cast<USB_INTERFACE_DESCRIPTOR*>(varBuffer);
|
||||
switch(stateParseDescr) {
|
||||
case 0:
|
||||
theBuffer.valueSize = 2;
|
||||
|
@ -128,22 +130,22 @@ bool ConfigDescParser<CLASS_ID, SUBCLASS_ID, PROTOCOL_ID, MASK>::ParseDescriptor
|
|||
case USB_DESCRIPTOR_CONFIGURATION:
|
||||
if(!valParser.Parse(pp, pcntdn))
|
||||
return false;
|
||||
confValue = ((USB_CONFIGURATION_DESCRIPTOR*) varBuffer)->bConfigurationValue;
|
||||
confValue = ucd->bConfigurationValue;
|
||||
break;
|
||||
case USB_DESCRIPTOR_INTERFACE:
|
||||
if(!valParser.Parse(pp, pcntdn))
|
||||
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;
|
||||
if((MASK & CP_MASK_COMPARE_SUBCLASS) && ((USB_INTERFACE_DESCRIPTOR*) varBuffer)->bInterfaceSubClass != SUBCLASS_ID)
|
||||
if((MASK & CP_MASK_COMPARE_SUBCLASS) && uid->bInterfaceSubClass != SUBCLASS_ID)
|
||||
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;
|
||||
|
||||
isGoodInterface = true;
|
||||
ifaceNumber = ((USB_INTERFACE_DESCRIPTOR*) varBuffer)->bInterfaceNumber;
|
||||
ifaceAltSet = ((USB_INTERFACE_DESCRIPTOR*) varBuffer)->bAlternateSetting;
|
||||
protoValue = ((USB_INTERFACE_DESCRIPTOR*) varBuffer)->bInterfaceProtocol;
|
||||
ifaceNumber = uid->bInterfaceNumber;
|
||||
ifaceAltSet = uid->bAlternateSetting;
|
||||
protoValue = uid->bInterfaceProtocol;
|
||||
break;
|
||||
case USB_DESCRIPTOR_ENDPOINT:
|
||||
if(!valParser.Parse(pp, pcntdn))
|
||||
|
|
|
@ -2,14 +2,16 @@
|
|||
#include <hiduniversal.h>
|
||||
#include <hidescriptorparser.h>
|
||||
#include <usbhub.h>
|
||||
|
||||
#include "pgmstrings.h"
|
||||
#ifdef arm
|
||||
#include <spi4teensy3.h>
|
||||
#endif
|
||||
#include "pgmstrings.h"
|
||||
|
||||
class HIDUniversal2 : public HIDUniversal
|
||||
{
|
||||
public:
|
||||
HIDUniversal2(USB *usb) : HIDUniversal(usb) {};
|
||||
|
||||
|
||||
protected:
|
||||
virtual uint8_t OnInitSuccessful();
|
||||
};
|
||||
|
@ -17,13 +19,13 @@ protected:
|
|||
uint8_t HIDUniversal2::OnInitSuccessful()
|
||||
{
|
||||
uint8_t rcode;
|
||||
|
||||
|
||||
HexDumper<USBReadParser, uint16_t, uint16_t> Hex;
|
||||
ReportDescParser Rpt;
|
||||
|
||||
if (rcode = GetReportDescr(0, &Hex))
|
||||
goto FailGetReportDescr1;
|
||||
|
||||
|
||||
if (rcode = GetReportDescr(0, &Rpt))
|
||||
goto FailGetReportDescr2;
|
||||
|
||||
|
@ -43,10 +45,10 @@ Fail:
|
|||
return rcode;
|
||||
}
|
||||
|
||||
USB Usb;
|
||||
//USBHub Hub(&Usb);
|
||||
HIDUniversal2 Hid(&Usb);
|
||||
UniversalReportParser Uni;
|
||||
USB Usb;
|
||||
//USBHub Hub(&Usb);
|
||||
HIDUniversal2 Hid(&Usb);
|
||||
UniversalReportParser Uni;
|
||||
|
||||
void setup()
|
||||
{
|
||||
|
@ -56,11 +58,11 @@ void setup()
|
|||
|
||||
if (Usb.Init() == -1)
|
||||
Serial.println("OSC did not start.");
|
||||
|
||||
|
||||
delay( 200 );
|
||||
|
||||
if (!Hid.SetReportParser(0, &Uni))
|
||||
ErrorMessage<uint8_t>(PSTR("SetReportParser"), 1 );
|
||||
ErrorMessage<uint8_t>(PSTR("SetReportParser"), 1 );
|
||||
}
|
||||
|
||||
void loop()
|
||||
|
|
149
hid.h
149
hid.h
|
@ -20,75 +20,101 @@ e-mail : support@circuitsathome.com
|
|||
#include "Usb.h"
|
||||
#include "hidusagestr.h"
|
||||
|
||||
#define DATA_SIZE_MASK 0x03
|
||||
#define TYPE_MASK 0x0C
|
||||
#define TAG_MASK 0xF0
|
||||
#define MAX_REPORT_PARSERS 2
|
||||
#define HID_MAX_HID_CLASS_DESCRIPTORS 5
|
||||
|
||||
#define DATA_SIZE_0 0x00
|
||||
#define DATA_SIZE_1 0x01
|
||||
#define DATA_SIZE_2 0x02
|
||||
#define DATA_SIZE_4 0x03
|
||||
#define DATA_SIZE_MASK 0x03
|
||||
#define TYPE_MASK 0x0C
|
||||
#define TAG_MASK 0xF0
|
||||
|
||||
#define TYPE_MAIN 0x00
|
||||
#define TYPE_GLOBAL 0x04
|
||||
#define TYPE_LOCAL 0x08
|
||||
#define DATA_SIZE_0 0x00
|
||||
#define DATA_SIZE_1 0x01
|
||||
#define DATA_SIZE_2 0x02
|
||||
#define DATA_SIZE_4 0x03
|
||||
|
||||
#define TAG_MAIN_INPUT 0x80
|
||||
#define TAG_MAIN_OUTPUT 0x90
|
||||
#define TAG_MAIN_COLLECTION 0xA0
|
||||
#define TAG_MAIN_FEATURE 0xB0
|
||||
#define TAG_MAIN_ENDCOLLECTION 0xC0
|
||||
#define TYPE_MAIN 0x00
|
||||
#define TYPE_GLOBAL 0x04
|
||||
#define TYPE_LOCAL 0x08
|
||||
|
||||
#define TAG_GLOBAL_USAGEPAGE 0x00
|
||||
#define TAG_GLOBAL_LOGICALMIN 0x10
|
||||
#define TAG_GLOBAL_LOGICALMAX 0x20
|
||||
#define TAG_GLOBAL_PHYSMIN 0x30
|
||||
#define TAG_GLOBAL_PHYSMAX 0x40
|
||||
#define TAG_GLOBAL_UNITEXP 0x50
|
||||
#define TAG_GLOBAL_UNIT 0x60
|
||||
#define TAG_GLOBAL_REPORTSIZE 0x70
|
||||
#define TAG_GLOBAL_REPORTID 0x80
|
||||
#define TAG_GLOBAL_REPORTCOUNT 0x90
|
||||
#define TAG_GLOBAL_PUSH 0xA0
|
||||
#define TAG_GLOBAL_POP 0xB0
|
||||
#define TAG_MAIN_INPUT 0x80
|
||||
#define TAG_MAIN_OUTPUT 0x90
|
||||
#define TAG_MAIN_COLLECTION 0xA0
|
||||
#define TAG_MAIN_FEATURE 0xB0
|
||||
#define TAG_MAIN_ENDCOLLECTION 0xC0
|
||||
|
||||
#define TAG_LOCAL_USAGE 0x00
|
||||
#define TAG_LOCAL_USAGEMIN 0x10
|
||||
#define TAG_LOCAL_USAGEMAX 0x20
|
||||
#define TAG_GLOBAL_USAGEPAGE 0x00
|
||||
#define TAG_GLOBAL_LOGICALMIN 0x10
|
||||
#define TAG_GLOBAL_LOGICALMAX 0x20
|
||||
#define TAG_GLOBAL_PHYSMIN 0x30
|
||||
#define TAG_GLOBAL_PHYSMAX 0x40
|
||||
#define TAG_GLOBAL_UNITEXP 0x50
|
||||
#define TAG_GLOBAL_UNIT 0x60
|
||||
#define TAG_GLOBAL_REPORTSIZE 0x70
|
||||
#define TAG_GLOBAL_REPORTID 0x80
|
||||
#define TAG_GLOBAL_REPORTCOUNT 0x90
|
||||
#define TAG_GLOBAL_PUSH 0xA0
|
||||
#define TAG_GLOBAL_POP 0xB0
|
||||
|
||||
#define TAG_LOCAL_USAGE 0x00
|
||||
#define TAG_LOCAL_USAGEMIN 0x10
|
||||
#define TAG_LOCAL_USAGEMAX 0x20
|
||||
|
||||
/* HID requests */
|
||||
#define bmREQ_HIDOUT USB_SETUP_HOST_TO_DEVICE|USB_SETUP_TYPE_CLASS|USB_SETUP_RECIPIENT_INTERFACE
|
||||
#define bmREQ_HIDIN USB_SETUP_DEVICE_TO_HOST|USB_SETUP_TYPE_CLASS|USB_SETUP_RECIPIENT_INTERFACE
|
||||
#define bmREQ_HIDREPORT USB_SETUP_DEVICE_TO_HOST|USB_SETUP_TYPE_STANDARD|USB_SETUP_RECIPIENT_INTERFACE
|
||||
#define bmREQ_HIDOUT USB_SETUP_HOST_TO_DEVICE|USB_SETUP_TYPE_CLASS|USB_SETUP_RECIPIENT_INTERFACE
|
||||
#define bmREQ_HIDIN USB_SETUP_DEVICE_TO_HOST|USB_SETUP_TYPE_CLASS|USB_SETUP_RECIPIENT_INTERFACE
|
||||
#define bmREQ_HIDREPORT USB_SETUP_DEVICE_TO_HOST|USB_SETUP_TYPE_STANDARD|USB_SETUP_RECIPIENT_INTERFACE
|
||||
|
||||
/* HID constants. Not part of chapter 9 */
|
||||
/* Class-Specific Requests */
|
||||
#define HID_REQUEST_GET_REPORT 0x01
|
||||
#define HID_REQUEST_GET_IDLE 0x02
|
||||
#define HID_REQUEST_GET_PROTOCOL 0x03
|
||||
#define HID_REQUEST_SET_REPORT 0x09
|
||||
#define HID_REQUEST_SET_IDLE 0x0A
|
||||
#define HID_REQUEST_SET_PROTOCOL 0x0B
|
||||
#define HID_REQUEST_GET_REPORT 0x01
|
||||
#define HID_REQUEST_GET_IDLE 0x02
|
||||
#define HID_REQUEST_GET_PROTOCOL 0x03
|
||||
#define HID_REQUEST_SET_REPORT 0x09
|
||||
#define HID_REQUEST_SET_IDLE 0x0A
|
||||
#define HID_REQUEST_SET_PROTOCOL 0x0B
|
||||
|
||||
/* Class Descriptor Types */
|
||||
#define HID_DESCRIPTOR_HID 0x21
|
||||
#define HID_DESCRIPTOR_REPORT 0x22
|
||||
#define HID_DESRIPTOR_PHY 0x23
|
||||
#define HID_DESCRIPTOR_HID 0x21
|
||||
#define HID_DESCRIPTOR_REPORT 0x22
|
||||
#define HID_DESRIPTOR_PHY 0x23
|
||||
|
||||
/* Protocol Selection */
|
||||
#define HID_BOOT_PROTOCOL 0x00
|
||||
#define HID_RPT_PROTOCOL 0x01
|
||||
#define HID_BOOT_PROTOCOL 0x00
|
||||
#define HID_RPT_PROTOCOL 0x01
|
||||
|
||||
/* HID Interface Class Code */
|
||||
#define HID_INTF 0x03
|
||||
#define HID_INTF 0x03
|
||||
|
||||
/* HID Interface Class SubClass Codes */
|
||||
#define HID_BOOT_INTF_SUBCLASS 0x01
|
||||
#define HID_BOOT_INTF_SUBCLASS 0x01
|
||||
|
||||
/* HID Interface Class Protocol Codes */
|
||||
#define HID_PROTOCOL_NONE 0x00
|
||||
#define HID_PROTOCOL_KEYBOARD 0x01
|
||||
#define HID_PROTOCOL_MOUSE 0x02
|
||||
#define HID_PROTOCOL_NONE 0x00
|
||||
#define HID_PROTOCOL_KEYBOARD 0x01
|
||||
#define HID_PROTOCOL_MOUSE 0x02
|
||||
|
||||
#define HID_ITEM_TYPE_MAIN 0
|
||||
#define HID_ITEM_TYPE_GLOBAL 1
|
||||
#define HID_ITEM_TYPE_LOCAL 2
|
||||
#define HID_ITEM_TYPE_RESERVED 3
|
||||
|
||||
#define HID_LONG_ITEM_PREFIX 0xfe // Long item prefix value
|
||||
|
||||
#define bmHID_MAIN_ITEM_TAG 0xfc // Main item tag mask
|
||||
|
||||
#define bmHID_MAIN_ITEM_INPUT 0x80 // Main item Input tag value
|
||||
#define bmHID_MAIN_ITEM_OUTPUT 0x90 // Main item Output tag value
|
||||
#define bmHID_MAIN_ITEM_FEATURE 0xb0 // Main item Feature tag value
|
||||
#define bmHID_MAIN_ITEM_COLLECTION 0xa0 // Main item Collection tag value
|
||||
#define bmHID_MAIN_ITEM_END_COLLECTION 0xce // Main item End Collection tag value
|
||||
|
||||
#define HID_MAIN_ITEM_COLLECTION_PHYSICAL 0
|
||||
#define HID_MAIN_ITEM_COLLECTION_APPLICATION 1
|
||||
#define HID_MAIN_ITEM_COLLECTION_LOGICAL 2
|
||||
#define HID_MAIN_ITEM_COLLECTION_REPORT 3
|
||||
#define HID_MAIN_ITEM_COLLECTION_NAMED_ARRAY 4
|
||||
#define HID_MAIN_ITEM_COLLECTION_USAGE_SWITCH 5
|
||||
#define HID_MAIN_ITEM_COLLECTION_USAGE_MODIFIER 6
|
||||
|
||||
struct HidItemPrefix {
|
||||
uint8_t bSize : 2;
|
||||
|
@ -96,29 +122,6 @@ struct HidItemPrefix {
|
|||
uint8_t bTag : 4;
|
||||
};
|
||||
|
||||
#define HID_ITEM_TYPE_MAIN 0
|
||||
#define HID_ITEM_TYPE_GLOBAL 1
|
||||
#define HID_ITEM_TYPE_LOCAL 2
|
||||
#define HID_ITEM_TYPE_RESERVED 3
|
||||
|
||||
#define HID_LONG_ITEM_PREFIX 0xfe // Long item prefix value
|
||||
|
||||
#define bmHID_MAIN_ITEM_TAG 0xfc // Main item tag mask
|
||||
|
||||
#define bmHID_MAIN_ITEM_INPUT 0x80 // Main item Input tag value
|
||||
#define bmHID_MAIN_ITEM_OUTPUT 0x90 // Main item Output tag value
|
||||
#define bmHID_MAIN_ITEM_FEATURE 0xb0 // Main item Feature tag value
|
||||
#define bmHID_MAIN_ITEM_COLLECTION 0xa0 // Main item Collection tag value
|
||||
#define bmHID_MAIN_ITEM_END_COLLECTION 0xce // Main item End Collection tag value
|
||||
|
||||
#define HID_MAIN_ITEM_COLLECTION_PHYSICAL 0
|
||||
#define HID_MAIN_ITEM_COLLECTION_APPLICATION 1
|
||||
#define HID_MAIN_ITEM_COLLECTION_LOGICAL 2
|
||||
#define HID_MAIN_ITEM_COLLECTION_REPORT 3
|
||||
#define HID_MAIN_ITEM_COLLECTION_NAMED_ARRAY 4
|
||||
#define HID_MAIN_ITEM_COLLECTION_USAGE_SWITCH 5
|
||||
#define HID_MAIN_ITEM_COLLECTION_USAGE_MODIFIER 6
|
||||
|
||||
struct MainItemIOFeature {
|
||||
uint8_t bmIsConstantOrData : 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;
|
||||
};
|
||||
|
||||
#define MAX_REPORT_PARSERS 2
|
||||
#define HID_MAX_HID_CLASS_DESCRIPTORS 5
|
||||
|
||||
class HID : public USBDeviceConfig, public UsbConfigXtracter {
|
||||
protected:
|
||||
|
|
46
hidboot.h
46
hidboot.h
|
@ -19,11 +19,43 @@ e-mail : support@circuitsathome.com
|
|||
|
||||
#include "hid.h"
|
||||
|
||||
#define KEY_SPACE 0x2c
|
||||
#define KEY_ZERO 0x27
|
||||
#define KEY_ZERO2 0x62
|
||||
#define KEY_ENTER 0x28
|
||||
#define KEY_PERIOD 0x63
|
||||
//
|
||||
// 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_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
|
||||
|
||||
|
||||
struct MOUSEINFO {
|
||||
|
||||
|
@ -107,10 +139,6 @@ struct KBDLEDS {
|
|||
uint8_t bmReserved : 3;
|
||||
};
|
||||
|
||||
#define KEY_NUM_LOCK 0x53
|
||||
#define KEY_CAPS_LOCK 0x39
|
||||
#define KEY_SCROLL_LOCK 0x47
|
||||
|
||||
class KeyboardReportParser : public HIDReportParser {
|
||||
static const uint8_t numKeys[];
|
||||
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 ret = enErrorSuccess;
|
||||
|
||||
switch (itemParseState) {
|
||||
//reinterpret_cast<>(varBuffer);
|
||||
switch (itemParseState) {
|
||||
case 0:
|
||||
if (**pp == HID_LONG_ITEM_PREFIX)
|
||||
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)) {
|
||||
case (TYPE_LOCAL | TAG_LOCAL_USAGE):
|
||||
if (pfUsage) {
|
||||
if (theBuffer.valueSize > 1)
|
||||
pfUsage(*((uint16_t*)varBuffer));
|
||||
else
|
||||
if (theBuffer.valueSize > 1) {
|
||||
uint16_t* ui16 = reinterpret_cast<uint16_t *>(varBuffer);
|
||||
pfUsage(*ui16);
|
||||
} else
|
||||
pfUsage(data);
|
||||
}
|
||||
break;
|
||||
|
@ -1237,16 +1238,19 @@ void ReportDescParserBase::SetUsagePage(uint16_t page) {
|
|||
}
|
||||
|
||||
void ReportDescParserBase::PrintUsagePage(uint16_t page) {
|
||||
const char * const * w;
|
||||
E_Notify(pstrSpace, 0x80);
|
||||
|
||||
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)
|
||||
E_Notify(pstrUsagePageMonitor, 0x80);
|
||||
else if (page > 0x83 && page < 0x8c)
|
||||
E_Notify(pstrUsagePagePower, 0x80);
|
||||
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)
|
||||
E_Notify(pstrUsagePageVendorDefined, 0x80);
|
||||
else
|
||||
|
@ -1280,188 +1284,249 @@ void ReportDescParserBase::PrintOrdinalPageUsage(uint16_t usage) {
|
|||
}
|
||||
|
||||
void ReportDescParserBase::PrintGenericDesktopPageUsage(uint16_t usage) {
|
||||
const char * const * w;
|
||||
E_Notify(pstrSpace, 0x80);
|
||||
|
||||
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)
|
||||
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)
|
||||
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)
|
||||
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)
|
||||
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
|
||||
E_Notify(pstrUsagePageUndefined, 0x80);
|
||||
}
|
||||
|
||||
void ReportDescParserBase::PrintSimulationControlsPageUsage(uint16_t usage) {
|
||||
const char * const * w;
|
||||
E_Notify(pstrSpace, 0x80);
|
||||
|
||||
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)
|
||||
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)
|
||||
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
|
||||
E_Notify(pstrUsagePageUndefined, 0x80);
|
||||
}
|
||||
|
||||
void ReportDescParserBase::PrintVRControlsPageUsage(uint16_t usage) {
|
||||
const char * const * w;
|
||||
E_Notify(pstrSpace, 0x80);
|
||||
|
||||
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)
|
||||
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
|
||||
E_Notify(pstrUsagePageUndefined, 0x80);
|
||||
}
|
||||
|
||||
void ReportDescParserBase::PrintSportsControlsPageUsage(uint16_t usage) {
|
||||
const char * const * w;
|
||||
E_Notify(pstrSpace, 0x80);
|
||||
|
||||
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)
|
||||
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)
|
||||
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
|
||||
E_Notify(pstrUsagePageUndefined, 0x80);
|
||||
}
|
||||
|
||||
void ReportDescParserBase::PrintGameControlsPageUsage(uint16_t usage) {
|
||||
const char * const * w;
|
||||
E_Notify(pstrSpace, 0x80);
|
||||
|
||||
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)
|
||||
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
|
||||
E_Notify(pstrUsagePageUndefined, 0x80);
|
||||
}
|
||||
|
||||
void ReportDescParserBase::PrintGenericDeviceControlsPageUsage(uint16_t usage) {
|
||||
const char * const * w;
|
||||
E_Notify(pstrSpace, 0x80);
|
||||
|
||||
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
|
||||
E_Notify(pstrUsagePageUndefined, 0x80);
|
||||
}
|
||||
|
||||
void ReportDescParserBase::PrintLEDPageUsage(uint16_t usage) {
|
||||
const char * const * w;
|
||||
E_Notify(pstrSpace, 0x80);
|
||||
|
||||
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
|
||||
E_Notify(pstrUsagePageUndefined, 0x80);
|
||||
}
|
||||
|
||||
void ReportDescParserBase::PrintTelephonyPageUsage(uint16_t usage) {
|
||||
const char * const * w;
|
||||
E_Notify(pstrSpace, 0x80);
|
||||
|
||||
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)
|
||||
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)
|
||||
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)
|
||||
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)
|
||||
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)
|
||||
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
|
||||
E_Notify(pstrUsagePageUndefined, 0x80);
|
||||
}
|
||||
|
||||
void ReportDescParserBase::PrintConsumerPageUsage(uint16_t usage) {
|
||||
const char * const * w;
|
||||
E_Notify(pstrSpace, 0x80);
|
||||
|
||||
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)
|
||||
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)
|
||||
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)
|
||||
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)
|
||||
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)
|
||||
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)
|
||||
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)
|
||||
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)
|
||||
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)
|
||||
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)
|
||||
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)
|
||||
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)
|
||||
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)
|
||||
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)
|
||||
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
|
||||
E_Notify(pstrUsagePageUndefined, 0x80);
|
||||
}
|
||||
|
||||
void ReportDescParserBase::PrintDigitizerPageUsage(uint16_t usage) {
|
||||
const char * const * w;
|
||||
E_Notify(pstrSpace, 0x80);
|
||||
|
||||
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)
|
||||
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)
|
||||
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
|
||||
E_Notify(pstrUsagePageUndefined, 0x80);
|
||||
}
|
||||
|
||||
void ReportDescParserBase::PrintAlphanumDisplayPageUsage(uint16_t usage) {
|
||||
const char * const * w;
|
||||
E_Notify(pstrSpace, 0x80);
|
||||
|
||||
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)
|
||||
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)
|
||||
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
|
||||
E_Notify(pstrUsagePageUndefined, 0x80);
|
||||
}
|
||||
|
||||
void ReportDescParserBase::PrintMedicalInstrumentPageUsage(uint16_t usage) {
|
||||
const char * const * w;
|
||||
E_Notify(pstrSpace, 0x80);
|
||||
|
||||
//output_pgm_message(w, E_Notify, , 0x80);
|
||||
if (usage == 1)
|
||||
E_Notify(pstrUsageMedicalUltrasound, 0x80);
|
||||
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)
|
||||
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)
|
||||
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)
|
||||
E_Notify(pstrUsageDepthGainCompensation, 0x80);
|
||||
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)
|
||||
E_Notify((char*)pgm_read_pointer(&medInstrTitles4[usage - 0xa0]), 0x80);
|
||||
else
|
||||
// E_Notify((char*)pgm_read_pointer(&medInstrTitles4[usage - 0xa0]), 0x80);
|
||||
output_pgm_message(w, E_Notify, medInstrTitles4[usage - 0xa0], 0x80);
|
||||
else
|
||||
E_Notify(pstrUsagePageUndefined, 0x80);
|
||||
}
|
||||
|
||||
|
@ -1502,9 +1567,10 @@ uint8_t ReportDescParser2::ParseItem(uint8_t **pp, uint16_t *pcntdn) {
|
|||
switch (itemPrefix & (TYPE_MASK | TAG_MASK)) {
|
||||
case (TYPE_LOCAL | TAG_LOCAL_USAGE):
|
||||
if (pfUsage) {
|
||||
if (theBuffer.valueSize > 1)
|
||||
pfUsage(*((uint16_t*)varBuffer));
|
||||
else
|
||||
if (theBuffer.valueSize > 1) {
|
||||
uint16_t* ui16 = reinterpret_cast<uint16_t *>(varBuffer);
|
||||
pfUsage(*ui16);
|
||||
} else
|
||||
pfUsage(data);
|
||||
}
|
||||
break;
|
||||
|
|
|
@ -126,7 +126,8 @@ public:
|
|||
itemPrefix(0),
|
||||
rptSize(0),
|
||||
rptCount(0),
|
||||
pfUsage(NULL) {
|
||||
pfUsage(NULL)
|
||||
{
|
||||
theBuffer.pValue = varBuffer;
|
||||
valParser.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);
|
||||
|
||||
uint8_t buf[constBufSize];
|
||||
USB_DEVICE_DESCRIPTOR * udd = reinterpret_cast<USB_DEVICE_DESCRIPTOR*>(buf);
|
||||
uint8_t rcode;
|
||||
UsbDevice *p = 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;
|
||||
|
||||
// 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
|
||||
rcode = pUsb->setAddr(0, 0, bAddress);
|
||||
|
@ -147,7 +148,7 @@ uint8_t HIDUniversal::Init(uint8_t parent, uint8_t port, bool lowspeed) {
|
|||
return rcode;
|
||||
}
|
||||
|
||||
delay( 2 ); //per USB 2.0 sect.9.2.6.3
|
||||
delay( 2 ); //per USB 2.0 sect.9.2.6.3
|
||||
|
||||
USBTRACE2("Addr:", bAddress);
|
||||
|
||||
|
@ -166,7 +167,7 @@ uint8_t HIDUniversal::Init(uint8_t parent, uint8_t port, bool lowspeed) {
|
|||
if (rcode)
|
||||
goto FailGetDevDescr;
|
||||
|
||||
num_of_conf = ((USB_DEVICE_DESCRIPTOR*)buf)->bNumConfigurations;
|
||||
num_of_conf = udd->bNumConfigurations;
|
||||
|
||||
// Assign epInfo to epinfo pointer
|
||||
rcode = pUsb->setEpInfoEntry(bAddress, 1, epInfo);
|
||||
|
@ -252,8 +253,8 @@ FailSetIdle:
|
|||
USBTRACE("SetIdle:");
|
||||
#endif
|
||||
|
||||
Fail:
|
||||
#ifdef DEBUG_USB_HOST
|
||||
Fail:
|
||||
NotifyFail(rcode);
|
||||
#endif
|
||||
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);
|
||||
|
||||
uint8_t buf[constBufSize];
|
||||
USB_DEVICE_DESCRIPTOR * udd = reinterpret_cast<USB_DEVICE_DESCRIPTOR*>(buf);
|
||||
uint8_t rcode;
|
||||
UsbDevice *p = 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;
|
||||
|
||||
// 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.
|
||||
epInfo[1].epAddr = ((USB_DEVICE_DESCRIPTOR*)buf)->bNumConfigurations;
|
||||
epInfo[1].epAddr = udd->bNumConfigurations;
|
||||
// </TECHNICAL>
|
||||
return USB_ERROR_CONFIG_REQUIRES_ADDITIONAL_RESET;
|
||||
|
||||
|
@ -294,7 +295,6 @@ FailGetDevDescr:
|
|||
#endif
|
||||
rcode = USB_ERROR_FailGetDevDescr;
|
||||
|
||||
Fail:
|
||||
Release();
|
||||
return rcode;
|
||||
};
|
||||
|
@ -436,7 +436,7 @@ uint8_t BulkOnly::Init(uint8_t parent, uint8_t port, bool lowspeed) {
|
|||
printf(" standards.\r\n");
|
||||
#endif
|
||||
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.
|
||||
// try to lock media and spin up
|
||||
if (tries < 14) {
|
||||
|
@ -489,8 +489,8 @@ FailGetMaxLUN:
|
|||
goto Fail;
|
||||
#endif
|
||||
|
||||
FailInvalidSectorSize:
|
||||
#ifdef DEBUG_USB_HOST
|
||||
FailInvalidSectorSize:
|
||||
USBTRACE("Sector Size is NOT VALID: ");
|
||||
goto Fail;
|
||||
#endif
|
||||
|
@ -506,8 +506,8 @@ FailGetConfDescr:
|
|||
NotifyFailGetConfDescr();
|
||||
#endif
|
||||
|
||||
Fail:
|
||||
#ifdef DEBUG_USB_HOST
|
||||
Fail:
|
||||
NotifyFail(rcode);
|
||||
#endif
|
||||
Release();
|
||||
|
@ -808,9 +808,8 @@ uint8_t BulkOnly::ClearEpHalt(uint8_t index) {
|
|||
|
||||
uint8_t ret = 0;
|
||||
|
||||
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) delay(6);
|
||||
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))
|
||||
delay(6);
|
||||
|
||||
if (ret) {
|
||||
ErrorMessage<uint8_t > (PSTR("ClearEpHalt"), ret);
|
||||
|
|
|
@ -394,7 +394,7 @@ public:
|
|||
bmCBWLUN(lu), bmReserved1(0), bmCBWCBLength(cmdlen), bmReserved2(0) {
|
||||
for(int i = 0; i < 16; i++) CBWCB[i] = 0;
|
||||
// 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 *x = reinterpret_cast<BASICCDB_t *> (CBWCB);
|
||||
x->LUN = cmd;
|
||||
|
|
|
@ -44,7 +44,7 @@ void E_NotifyStr(char const * msg, int lvl) {
|
|||
if (!msg) return;
|
||||
char c;
|
||||
|
||||
while (c = *msg++) E_Notifyc(c, lvl);
|
||||
while ((c = *msg++)) E_Notifyc(c, 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 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;
|
||||
UsbDevice *p = 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
|
||||
// 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;
|
||||
|
||||
// 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)
|
||||
return USB_ERROR_OUT_OF_ADDRESS_SPACE_IN_POOL;
|
||||
|
||||
// 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
|
||||
rcode = pUsb->setAddr(0, 0, bAddress);
|
||||
|
@ -140,7 +143,7 @@ uint8_t USBHub::Init(uint8_t parent, uint8_t port, bool lowspeed) {
|
|||
goto FailGetHubDescr;
|
||||
|
||||
// Save number of ports for future use
|
||||
bNbrPorts = ((HubDescriptor*)buf)->bNbrPorts;
|
||||
bNbrPorts = hd->bNbrPorts;
|
||||
|
||||
// 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);
|
||||
|
||||
if (!rcode) {
|
||||
cd_len = ((USB_CONFIGURATION_DESCRIPTOR*)buf)->wTotalLength;
|
||||
cd_len = ucd->wTotalLength;
|
||||
rcode = pUsb->getConfDescr(bAddress, 0, cd_len, 0, buf);
|
||||
}
|
||||
if (rcode)
|
||||
|
|
Loading…
Reference in a new issue