From 6c36eed2394b7416f6cfa0a18b4376c4af6832e6 Mon Sep 17 00:00:00 2001 From: Kristian Sloth Lauszus Date: Tue, 19 Jan 2016 16:34:45 +0100 Subject: [PATCH] Renamed USB class to USBHost, so it does not collide with the one defined in the Arduino Zero core Also renamed the struct UsbDevice to UsbDeviceDefinition --- .travis.yml | 2 +- BTD.cpp | 8 +++--- BTD.h | 8 +++--- BTHID.cpp | 2 +- PS3BT.cpp | 2 +- PS3USB.cpp | 6 ++--- PS3USB.h | 8 +++--- PS4USB.h | 4 +-- PSBuzz.h | 4 +-- Usb.cpp | 64 +++++++++++++++++++++++------------------------ UsbCore.h | 14 +++++------ Wii.cpp | 2 +- XBOXOLD.cpp | 6 ++--- XBOXOLD.h | 8 +++--- XBOXONE.cpp | 6 ++--- XBOXONE.h | 8 +++--- XBOXRECV.cpp | 8 +++--- XBOXRECV.h | 8 +++--- XBOXUSB.cpp | 6 ++--- XBOXUSB.h | 8 +++--- address.h | 10 ++++---- adk.cpp | 6 ++--- adk.h | 4 +-- cdc_XR21B1411.cpp | 4 +-- cdc_XR21B1411.h | 2 +- cdcacm.cpp | 4 +-- cdcacm.h | 4 +-- cdcftdi.cpp | 4 +-- cdcftdi.h | 4 +-- cdcprolific.cpp | 4 +-- cdcprolific.h | 2 +- hidboot.h | 6 ++--- hiduniversal.cpp | 4 +-- hiduniversal.h | 2 +- keywords.txt | 2 +- masstorage.cpp | 6 ++--- masstorage.h | 4 +-- max_LCD.cpp | 2 +- max_LCD.h | 4 +-- usbhid.h | 10 ++++---- usbhub.cpp | 4 +-- usbhub.h | 6 ++--- 42 files changed, 140 insertions(+), 140 deletions(-) diff --git a/.travis.yml b/.travis.yml index b02d84a4..1a8deafe 100644 --- a/.travis.yml +++ b/.travis.yml @@ -64,4 +64,4 @@ install: - platformio lib install 416 417 script: - - platformio ci --board=uno --board=teensy31 --board=due --lib="." + - platformio ci --board=uno --board=teensy31 --board=due --board=zero --lib="." diff --git a/BTD.cpp b/BTD.cpp index b3b41a7f..a8d5179f 100755 --- a/BTD.cpp +++ b/BTD.cpp @@ -24,12 +24,12 @@ const uint8_t BTD::BTD_EVENT_PIPE = 1; const uint8_t BTD::BTD_DATAIN_PIPE = 2; const uint8_t BTD::BTD_DATAOUT_PIPE = 3; -BTD::BTD(USB *p) : +BTD::BTD(USBHost *p) : connectToWii(false), pairWithWii(false), connectToHIDDevice(false), pairWithHIDDevice(false), -pUsb(p), // Pointer to USB class instance - mandatory +pUsb(p), // Pointer to USBHost class instance - mandatory bAddress(0), // Device address - mandatory bNumEP(1), // If config descriptor needs to be parsed qNextPollTime(0), // Reset NextPollTime @@ -50,7 +50,7 @@ uint8_t BTD::ConfigureDevice(uint8_t parent, uint8_t port, bool lowspeed) { uint8_t buf[constBufSize]; USB_DEVICE_DESCRIPTOR * udd = reinterpret_cast(buf); uint8_t rcode; - UsbDevice *p = NULL; + UsbDeviceDefinition *p = NULL; EpInfo *oldep_ptr = NULL; Initialize(); // Set all variables, endpoint structs etc. to default values @@ -140,7 +140,7 @@ uint8_t BTD::Init(uint8_t parent, uint8_t port, bool lowspeed) { #ifdef EXTRADEBUG Notify(PSTR("\r\nBTD Init"), 0x80); #endif - UsbDevice *p = addrPool.GetUsbDevicePtr(bAddress); // Get pointer to assigned address record + UsbDeviceDefinition *p = addrPool.GetUsbDevicePtr(bAddress); // Get pointer to assigned address record if(!p) { #ifdef DEBUG_USB_HOST diff --git a/BTD.h b/BTD.h index 214931a8..2c7d81ce 100755 --- a/BTD.h +++ b/BTD.h @@ -199,9 +199,9 @@ class BTD : public USBDeviceConfig, public UsbConfigXtracter { public: /** * Constructor for the BTD class. - * @param p Pointer to USB class instance. + * @param p Pointer to USBHost class instance. */ - BTD(USB *p); + BTD(USBHost *p); /** @name USBDeviceConfig implementation */ /** @@ -497,8 +497,8 @@ public: }; protected: - /** Pointer to USB class instance. */ - USB *pUsb; + /** Pointer to USBHost class instance. */ + USBHost *pUsb; /** Device address. */ uint8_t bAddress; /** Endpoint info structure. */ diff --git a/BTHID.cpp b/BTHID.cpp index d32e9aa6..80f8eae0 100644 --- a/BTHID.cpp +++ b/BTHID.cpp @@ -21,7 +21,7 @@ //#define PRINTREPORT // Uncomment to print the report send by the HID device BTHID::BTHID(BTD *p, bool pair, const char *pin) : -BluetoothService(p), // Pointer to USB class instance - mandatory +BluetoothService(p), // Pointer to BTD class instance - mandatory protocolMode(USB_HID_BOOT_PROTOCOL) { for(uint8_t i = 0; i < NUM_PARSERS; i++) pRptParser[i] = NULL; diff --git a/PS3BT.cpp b/PS3BT.cpp index ab5a8ed5..e3b8529d 100644 --- a/PS3BT.cpp +++ b/PS3BT.cpp @@ -21,7 +21,7 @@ //#define PRINTREPORT // Uncomment to print the report send by the PS3 Controllers PS3BT::PS3BT(BTD *p, uint8_t btadr5, uint8_t btadr4, uint8_t btadr3, uint8_t btadr2, uint8_t btadr1, uint8_t btadr0) : -BluetoothService(p) // Pointer to USB class instance - mandatory +BluetoothService(p) // Pointer to BTD class instance - mandatory { pBtd->my_bdaddr[5] = btadr5; // Change to your dongle's Bluetooth address instead pBtd->my_bdaddr[4] = btadr4; diff --git a/PS3USB.cpp b/PS3USB.cpp index f247cc91..fcb22c40 100755 --- a/PS3USB.cpp +++ b/PS3USB.cpp @@ -20,8 +20,8 @@ //#define EXTRADEBUG // Uncomment to get even more debugging data //#define PRINTREPORT // Uncomment to print the report send by the PS3 Controllers -PS3USB::PS3USB(USB *p, uint8_t btadr5, uint8_t btadr4, uint8_t btadr3, uint8_t btadr2, uint8_t btadr1, uint8_t btadr0) : -pUsb(p), // pointer to USB class instance - mandatory +PS3USB::PS3USB(USBHost *p, uint8_t btadr5, uint8_t btadr4, uint8_t btadr3, uint8_t btadr2, uint8_t btadr1, uint8_t btadr0) : +pUsb(p), // pointer to USBHost class instance - mandatory bAddress(0), // device address - mandatory bPollEnable(false) // don't start polling before dongle is connected { @@ -48,7 +48,7 @@ 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(buf); uint8_t rcode; - UsbDevice *p = NULL; + UsbDeviceDefinition *p = NULL; EpInfo *oldep_ptr = NULL; uint16_t PID; uint16_t VID; diff --git a/PS3USB.h b/PS3USB.h index 338aa7af..bf2d7699 100644 --- a/PS3USB.h +++ b/PS3USB.h @@ -50,12 +50,12 @@ class PS3USB : public USBDeviceConfig { public: /** * Constructor for the PS3USB class. - * @param pUsb Pointer to USB class instance. + * @param pUsb Pointer to USBHost class instance. * @param btadr5,btadr4,btadr3,btadr2,btadr1,btadr0 * Pass your dongles Bluetooth address into the constructor, * so you are able to pair the controller with a Bluetooth dongle. */ - PS3USB(USB *pUsb, uint8_t btadr5 = 0, uint8_t btadr4 = 0, uint8_t btadr3 = 0, uint8_t btadr2 = 0, uint8_t btadr1 = 0, uint8_t btadr0 = 0); + PS3USB(USBHost *pUsb, uint8_t btadr5 = 0, uint8_t btadr4 = 0, uint8_t btadr3 = 0, uint8_t btadr2 = 0, uint8_t btadr1 = 0, uint8_t btadr0 = 0); /** @name USBDeviceConfig implementation */ /** @@ -264,8 +264,8 @@ public: bool PS3NavigationConnected; protected: - /** Pointer to USB class instance. */ - USB *pUsb; + /** Pointer to USBHost class instance. */ + USBHost *pUsb; /** Device address. */ uint8_t bAddress; /** Endpoint info structure. */ diff --git a/PS4USB.h b/PS4USB.h index b5346ff6..2d525a6f 100644 --- a/PS4USB.h +++ b/PS4USB.h @@ -32,9 +32,9 @@ class PS4USB : public HIDUniversal, public PS4Parser { public: /** * Constructor for the PS4USB class. - * @param p Pointer to the USB class instance. + * @param p Pointer to the USBHost class instance. */ - PS4USB(USB *p) : + PS4USB(USBHost *p) : HIDUniversal(p) { PS4Parser::Reset(); }; diff --git a/PSBuzz.h b/PSBuzz.h index da83dff0..b87f83aa 100644 --- a/PSBuzz.h +++ b/PSBuzz.h @@ -44,9 +44,9 @@ class PSBuzz : public HIDUniversal { public: /** * Constructor for the PSBuzz class. - * @param p Pointer to the USB class instance. + * @param p Pointer to the USBHost class instance. */ - PSBuzz(USB *p) : + PSBuzz(USBHost *p) : HIDUniversal(p) { Reset(); }; diff --git a/Usb.cpp b/Usb.cpp index d6755c9d..bef4c37c 100644 --- a/Usb.cpp +++ b/Usb.cpp @@ -22,27 +22,27 @@ static uint8_t usb_error = 0; static uint8_t usb_task_state; /* constructor */ -USB::USB() : bmHubPre(0) { +USBHost::USBHost() : bmHubPre(0) { usb_task_state = USB_DETACHED_SUBSTATE_INITIALIZE; //set up state machine init(); } /* Initialize data structures */ -void USB::init() { +void USBHost::init() { //devConfigIndex = 0; bmHubPre = 0; } -uint8_t USB::getUsbTaskState(void) { +uint8_t USBHost::getUsbTaskState(void) { return ( usb_task_state); } -void USB::setUsbTaskState(uint8_t state) { +void USBHost::setUsbTaskState(uint8_t state) { usb_task_state = state; } -EpInfo* USB::getEpInfoEntry(uint8_t addr, uint8_t ep) { - UsbDevice *p = addrPool.GetUsbDevicePtr(addr); +EpInfo* USBHost::getEpInfoEntry(uint8_t addr, uint8_t ep) { + UsbDeviceDefinition *p = addrPool.GetUsbDevicePtr(addr); if(!p || !p->epinfo) return NULL; @@ -61,11 +61,11 @@ EpInfo* USB::getEpInfoEntry(uint8_t addr, uint8_t ep) { /* set device table entry */ /* each device is different and has different number of endpoints. This function plugs endpoint record structure, defined in application, to devtable */ -uint8_t USB::setEpInfoEntry(uint8_t addr, uint8_t epcount, EpInfo* eprecord_ptr) { +uint8_t USBHost::setEpInfoEntry(uint8_t addr, uint8_t epcount, EpInfo* eprecord_ptr) { if(!eprecord_ptr) return USB_ERROR_INVALID_ARGUMENT; - UsbDevice *p = addrPool.GetUsbDevicePtr(addr); + UsbDeviceDefinition *p = addrPool.GetUsbDevicePtr(addr); if(!p) return USB_ERROR_ADDRESS_NOT_FOUND_IN_POOL; @@ -77,8 +77,8 @@ uint8_t USB::setEpInfoEntry(uint8_t addr, uint8_t epcount, EpInfo* eprecord_ptr) return 0; } -uint8_t USB::SetAddress(uint8_t addr, uint8_t ep, EpInfo **ppep, uint16_t *nak_limit) { - UsbDevice *p = addrPool.GetUsbDevicePtr(addr); +uint8_t USBHost::SetAddress(uint8_t addr, uint8_t ep, EpInfo **ppep, uint16_t *nak_limit) { + UsbDeviceDefinition *p = addrPool.GetUsbDevicePtr(addr); if(!p) return USB_ERROR_ADDRESS_NOT_FOUND_IN_POOL; @@ -123,7 +123,7 @@ uint8_t USB::SetAddress(uint8_t addr, uint8_t ep, EpInfo **ppep, uint16_t *nak_l /* 00 = success */ /* 01-0f = non-zero HRSLT */ -uint8_t USB::ctrlReq(uint8_t addr, uint8_t ep, uint8_t bmReqType, uint8_t bRequest, uint8_t wValLo, uint8_t wValHi, +uint8_t USBHost::ctrlReq(uint8_t addr, uint8_t ep, uint8_t bmReqType, uint8_t bRequest, uint8_t wValLo, uint8_t wValHi, uint16_t wInd, uint16_t total, uint16_t nbytes, uint8_t* dataptr, USBReadParser *p) { bool direction = false; //request direction, IN or OUT uint8_t rcode; @@ -203,22 +203,22 @@ uint8_t USB::ctrlReq(uint8_t addr, uint8_t ep, uint8_t bmReqType, uint8_t bReque /* rcode 0 if no errors. rcode 01-0f is relayed from dispatchPkt(). Rcode f0 means RCVDAVIRQ error, fe USB xfer timeout */ -uint8_t USB::inTransfer(uint8_t addr, uint8_t ep, uint16_t *nbytesptr, uint8_t* data, uint8_t bInterval /*= 0*/) { +uint8_t USBHost::inTransfer(uint8_t addr, uint8_t ep, uint16_t *nbytesptr, uint8_t* data, uint8_t bInterval /*= 0*/) { EpInfo *pep = NULL; uint16_t nak_limit = 0; uint8_t rcode = SetAddress(addr, ep, &pep, &nak_limit); if(rcode) { - USBTRACE3("(USB::InTransfer) SetAddress Failed ", rcode, 0x81); - USBTRACE3("(USB::InTransfer) addr requested ", addr, 0x81); - USBTRACE3("(USB::InTransfer) ep requested ", ep, 0x81); + USBTRACE3("(USBHost::InTransfer) SetAddress Failed ", rcode, 0x81); + USBTRACE3("(USBHost::InTransfer) addr requested ", addr, 0x81); + USBTRACE3("(USBHost::InTransfer) ep requested ", ep, 0x81); return rcode; } return InTransfer(pep, nak_limit, nbytesptr, data, bInterval); } -uint8_t USB::InTransfer(EpInfo *pep, uint16_t nak_limit, uint16_t *nbytesptr, uint8_t* data, uint8_t bInterval /*= 0*/) { +uint8_t USBHost::InTransfer(EpInfo *pep, uint16_t nak_limit, uint16_t *nbytesptr, uint8_t* data, uint8_t bInterval /*= 0*/) { uint8_t rcode = 0; uint8_t pktsize; @@ -290,7 +290,7 @@ uint8_t USB::InTransfer(EpInfo *pep, uint16_t nak_limit, uint16_t *nbytesptr, ui /* Handles NAK bug per Maxim Application Note 4000 for single buffer transfer */ /* rcode 0 if no errors. rcode 01-0f is relayed from HRSL */ -uint8_t USB::outTransfer(uint8_t addr, uint8_t ep, uint16_t nbytes, uint8_t* data) { +uint8_t USBHost::outTransfer(uint8_t addr, uint8_t ep, uint16_t nbytes, uint8_t* data) { EpInfo *pep = NULL; uint16_t nak_limit = 0; @@ -302,7 +302,7 @@ uint8_t USB::outTransfer(uint8_t addr, uint8_t ep, uint16_t nbytes, uint8_t* dat return OutTransfer(pep, nak_limit, nbytes, data); } -uint8_t USB::OutTransfer(EpInfo *pep, uint16_t nak_limit, uint16_t nbytes, uint8_t *data) { +uint8_t USBHost::OutTransfer(EpInfo *pep, uint16_t nak_limit, uint16_t nbytes, uint8_t *data) { uint8_t rcode = hrSUCCESS, retry_count; uint8_t *data_p = data; //local copy of the data pointer uint16_t bytes_tosend, nak_count; @@ -374,7 +374,7 @@ breakout: /* If bus timeout, re-sends up to USB_RETRY_LIMIT times */ /* return codes 0x00-0x0f are HRSLT( 0x00 being success ), 0xff means timeout */ -uint8_t USB::dispatchPkt(uint8_t token, uint8_t ep, uint16_t nak_limit) { +uint8_t USBHost::dispatchPkt(uint8_t token, uint8_t ep, uint16_t nak_limit) { unsigned long timeout = millis() + USB_XFER_TIMEOUT; uint8_t tmpdata; uint8_t rcode = hrSUCCESS; @@ -422,7 +422,7 @@ uint8_t USB::dispatchPkt(uint8_t token, uint8_t ep, uint16_t nak_limit) { } /* USB main task. Performs enumeration/cleanup */ -void USB::Task(void) //USB state machine +void USBHost::Task(void) //USB state machine { uint8_t rcode; uint8_t tmpdata; @@ -528,10 +528,10 @@ void USB::Task(void) //USB state machine } // switch( usb_task_state ) } -uint8_t USB::DefaultAddressing(uint8_t parent, uint8_t port, bool lowspeed) { +uint8_t USBHost::DefaultAddressing(uint8_t parent, uint8_t port, bool lowspeed) { //uint8_t buf[12]; uint8_t rcode; - UsbDevice *p0 = NULL, *p = NULL; + UsbDeviceDefinition *p0 = NULL, *p = NULL; // Get pointer to pseudo device with address 0 assigned p0 = addrPool.GetUsbDevicePtr(0); @@ -568,7 +568,7 @@ uint8_t USB::DefaultAddressing(uint8_t parent, uint8_t port, bool lowspeed) { return 0; }; -uint8_t USB::AttemptConfig(uint8_t driver, uint8_t parent, uint8_t port, bool lowspeed) { +uint8_t USBHost::AttemptConfig(uint8_t driver, uint8_t parent, uint8_t port, bool lowspeed) { //printf("AttemptConfig: parent = %i, port = %i\r\n", parent, port); uint8_t retries = 0; @@ -650,14 +650,14 @@ again: * 8: if we get here, no driver likes the device plugged in, so exit failure. * */ -uint8_t USB::Configuring(uint8_t parent, uint8_t port, bool lowspeed) { +uint8_t USBHost::Configuring(uint8_t parent, uint8_t port, bool lowspeed) { //uint8_t bAddress = 0; //printf("Configuring: parent = %i, port = %i\r\n", parent, port); uint8_t devConfigIndex; uint8_t rcode = 0; uint8_t buf[sizeof (USB_DEVICE_DESCRIPTOR)]; USB_DEVICE_DESCRIPTOR *udd = reinterpret_cast(buf); - UsbDevice *p = NULL; + UsbDeviceDefinition *p = NULL; EpInfo *oldep_ptr = NULL; EpInfo epInfo; @@ -748,7 +748,7 @@ uint8_t USB::Configuring(uint8_t parent, uint8_t port, bool lowspeed) { return rcode; } -uint8_t USB::ReleaseDevice(uint8_t addr) { +uint8_t USBHost::ReleaseDevice(uint8_t addr) { if(!addr) return 0; @@ -763,18 +763,18 @@ uint8_t USB::ReleaseDevice(uint8_t addr) { #if 1 //!defined(USB_METHODS_INLINE) //get device descriptor -uint8_t USB::getDevDescr(uint8_t addr, uint8_t ep, uint16_t nbytes, uint8_t* dataptr) { +uint8_t USBHost::getDevDescr(uint8_t addr, uint8_t ep, uint16_t nbytes, uint8_t* dataptr) { return ( ctrlReq(addr, ep, bmREQ_GET_DESCR, USB_REQUEST_GET_DESCRIPTOR, 0x00, USB_DESCRIPTOR_DEVICE, 0x0000, nbytes, nbytes, dataptr, NULL)); } //get configuration descriptor -uint8_t USB::getConfDescr(uint8_t addr, uint8_t ep, uint16_t nbytes, uint8_t conf, uint8_t* dataptr) { +uint8_t USBHost::getConfDescr(uint8_t addr, uint8_t ep, uint16_t nbytes, uint8_t conf, uint8_t* dataptr) { return ( ctrlReq(addr, ep, bmREQ_GET_DESCR, USB_REQUEST_GET_DESCRIPTOR, conf, USB_DESCRIPTOR_CONFIGURATION, 0x0000, nbytes, nbytes, dataptr, NULL)); } /* Requests Configuration Descriptor. Sends two Get Conf Descr requests. The first one gets the total length of all descriptors, then the second one requests this total length. The length of the first request can be shorter ( 4 bytes ), however, there are devices which won't work unless this length is set to 9 */ -uint8_t USB::getConfDescr(uint8_t addr, uint8_t ep, uint8_t conf, USBReadParser *p) { +uint8_t USBHost::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(buf); @@ -793,12 +793,12 @@ uint8_t USB::getConfDescr(uint8_t addr, uint8_t ep, uint8_t conf, USBReadParser //get string descriptor -uint8_t USB::getStrDescr(uint8_t addr, uint8_t ep, uint16_t ns, uint8_t index, uint16_t langid, uint8_t* dataptr) { +uint8_t USBHost::getStrDescr(uint8_t addr, uint8_t ep, uint16_t ns, uint8_t index, uint16_t langid, uint8_t* dataptr) { return ( ctrlReq(addr, ep, bmREQ_GET_DESCR, USB_REQUEST_GET_DESCRIPTOR, index, USB_DESCRIPTOR_STRING, langid, ns, ns, dataptr, NULL)); } //set address -uint8_t USB::setAddr(uint8_t oldaddr, uint8_t ep, uint8_t newaddr) { +uint8_t USBHost::setAddr(uint8_t oldaddr, uint8_t ep, uint8_t newaddr) { uint8_t rcode = ctrlReq(oldaddr, ep, bmREQ_SET, USB_REQUEST_SET_ADDRESS, newaddr, 0x00, 0x0000, 0x0000, 0x0000, NULL, NULL); //delay(2); //per USB 2.0 sect.9.2.6.3 delay(300); // Older spec says you should wait at least 200ms @@ -807,7 +807,7 @@ uint8_t USB::setAddr(uint8_t oldaddr, uint8_t ep, uint8_t newaddr) { } //set configuration -uint8_t USB::setConf(uint8_t addr, uint8_t ep, uint8_t conf_value) { +uint8_t USBHost::setConf(uint8_t addr, uint8_t ep, uint8_t conf_value) { return ( ctrlReq(addr, ep, bmREQ_SET, USB_REQUEST_SET_CONFIGURATION, conf_value, 0x00, 0x0000, 0x0000, 0x0000, NULL, NULL)); } diff --git a/UsbCore.h b/UsbCore.h index fdec87b0..904fdd90 100644 --- a/UsbCore.h +++ b/UsbCore.h @@ -194,13 +194,13 @@ public: virtual void Parse(const uint16_t len, const uint8_t *pbuf, const uint16_t &offset) = 0; }; -class USB : public MAX3421E { +class USBHost : public MAX3421E { AddressPoolImpl addrPool; USBDeviceConfig* devConfig[USB_NUMDEVICES]; uint8_t bmHubPre; public: - USB(void); + USBHost(void); void SetHubPreMask() { bmHubPre |= bmHUBPRE; @@ -269,27 +269,27 @@ private: #if 0 //defined(USB_METHODS_INLINE) //get device descriptor -inline uint8_t USB::getDevDescr(uint8_t addr, uint8_t ep, uint16_t nbytes, uint8_t* dataptr) { +inline uint8_t USBHost::getDevDescr(uint8_t addr, uint8_t ep, uint16_t nbytes, uint8_t* dataptr) { return ( ctrlReq(addr, ep, bmREQ_GET_DESCR, USB_REQUEST_GET_DESCRIPTOR, 0x00, USB_DESCRIPTOR_DEVICE, 0x0000, nbytes, dataptr)); } //get configuration descriptor -inline uint8_t USB::getConfDescr(uint8_t addr, uint8_t ep, uint16_t nbytes, uint8_t conf, uint8_t* dataptr) { +inline uint8_t USBHost::getConfDescr(uint8_t addr, uint8_t ep, uint16_t nbytes, uint8_t conf, uint8_t* dataptr) { return ( ctrlReq(addr, ep, bmREQ_GET_DESCR, USB_REQUEST_GET_DESCRIPTOR, conf, USB_DESCRIPTOR_CONFIGURATION, 0x0000, nbytes, dataptr)); } //get string descriptor -inline uint8_t USB::getStrDescr(uint8_t addr, uint8_t ep, uint16_t nuint8_ts, uint8_t index, uint16_t langid, uint8_t* dataptr) { +inline uint8_t USBHost::getStrDescr(uint8_t addr, uint8_t ep, uint16_t nuint8_ts, uint8_t index, uint16_t langid, uint8_t* dataptr) { return ( ctrlReq(addr, ep, bmREQ_GET_DESCR, USB_REQUEST_GET_DESCRIPTOR, index, USB_DESCRIPTOR_STRING, langid, nuint8_ts, dataptr)); } //set address -inline uint8_t USB::setAddr(uint8_t oldaddr, uint8_t ep, uint8_t newaddr) { +inline uint8_t USBHost::setAddr(uint8_t oldaddr, uint8_t ep, uint8_t newaddr) { return ( ctrlReq(oldaddr, ep, bmREQ_SET, USB_REQUEST_SET_ADDRESS, newaddr, 0x00, 0x0000, 0x0000, NULL)); } //set configuration -inline uint8_t USB::setConf(uint8_t addr, uint8_t ep, uint8_t conf_value) { +inline uint8_t USBHost::setConf(uint8_t addr, uint8_t ep, uint8_t conf_value) { return ( ctrlReq(addr, ep, bmREQ_SET, USB_REQUEST_SET_CONFIGURATION, conf_value, 0x00, 0x0000, 0x0000, NULL)); } diff --git a/Wii.cpp b/Wii.cpp index 20975a81..15eecb31 100755 --- a/Wii.cpp +++ b/Wii.cpp @@ -83,7 +83,7 @@ const uint32_t WII_PROCONTROLLER_BUTTONS[] PROGMEM = { }; WII::WII(BTD *p, bool pair) : -BluetoothService(p) // Pointer to USB class instance - mandatory +BluetoothService(p) // Pointer to BTD class instance - mandatory { pBtd->pairWithWii = pair; diff --git a/XBOXOLD.cpp b/XBOXOLD.cpp index 3d88ea97..43caab77 100644 --- a/XBOXOLD.cpp +++ b/XBOXOLD.cpp @@ -44,8 +44,8 @@ const uint8_t XBOXOLD_BUTTONS[] PROGMEM = { 3, // Y }; -XBOXOLD::XBOXOLD(USB *p) : -pUsb(p), // pointer to USB class instance - mandatory +XBOXOLD::XBOXOLD(USBHost *p) : +pUsb(p), // pointer to USBHost class instance - mandatory bAddress(0), // device address - mandatory bPollEnable(false) { // don't start polling before dongle is connected for(uint8_t i = 0; i < XBOX_MAX_ENDPOINTS; i++) { @@ -64,7 +64,7 @@ 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(buf); uint8_t rcode; - UsbDevice *p = NULL; + UsbDeviceDefinition *p = NULL; EpInfo *oldep_ptr = NULL; uint16_t PID; uint16_t VID; diff --git a/XBOXOLD.h b/XBOXOLD.h index 6b0757b2..43237a89 100644 --- a/XBOXOLD.h +++ b/XBOXOLD.h @@ -47,9 +47,9 @@ class XBOXOLD : public USBDeviceConfig { public: /** * Constructor for the XBOXOLD class. - * @param pUsb Pointer to USB class instance. + * @param pUsb Pointer to USBHost class instance. */ - XBOXOLD(USB *pUsb); + XBOXOLD(USBHost *pUsb); /** @name USBDeviceConfig implementation */ /** @@ -145,8 +145,8 @@ public: bool XboxConnected; protected: - /** Pointer to USB class instance. */ - USB *pUsb; + /** Pointer to USBHost class instance. */ + USBHost *pUsb; /** Device address. */ uint8_t bAddress; /** Endpoint info structure. */ diff --git a/XBOXONE.cpp b/XBOXONE.cpp index 0698a6aa..87f8ef2a 100644 --- a/XBOXONE.cpp +++ b/XBOXONE.cpp @@ -24,8 +24,8 @@ //#define EXTRADEBUG // Uncomment to get even more debugging data //#define PRINTREPORT // Uncomment to print the report send by the Xbox ONE Controller -XBOXONE::XBOXONE(USB *p) : -pUsb(p), // pointer to USB class instance - mandatory +XBOXONE::XBOXONE(USBHost *p) : +pUsb(p), // pointer to USBHost class instance - mandatory bAddress(0), // device address - mandatory bPollEnable(false) { // don't start polling before dongle is connected for(uint8_t i = 0; i < XBOX_MAX_ENDPOINTS; i++) { @@ -44,7 +44,7 @@ uint8_t XBOXONE::Init(uint8_t parent, uint8_t port, bool lowspeed) { uint8_t buf[sizeof (USB_DEVICE_DESCRIPTOR)]; USB_DEVICE_DESCRIPTOR * udd = reinterpret_cast(buf); uint8_t rcode; - UsbDevice *p = NULL; + UsbDeviceDefinition *p = NULL; EpInfo *oldep_ptr = NULL; uint16_t PID; uint16_t VID; diff --git a/XBOXONE.h b/XBOXONE.h index 11710fcf..b922d17b 100644 --- a/XBOXONE.h +++ b/XBOXONE.h @@ -47,9 +47,9 @@ class XBOXONE : public USBDeviceConfig { public: /** * Constructor for the XBOXONE class. - * @param pUsb Pointer to USB class instance. + * @param pUsb Pointer to USBHost class instance. */ - XBOXONE(USB *pUsb); + XBOXONE(USBHost *pUsb); /** @name USBDeviceConfig implementation */ /** @@ -132,8 +132,8 @@ public: bool XboxOneConnected; protected: - /** Pointer to USB class instance. */ - USB *pUsb; + /** Pointer to USBHost class instance. */ + USBHost *pUsb; /** Device address. */ uint8_t bAddress; /** Endpoint info structure. */ diff --git a/XBOXRECV.cpp b/XBOXRECV.cpp index 39e14ef8..c6a2e357 100644 --- a/XBOXRECV.cpp +++ b/XBOXRECV.cpp @@ -22,8 +22,8 @@ //#define EXTRADEBUG // Uncomment to get even more debugging data //#define PRINTREPORT // Uncomment to print the report send by the Xbox 360 Controller -XBOXRECV::XBOXRECV(USB *p) : -pUsb(p), // pointer to USB class instance - mandatory +XBOXRECV::XBOXRECV(USBHost *p) : +pUsb(p), // pointer to USBHost class instance - mandatory bAddress(0), // device address - mandatory bPollEnable(false) { // don't start polling before dongle is connected for(uint8_t i = 0; i < XBOX_MAX_ENDPOINTS; i++) { @@ -43,7 +43,7 @@ uint8_t XBOXRECV::ConfigureDevice(uint8_t parent, uint8_t port, bool lowspeed) { uint8_t buf[constBufSize]; USB_DEVICE_DESCRIPTOR * udd = reinterpret_cast(buf); uint8_t rcode; - UsbDevice *p = NULL; + UsbDeviceDefinition *p = NULL; EpInfo *oldep_ptr = NULL; uint16_t PID, VID; @@ -142,7 +142,7 @@ uint8_t XBOXRECV::Init(uint8_t parent, uint8_t port, bool lowspeed) { #ifdef EXTRADEBUG Notify(PSTR("\r\nBTD Init"), 0x80); #endif - UsbDevice *p = addrPool.GetUsbDevicePtr(bAddress); // Get pointer to assigned address record + UsbDeviceDefinition *p = addrPool.GetUsbDevicePtr(bAddress); // Get pointer to assigned address record if(!p) { #ifdef DEBUG_USB_HOST diff --git a/XBOXRECV.h b/XBOXRECV.h index 4f921465..ab1acb19 100644 --- a/XBOXRECV.h +++ b/XBOXRECV.h @@ -56,9 +56,9 @@ class XBOXRECV : public USBDeviceConfig { public: /** * Constructor for the XBOXRECV class. - * @param pUsb Pointer to USB class instance. + * @param pUsb Pointer to USBHost class instance. */ - XBOXRECV(USB *pUsb); + XBOXRECV(USBHost *pUsb); /** @name USBDeviceConfig implementation */ /** @@ -231,8 +231,8 @@ public: uint8_t Xbox360Connected[4]; protected: - /** Pointer to USB class instance. */ - USB *pUsb; + /** Pointer to USBHost class instance. */ + USBHost *pUsb; /** Device address. */ uint8_t bAddress; /** Endpoint info structure. */ diff --git a/XBOXUSB.cpp b/XBOXUSB.cpp index ce69f82b..c548c3a5 100644 --- a/XBOXUSB.cpp +++ b/XBOXUSB.cpp @@ -20,8 +20,8 @@ //#define EXTRADEBUG // Uncomment to get even more debugging data //#define PRINTREPORT // Uncomment to print the report send by the Xbox 360 Controller -XBOXUSB::XBOXUSB(USB *p) : -pUsb(p), // pointer to USB class instance - mandatory +XBOXUSB::XBOXUSB(USBHost *p) : +pUsb(p), // pointer to USBHost class instance - mandatory bAddress(0), // device address - mandatory bPollEnable(false) { // don't start polling before dongle is connected for(uint8_t i = 0; i < XBOX_MAX_ENDPOINTS; i++) { @@ -40,7 +40,7 @@ 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(buf); uint8_t rcode; - UsbDevice *p = NULL; + UsbDeviceDefinition *p = NULL; EpInfo *oldep_ptr = NULL; uint16_t PID; uint16_t VID; diff --git a/XBOXUSB.h b/XBOXUSB.h index 7f75610e..571f3ea3 100644 --- a/XBOXUSB.h +++ b/XBOXUSB.h @@ -54,9 +54,9 @@ class XBOXUSB : public USBDeviceConfig { public: /** * Constructor for the XBOXUSB class. - * @param pUsb Pointer to USB class instance. + * @param pUsb Pointer to USBHost class instance. */ - XBOXUSB(USB *pUsb); + XBOXUSB(USBHost *pUsb); /** @name USBDeviceConfig implementation */ /** @@ -185,8 +185,8 @@ public: bool Xbox360Connected; protected: - /** Pointer to USB class instance. */ - USB *pUsb; + /** Pointer to USBHost class instance. */ + USBHost *pUsb; /** Device address. */ uint8_t bAddress; /** Endpoint info structure. */ diff --git a/address.h b/address.h index ec48adbf..a18aba73 100644 --- a/address.h +++ b/address.h @@ -72,7 +72,7 @@ struct UsbDeviceAddress { #define bmUSB_DEV_ADDR_PARENT 0x38 #define bmUSB_DEV_ADDR_HUB 0x40 -struct UsbDevice { +struct UsbDeviceDefinition { EpInfo *epinfo; // endpoint info pointer UsbDeviceAddress address; uint8_t epcount; // number of endpoints @@ -82,12 +82,12 @@ struct UsbDevice { class AddressPool { public: - virtual UsbDevice* GetUsbDevicePtr(uint8_t addr) = 0; + virtual UsbDeviceDefinition* GetUsbDevicePtr(uint8_t addr) = 0; virtual uint8_t AllocAddress(uint8_t parent, bool is_hub = false, uint8_t port = 0) = 0; virtual void FreeAddress(uint8_t addr) = 0; }; -typedef void (*UsbDeviceHandleFunc)(UsbDevice *pdev); +typedef void (*UsbDeviceHandleFunc)(UsbDeviceDefinition *pdev); #define ADDR_ERROR_INVALID_INDEX 0xFF #define ADDR_ERROR_INVALID_ADDRESS 0xFF @@ -99,7 +99,7 @@ class AddressPoolImpl : public AddressPool { uint8_t hubCounter; // hub counter is kept // in order to avoid hub address duplication - UsbDevice thePool[MAX_DEVICES_ALLOWED]; + UsbDeviceDefinition thePool[MAX_DEVICES_ALLOWED]; // Initializes address pool entry @@ -178,7 +178,7 @@ public: // Returns a pointer to a specified address entry - virtual UsbDevice* GetUsbDevicePtr(uint8_t addr) { + virtual UsbDeviceDefinition* GetUsbDevicePtr(uint8_t addr) { if(!addr) return thePool; diff --git a/adk.cpp b/adk.cpp index f9631ae8..84e8a5b9 100644 --- a/adk.cpp +++ b/adk.cpp @@ -22,7 +22,7 @@ e-mail : support@circuitsathome.com const uint8_t ADK::epDataInIndex = 1; const uint8_t ADK::epDataOutIndex = 2; -ADK::ADK(USB *p, const char* manufacturer, +ADK::ADK(USBHost *p, const char* manufacturer, const char* model, const char* description, const char* version, @@ -36,7 +36,7 @@ description(description), version(version), uri(uri), serial(serial), -pUsb(p), //pointer to USB class instance - mandatory +pUsb(p), //pointer to USBHost class instance - mandatory bAddress(0), //device address - mandatory bConfNum(0), //configuration number bNumEP(1), //if config descriptor needs to be parsed @@ -66,7 +66,7 @@ uint8_t ADK::Init(uint8_t parent, uint8_t port, bool lowspeed) { USB_DEVICE_DESCRIPTOR * udd = reinterpret_cast(buf); uint8_t rcode; uint8_t num_of_conf; // number of configurations - UsbDevice *p = NULL; + UsbDeviceDefinition *p = NULL; EpInfo *oldep_ptr = NULL; // get memory address of USB device address pool diff --git a/adk.h b/adk.h index 4a2920b8..2b903165 100644 --- a/adk.h +++ b/adk.h @@ -70,7 +70,7 @@ protected: static const uint8_t epDataOutIndex; // DataOUT endpoint index /* mandatory members */ - USB *pUsb; + USBHost *pUsb; uint8_t bAddress; uint8_t bConfNum; // configuration number @@ -83,7 +83,7 @@ protected: void PrintEndpointDescriptor(const USB_ENDPOINT_DESCRIPTOR* ep_ptr); public: - ADK(USB *pUsb, const char* manufacturer, + ADK(USBHost *pUsb, const char* manufacturer, const char* model, const char* description, const char* version, diff --git a/cdc_XR21B1411.cpp b/cdc_XR21B1411.cpp index 1c4cd5c6..18c6c112 100644 --- a/cdc_XR21B1411.cpp +++ b/cdc_XR21B1411.cpp @@ -16,7 +16,7 @@ e-mail : support@circuitsathome.com */ #include "cdc_XR21B1411.h" -XR21B1411::XR21B1411(USB *p, CDCAsyncOper *pasync) : +XR21B1411::XR21B1411(USBHost *p, CDCAsyncOper *pasync) : ACM(p, pasync) { // Is this needed?? _enhanced_status = enhanced_features(); // Set up features @@ -29,7 +29,7 @@ uint8_t XR21B1411::Init(uint8_t parent, uint8_t port, bool lowspeed) { USB_DEVICE_DESCRIPTOR * udd = reinterpret_cast(buf); uint8_t rcode; - UsbDevice *p = NULL; + UsbDeviceDefinition *p = NULL; EpInfo *oldep_ptr = NULL; uint8_t num_of_conf; // number of configurations diff --git a/cdc_XR21B1411.h b/cdc_XR21B1411.h index c3262754..d32d212e 100644 --- a/cdc_XR21B1411.h +++ b/cdc_XR21B1411.h @@ -104,7 +104,7 @@ class XR21B1411 : public ACM { protected: public: - XR21B1411(USB *pusb, CDCAsyncOper *pasync); + XR21B1411(USBHost *pusb, CDCAsyncOper *pasync); /** * Used by the USB core to check what this driver support. diff --git a/cdcacm.cpp b/cdcacm.cpp index 87d6961a..7716e1f2 100644 --- a/cdcacm.cpp +++ b/cdcacm.cpp @@ -20,7 +20,7 @@ const uint8_t ACM::epDataInIndex = 1; const uint8_t ACM::epDataOutIndex = 2; const uint8_t ACM::epInterruptInIndex = 3; -ACM::ACM(USB *p, CDCAsyncOper *pasync) : +ACM::ACM(USBHost *p, CDCAsyncOper *pasync) : pUsb(p), pAsync(pasync), bAddress(0), @@ -51,7 +51,7 @@ uint8_t ACM::Init(uint8_t parent, uint8_t port, bool lowspeed) { USB_DEVICE_DESCRIPTOR * udd = reinterpret_cast(buf); uint8_t rcode; - UsbDevice *p = NULL; + UsbDeviceDefinition *p = NULL; EpInfo *oldep_ptr = NULL; uint8_t num_of_conf; // number of configurations diff --git a/cdcacm.h b/cdcacm.h index 2a38524d..966737f6 100644 --- a/cdcacm.h +++ b/cdcacm.h @@ -166,7 +166,7 @@ protected: static const uint8_t epDataOutIndex; // DataOUT endpoint index static const uint8_t epInterruptInIndex; // InterruptIN endpoint index - USB *pUsb; + USBHost *pUsb; CDCAsyncOper *pAsync; uint8_t bAddress; uint8_t bConfNum; // configuration number @@ -183,7 +183,7 @@ protected: void PrintEndpointDescriptor(const USB_ENDPOINT_DESCRIPTOR* ep_ptr); public: - ACM(USB *pusb, CDCAsyncOper *pasync); + ACM(USBHost *pusb, CDCAsyncOper *pasync); uint8_t SetCommFeature(uint16_t fid, uint8_t nbytes, uint8_t *dataptr); uint8_t GetCommFeature(uint16_t fid, uint8_t nbytes, uint8_t *dataptr); diff --git a/cdcftdi.cpp b/cdcftdi.cpp index 98d7da70..4d3ae881 100644 --- a/cdcftdi.cpp +++ b/cdcftdi.cpp @@ -20,7 +20,7 @@ const uint8_t FTDI::epDataInIndex = 1; const uint8_t FTDI::epDataOutIndex = 2; const uint8_t FTDI::epInterruptInIndex = 3; -FTDI::FTDI(USB *p, FTDIAsyncOper *pasync, uint16_t idProduct) : +FTDI::FTDI(USBHost *p, FTDIAsyncOper *pasync, uint16_t idProduct) : pAsync(pasync), pUsb(p), bAddress(0), @@ -44,7 +44,7 @@ uint8_t FTDI::Init(uint8_t parent, uint8_t port, bool lowspeed) { uint8_t buf[constBufSize]; USB_DEVICE_DESCRIPTOR * udd = reinterpret_cast(buf); uint8_t rcode; - UsbDevice *p = NULL; + UsbDeviceDefinition *p = NULL; EpInfo *oldep_ptr = NULL; uint8_t num_of_conf; // number of configurations diff --git a/cdcftdi.h b/cdcftdi.h index 8410bcdd..5bbdeb53 100644 --- a/cdcftdi.h +++ b/cdcftdi.h @@ -99,7 +99,7 @@ class FTDI : public USBDeviceConfig, public UsbConfigXtracter { static const uint8_t epInterruptInIndex; // InterruptIN endpoint index FTDIAsyncOper *pAsync; - USB *pUsb; + USBHost *pUsb; uint8_t bAddress; uint8_t bConfNum; // configuration number uint8_t bNumIface; // number of interfaces in the configuration @@ -114,7 +114,7 @@ class FTDI : public USBDeviceConfig, public UsbConfigXtracter { void PrintEndpointDescriptor(const USB_ENDPOINT_DESCRIPTOR* ep_ptr); public: - FTDI(USB *pusb, FTDIAsyncOper *pasync, uint16_t idProduct = FTDI_PID); + FTDI(USBHost *pusb, FTDIAsyncOper *pasync, uint16_t idProduct = FTDI_PID); uint8_t SetBaudRate(uint32_t baud); uint8_t SetModemControl(uint16_t control); diff --git a/cdcprolific.cpp b/cdcprolific.cpp index eceb1df9..004f36ce 100644 --- a/cdcprolific.cpp +++ b/cdcprolific.cpp @@ -16,7 +16,7 @@ e-mail : support@circuitsathome.com */ #include "cdcprolific.h" -PL2303::PL2303(USB *p, CDCAsyncOper *pasync) : +PL2303::PL2303(USBHost *p, CDCAsyncOper *pasync) : ACM(p, pasync), wPLType(0) { } @@ -27,7 +27,7 @@ uint8_t PL2303::Init(uint8_t parent, uint8_t port, bool lowspeed) { uint8_t buf[constBufSize]; USB_DEVICE_DESCRIPTOR * udd = reinterpret_cast(buf); uint8_t rcode; - UsbDevice *p = NULL; + UsbDeviceDefinition *p = NULL; EpInfo *oldep_ptr = NULL; uint8_t num_of_conf; // number of configurations #ifdef PL2303_COMPAT diff --git a/cdcprolific.h b/cdcprolific.h index 49914664..dea94554 100644 --- a/cdcprolific.h +++ b/cdcprolific.h @@ -123,7 +123,7 @@ class PL2303 : public ACM { uint16_t wPLType; // Type of chip public: - PL2303(USB *pusb, CDCAsyncOper *pasync); + PL2303(USBHost *pusb, CDCAsyncOper *pasync); // USBDeviceConfig implementation uint8_t Init(uint8_t parent, uint8_t port, bool lowspeed); diff --git a/hidboot.h b/hidboot.h index 27fda78d..c7e421fa 100644 --- a/hidboot.h +++ b/hidboot.h @@ -218,7 +218,7 @@ class HIDBoot : public USBHID //public USBDeviceConfig, public UsbConfigXtracter }; public: - HIDBoot(USB *p); + HIDBoot(USBHost *p); virtual bool SetReportParser(uint8_t id, HIDReportParser *prs) { pRptParser[id] = prs; @@ -252,7 +252,7 @@ public: }; template -HIDBoot::HIDBoot(USB *p) : +HIDBoot::HIDBoot(USBHost *p) : USBHID(p), qNextPollTime(0), bPollEnable(false) { @@ -285,7 +285,7 @@ uint8_t HIDBoot::Init(uint8_t parent, uint8_t port, bool lowspeed uint8_t buf[constBufSize]; uint8_t rcode; - UsbDevice *p = NULL; + UsbDeviceDefinition *p = NULL; EpInfo *oldep_ptr = NULL; uint8_t len = 0; //uint16_t cd_len = 0; diff --git a/hiduniversal.cpp b/hiduniversal.cpp index 1cc92521..821ead28 100644 --- a/hiduniversal.cpp +++ b/hiduniversal.cpp @@ -17,7 +17,7 @@ e-mail : support@circuitsathome.com #include "hiduniversal.h" -HIDUniversal::HIDUniversal(USB *p) : +HIDUniversal::HIDUniversal(USBHost *p) : USBHID(p), qNextPollTime(0), pollInterval(0), @@ -99,7 +99,7 @@ uint8_t HIDUniversal::Init(uint8_t parent, uint8_t port, bool lowspeed) { uint8_t buf[constBufSize]; USB_DEVICE_DESCRIPTOR * udd = reinterpret_cast(buf); uint8_t rcode; - UsbDevice *p = NULL; + UsbDeviceDefinition *p = NULL; EpInfo *oldep_ptr = NULL; uint8_t len = 0; diff --git a/hiduniversal.h b/hiduniversal.h index d64ad4cc..ef49201a 100644 --- a/hiduniversal.h +++ b/hiduniversal.h @@ -80,7 +80,7 @@ protected: }; public: - HIDUniversal(USB *p); + HIDUniversal(USBHost *p); // HID implementation bool SetReportParser(uint8_t id, HIDReportParser *prs); diff --git a/keywords.txt b/keywords.txt index 26707d1d..fb6c34ff 100644 --- a/keywords.txt +++ b/keywords.txt @@ -6,7 +6,7 @@ # Datatypes (KEYWORD1) #################################################### -USB KEYWORD1 +USBHost KEYWORD1 USBHub KEYWORD1 #################################################### diff --git a/masstorage.cpp b/masstorage.cpp index b528bb80..8f079526 100644 --- a/masstorage.cpp +++ b/masstorage.cpp @@ -219,7 +219,7 @@ again: //////////////////////////////////////////////////////////////////////////////// -BulkOnly::BulkOnly(USB *p) : +BulkOnly::BulkOnly(USBHost *p) : pUsb(p), bAddress(0), bIface(0), @@ -255,7 +255,7 @@ uint8_t BulkOnly::ConfigureDevice(uint8_t parent, uint8_t port, bool lowspeed) { uint8_t buf[constBufSize]; USB_DEVICE_DESCRIPTOR * udd = reinterpret_cast(buf); uint8_t rcode; - UsbDevice *p = NULL; + UsbDeviceDefinition *p = NULL; EpInfo *oldep_ptr = NULL; USBTRACE("MS ConfigureDevice\r\n"); ClearAllEP(); @@ -330,7 +330,7 @@ uint8_t BulkOnly::Init(uint8_t parent, uint8_t port, bool lowspeed) { USBTRACE("MS Init\r\n"); AddressPool &addrPool = pUsb->GetAddressPool(); - UsbDevice *p = addrPool.GetUsbDevicePtr(bAddress); + UsbDeviceDefinition *p = addrPool.GetUsbDevicePtr(bAddress); if(!p) return USB_ERROR_ADDRESS_NOT_FOUND_IN_POOL; diff --git a/masstorage.h b/masstorage.h index d39fd66f..2f460738 100644 --- a/masstorage.h +++ b/masstorage.h @@ -465,7 +465,7 @@ protected: static const uint8_t epDataOutIndex; // DataOUT endpoint index static const uint8_t epInterruptInIndex; // InterruptIN endpoint index - USB *pUsb; + USBHost *pUsb; uint8_t bAddress; uint8_t bConfNum; // configuration number uint8_t bIface; // interface value @@ -493,7 +493,7 @@ protected: return 0; }; public: - BulkOnly(USB *p); + BulkOnly(USBHost *p); uint8_t GetLastUsbError() { return bLastUsbError; diff --git a/max_LCD.cpp b/max_LCD.cpp index 7a9b1707..70b2d131 100644 --- a/max_LCD.cpp +++ b/max_LCD.cpp @@ -39,7 +39,7 @@ e-mail : support@circuitsathome.com static uint8_t lcdPins; //copy of LCD pins -Max_LCD::Max_LCD(USB *pusb) : pUsb(pusb) { +Max_LCD::Max_LCD(USBHost *pusb) : pUsb(pusb) { lcdPins = 0; } diff --git a/max_LCD.h b/max_LCD.h index 950c9c5a..cd4253eb 100644 --- a/max_LCD.h +++ b/max_LCD.h @@ -63,10 +63,10 @@ e-mail : support@circuitsathome.com #define LCD_5x8DOTS 0x00 class Max_LCD : public Print { - USB *pUsb; + USBHost *pUsb; public: - Max_LCD(USB *pusb); + Max_LCD(USBHost *pusb); void init(); void begin(uint8_t cols, uint8_t rows, uint8_t charsize = LCD_5x8DOTS); void clear(); diff --git a/usbhid.h b/usbhid.h index feca84db..2822b76e 100644 --- a/usbhid.h +++ b/usbhid.h @@ -120,7 +120,7 @@ struct HidItemPrefix { uint8_t bSize : 2; uint8_t bType : 2; uint8_t bTag : 4; -}; +} __attribute__((packed)); struct MainItemIOFeature { uint8_t bmIsConstantOrData : 1; @@ -131,7 +131,7 @@ struct MainItemIOFeature { uint8_t bmIsNoPreferedOrPrefered : 1; uint8_t bmIsNullOrNoNull : 1; uint8_t bmIsVolatileOrNonVolatile : 1; -}; +} __attribute__((packed)); class USBHID; @@ -142,7 +142,7 @@ public: class USBHID : public USBDeviceConfig, public UsbConfigXtracter { protected: - USB *pUsb; // USB class instance pointer + USBHost *pUsb; // USBHost class instance pointer uint8_t bAddress; // address protected: @@ -162,10 +162,10 @@ protected: public: - USBHID(USB *pusb) : pUsb(pusb) { + USBHID(USBHost *pusb) : pUsb(pusb) { }; - const USB* GetUsb() { + const USBHost* GetUsb() { return pUsb; }; diff --git a/usbhub.cpp b/usbhub.cpp index 6ead8bd0..af80bce7 100644 --- a/usbhub.cpp +++ b/usbhub.cpp @@ -18,7 +18,7 @@ e-mail : support@circuitsathome.com bool USBHub::bResetInitiated = false; -USBHub::USBHub(USB *p) : +USBHub::USBHub(USBHost *p) : pUsb(p), bAddress(0), bNbrPorts(0), @@ -47,7 +47,7 @@ uint8_t USBHub::Init(uint8_t parent, uint8_t port, bool lowspeed) { HubDescriptor* hd = reinterpret_cast(buf); USB_CONFIGURATION_DESCRIPTOR * ucd = reinterpret_cast(buf); uint8_t rcode; - UsbDevice *p = NULL; + UsbDeviceDefinition *p = NULL; EpInfo *oldep_ptr = NULL; uint8_t len = 0; uint16_t cd_len = 0; diff --git a/usbhub.h b/usbhub.h index 1ac94944..da94544d 100644 --- a/usbhub.h +++ b/usbhub.h @@ -164,7 +164,7 @@ struct HubEvent { class USBHub : USBDeviceConfig { static bool bResetInitiated; // True when reset is triggered - USB *pUsb; // USB class instance pointer + USBHost *pUsb; // USBHost class instance pointer EpInfo epInfo[2]; // interrupt endpoint info structure @@ -178,7 +178,7 @@ class USBHub : USBDeviceConfig { uint8_t PortStatusChange(uint8_t port, HubEvent &evt); public: - USBHub(USB *p); + USBHub(USBHost *p); uint8_t ClearHubFeature(uint8_t fid); uint8_t ClearPortFeature(uint8_t fid, uint8_t port, uint8_t sel = 0); @@ -247,6 +247,6 @@ inline uint8_t USBHub::SetPortFeature(uint8_t fid, uint8_t port, uint8_t sel) { return ( pUsb->ctrlReq(bAddress, 0, bmREQ_SET_PORT_FEATURE, USB_REQUEST_SET_FEATURE, fid, 0, (((0x0000 | sel) << 8) | port), 0, 0, NULL, NULL)); } -void PrintHubPortStatus(USB *usbptr, uint8_t addr, uint8_t port, bool print_changes = false); +void PrintHubPortStatus(USBHost *usbptr, uint8_t addr, uint8_t port, bool print_changes = false); #endif // __USBHUB_H__