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
This commit is contained in:
Kristian Sloth Lauszus 2016-01-19 16:34:45 +01:00
parent 47375fa8a7
commit 6c36eed239
42 changed files with 140 additions and 140 deletions

View file

@ -64,4 +64,4 @@ install:
- platformio lib install 416 417 - platformio lib install 416 417
script: script:
- platformio ci --board=uno --board=teensy31 --board=due --lib="." - platformio ci --board=uno --board=teensy31 --board=due --board=zero --lib="."

View file

@ -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_DATAIN_PIPE = 2;
const uint8_t BTD::BTD_DATAOUT_PIPE = 3; const uint8_t BTD::BTD_DATAOUT_PIPE = 3;
BTD::BTD(USB *p) : BTD::BTD(USBHost *p) :
connectToWii(false), connectToWii(false),
pairWithWii(false), pairWithWii(false),
connectToHIDDevice(false), connectToHIDDevice(false),
pairWithHIDDevice(false), pairWithHIDDevice(false),
pUsb(p), // Pointer to USB class instance - mandatory pUsb(p), // Pointer to USBHost class instance - mandatory
bAddress(0), // Device address - mandatory bAddress(0), // Device address - mandatory
bNumEP(1), // If config descriptor needs to be parsed bNumEP(1), // If config descriptor needs to be parsed
qNextPollTime(0), // Reset NextPollTime qNextPollTime(0), // Reset NextPollTime
@ -50,7 +50,7 @@ uint8_t BTD::ConfigureDevice(uint8_t parent, uint8_t port, bool lowspeed) {
uint8_t buf[constBufSize]; uint8_t buf[constBufSize];
USB_DEVICE_DESCRIPTOR * udd = reinterpret_cast<USB_DEVICE_DESCRIPTOR*>(buf); USB_DEVICE_DESCRIPTOR * udd = reinterpret_cast<USB_DEVICE_DESCRIPTOR*>(buf);
uint8_t rcode; uint8_t rcode;
UsbDevice *p = NULL; UsbDeviceDefinition *p = NULL;
EpInfo *oldep_ptr = NULL; EpInfo *oldep_ptr = NULL;
Initialize(); // Set all variables, endpoint structs etc. to default values 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 #ifdef EXTRADEBUG
Notify(PSTR("\r\nBTD Init"), 0x80); Notify(PSTR("\r\nBTD Init"), 0x80);
#endif #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) { if(!p) {
#ifdef DEBUG_USB_HOST #ifdef DEBUG_USB_HOST

8
BTD.h
View file

@ -199,9 +199,9 @@ class BTD : public USBDeviceConfig, public UsbConfigXtracter {
public: public:
/** /**
* Constructor for the BTD class. * 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 */ /** @name USBDeviceConfig implementation */
/** /**
@ -497,8 +497,8 @@ public:
}; };
protected: protected:
/** Pointer to USB class instance. */ /** Pointer to USBHost class instance. */
USB *pUsb; USBHost *pUsb;
/** Device address. */ /** Device address. */
uint8_t bAddress; uint8_t bAddress;
/** Endpoint info structure. */ /** Endpoint info structure. */

View file

@ -21,7 +21,7 @@
//#define PRINTREPORT // Uncomment to print the report send by the HID device //#define PRINTREPORT // Uncomment to print the report send by the HID device
BTHID::BTHID(BTD *p, bool pair, const char *pin) : 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) { protocolMode(USB_HID_BOOT_PROTOCOL) {
for(uint8_t i = 0; i < NUM_PARSERS; i++) for(uint8_t i = 0; i < NUM_PARSERS; i++)
pRptParser[i] = NULL; pRptParser[i] = NULL;

View file

@ -21,7 +21,7 @@
//#define PRINTREPORT // Uncomment to print the report send by the PS3 Controllers //#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) : 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[5] = btadr5; // Change to your dongle's Bluetooth address instead
pBtd->my_bdaddr[4] = btadr4; pBtd->my_bdaddr[4] = btadr4;

View file

@ -20,8 +20,8 @@
//#define EXTRADEBUG // Uncomment to get even more debugging data //#define EXTRADEBUG // Uncomment to get even more debugging data
//#define PRINTREPORT // Uncomment to print the report send by the PS3 Controllers //#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) : 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 USB class instance - mandatory pUsb(p), // pointer to USBHost class instance - mandatory
bAddress(0), // device address - mandatory bAddress(0), // device address - mandatory
bPollEnable(false) // don't start polling before dongle is connected 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)]; uint8_t buf[sizeof (USB_DEVICE_DESCRIPTOR)];
USB_DEVICE_DESCRIPTOR * udd = reinterpret_cast<USB_DEVICE_DESCRIPTOR*>(buf); USB_DEVICE_DESCRIPTOR * udd = reinterpret_cast<USB_DEVICE_DESCRIPTOR*>(buf);
uint8_t rcode; uint8_t rcode;
UsbDevice *p = NULL; UsbDeviceDefinition *p = NULL;
EpInfo *oldep_ptr = NULL; EpInfo *oldep_ptr = NULL;
uint16_t PID; uint16_t PID;
uint16_t VID; uint16_t VID;

View file

@ -50,12 +50,12 @@ class PS3USB : public USBDeviceConfig {
public: public:
/** /**
* Constructor for the PS3USB class. * 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 * @param btadr5,btadr4,btadr3,btadr2,btadr1,btadr0
* Pass your dongles Bluetooth address into the constructor, * Pass your dongles Bluetooth address into the constructor,
* so you are able to pair the controller with a Bluetooth dongle. * 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 */ /** @name USBDeviceConfig implementation */
/** /**
@ -264,8 +264,8 @@ public:
bool PS3NavigationConnected; bool PS3NavigationConnected;
protected: protected:
/** Pointer to USB class instance. */ /** Pointer to USBHost class instance. */
USB *pUsb; USBHost *pUsb;
/** Device address. */ /** Device address. */
uint8_t bAddress; uint8_t bAddress;
/** Endpoint info structure. */ /** Endpoint info structure. */

View file

@ -32,9 +32,9 @@ class PS4USB : public HIDUniversal, public PS4Parser {
public: public:
/** /**
* Constructor for the PS4USB class. * 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) { HIDUniversal(p) {
PS4Parser::Reset(); PS4Parser::Reset();
}; };

View file

@ -44,9 +44,9 @@ class PSBuzz : public HIDUniversal {
public: public:
/** /**
* Constructor for the PSBuzz class. * 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) { HIDUniversal(p) {
Reset(); Reset();
}; };

64
Usb.cpp
View file

@ -22,27 +22,27 @@ static uint8_t usb_error = 0;
static uint8_t usb_task_state; static uint8_t usb_task_state;
/* constructor */ /* constructor */
USB::USB() : bmHubPre(0) { USBHost::USBHost() : bmHubPre(0) {
usb_task_state = USB_DETACHED_SUBSTATE_INITIALIZE; //set up state machine usb_task_state = USB_DETACHED_SUBSTATE_INITIALIZE; //set up state machine
init(); init();
} }
/* Initialize data structures */ /* Initialize data structures */
void USB::init() { void USBHost::init() {
//devConfigIndex = 0; //devConfigIndex = 0;
bmHubPre = 0; bmHubPre = 0;
} }
uint8_t USB::getUsbTaskState(void) { uint8_t USBHost::getUsbTaskState(void) {
return ( usb_task_state); return ( usb_task_state);
} }
void USB::setUsbTaskState(uint8_t state) { void USBHost::setUsbTaskState(uint8_t state) {
usb_task_state = state; usb_task_state = state;
} }
EpInfo* USB::getEpInfoEntry(uint8_t addr, uint8_t ep) { EpInfo* USBHost::getEpInfoEntry(uint8_t addr, uint8_t ep) {
UsbDevice *p = addrPool.GetUsbDevicePtr(addr); UsbDeviceDefinition *p = addrPool.GetUsbDevicePtr(addr);
if(!p || !p->epinfo) if(!p || !p->epinfo)
return NULL; return NULL;
@ -61,11 +61,11 @@ EpInfo* USB::getEpInfoEntry(uint8_t addr, uint8_t ep) {
/* set device table entry */ /* 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 */ /* 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) if(!eprecord_ptr)
return USB_ERROR_INVALID_ARGUMENT; return USB_ERROR_INVALID_ARGUMENT;
UsbDevice *p = addrPool.GetUsbDevicePtr(addr); UsbDeviceDefinition *p = addrPool.GetUsbDevicePtr(addr);
if(!p) if(!p)
return USB_ERROR_ADDRESS_NOT_FOUND_IN_POOL; 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; return 0;
} }
uint8_t USB::SetAddress(uint8_t addr, uint8_t ep, EpInfo **ppep, uint16_t *nak_limit) { uint8_t USBHost::SetAddress(uint8_t addr, uint8_t ep, EpInfo **ppep, uint16_t *nak_limit) {
UsbDevice *p = addrPool.GetUsbDevicePtr(addr); UsbDeviceDefinition *p = addrPool.GetUsbDevicePtr(addr);
if(!p) if(!p)
return USB_ERROR_ADDRESS_NOT_FOUND_IN_POOL; 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 */ /* 00 = success */
/* 01-0f = non-zero HRSLT */ /* 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) { uint16_t wInd, uint16_t total, uint16_t nbytes, uint8_t* dataptr, USBReadParser *p) {
bool direction = false; //request direction, IN or OUT bool direction = false; //request direction, IN or OUT
uint8_t rcode; 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, /* rcode 0 if no errors. rcode 01-0f is relayed from dispatchPkt(). Rcode f0 means RCVDAVIRQ error,
fe USB xfer timeout */ 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; EpInfo *pep = NULL;
uint16_t nak_limit = 0; uint16_t nak_limit = 0;
uint8_t rcode = SetAddress(addr, ep, &pep, &nak_limit); uint8_t rcode = SetAddress(addr, ep, &pep, &nak_limit);
if(rcode) { if(rcode) {
USBTRACE3("(USB::InTransfer) SetAddress Failed ", rcode, 0x81); USBTRACE3("(USBHost::InTransfer) SetAddress Failed ", rcode, 0x81);
USBTRACE3("(USB::InTransfer) addr requested ", addr, 0x81); USBTRACE3("(USBHost::InTransfer) addr requested ", addr, 0x81);
USBTRACE3("(USB::InTransfer) ep requested ", ep, 0x81); USBTRACE3("(USBHost::InTransfer) ep requested ", ep, 0x81);
return rcode; return rcode;
} }
return InTransfer(pep, nak_limit, nbytesptr, data, bInterval); 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 rcode = 0;
uint8_t pktsize; 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 */ /* Handles NAK bug per Maxim Application Note 4000 for single buffer transfer */
/* rcode 0 if no errors. rcode 01-0f is relayed from HRSL */ /* 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; EpInfo *pep = NULL;
uint16_t nak_limit = 0; 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); 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 rcode = hrSUCCESS, retry_count;
uint8_t *data_p = data; //local copy of the data pointer uint8_t *data_p = data; //local copy of the data pointer
uint16_t bytes_tosend, nak_count; uint16_t bytes_tosend, nak_count;
@ -374,7 +374,7 @@ breakout:
/* If bus timeout, re-sends up to USB_RETRY_LIMIT times */ /* If bus timeout, re-sends up to USB_RETRY_LIMIT times */
/* return codes 0x00-0x0f are HRSLT( 0x00 being success ), 0xff means timeout */ /* 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; unsigned long timeout = millis() + USB_XFER_TIMEOUT;
uint8_t tmpdata; uint8_t tmpdata;
uint8_t rcode = hrSUCCESS; 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 */ /* 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 rcode;
uint8_t tmpdata; uint8_t tmpdata;
@ -528,10 +528,10 @@ void USB::Task(void) //USB state machine
} // switch( usb_task_state ) } // 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 buf[12];
uint8_t rcode; uint8_t rcode;
UsbDevice *p0 = NULL, *p = NULL; UsbDeviceDefinition *p0 = NULL, *p = NULL;
// Get pointer to pseudo device with address 0 assigned // Get pointer to pseudo device with address 0 assigned
p0 = addrPool.GetUsbDevicePtr(0); p0 = addrPool.GetUsbDevicePtr(0);
@ -568,7 +568,7 @@ uint8_t USB::DefaultAddressing(uint8_t parent, uint8_t port, bool lowspeed) {
return 0; 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); //printf("AttemptConfig: parent = %i, port = %i\r\n", parent, port);
uint8_t retries = 0; uint8_t retries = 0;
@ -650,14 +650,14 @@ again:
* 8: if we get here, no driver likes the device plugged in, so exit failure. * 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; //uint8_t bAddress = 0;
//printf("Configuring: parent = %i, port = %i\r\n", parent, port); //printf("Configuring: parent = %i, port = %i\r\n", parent, port);
uint8_t devConfigIndex; uint8_t devConfigIndex;
uint8_t rcode = 0; uint8_t rcode = 0;
uint8_t buf[sizeof (USB_DEVICE_DESCRIPTOR)]; uint8_t buf[sizeof (USB_DEVICE_DESCRIPTOR)];
USB_DEVICE_DESCRIPTOR *udd = reinterpret_cast<USB_DEVICE_DESCRIPTOR *>(buf); USB_DEVICE_DESCRIPTOR *udd = reinterpret_cast<USB_DEVICE_DESCRIPTOR *>(buf);
UsbDevice *p = NULL; UsbDeviceDefinition *p = NULL;
EpInfo *oldep_ptr = NULL; EpInfo *oldep_ptr = NULL;
EpInfo epInfo; EpInfo epInfo;
@ -748,7 +748,7 @@ uint8_t USB::Configuring(uint8_t parent, uint8_t port, bool lowspeed) {
return rcode; return rcode;
} }
uint8_t USB::ReleaseDevice(uint8_t addr) { uint8_t USBHost::ReleaseDevice(uint8_t addr) {
if(!addr) if(!addr)
return 0; return 0;
@ -763,18 +763,18 @@ uint8_t USB::ReleaseDevice(uint8_t addr) {
#if 1 //!defined(USB_METHODS_INLINE) #if 1 //!defined(USB_METHODS_INLINE)
//get device descriptor //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)); return ( ctrlReq(addr, ep, bmREQ_GET_DESCR, USB_REQUEST_GET_DESCRIPTOR, 0x00, USB_DESCRIPTOR_DEVICE, 0x0000, nbytes, nbytes, dataptr, NULL));
} }
//get configuration descriptor //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)); 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 /* 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 */ 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; const uint8_t bufSize = 64;
uint8_t buf[bufSize]; uint8_t buf[bufSize];
USB_CONFIGURATION_DESCRIPTOR *ucd = reinterpret_cast<USB_CONFIGURATION_DESCRIPTOR *>(buf); USB_CONFIGURATION_DESCRIPTOR *ucd = reinterpret_cast<USB_CONFIGURATION_DESCRIPTOR *>(buf);
@ -793,12 +793,12 @@ uint8_t USB::getConfDescr(uint8_t addr, uint8_t ep, uint8_t conf, USBReadParser
//get string descriptor //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)); return ( ctrlReq(addr, ep, bmREQ_GET_DESCR, USB_REQUEST_GET_DESCRIPTOR, index, USB_DESCRIPTOR_STRING, langid, ns, ns, dataptr, NULL));
} }
//set address //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); 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(2); //per USB 2.0 sect.9.2.6.3
delay(300); // Older spec says you should wait at least 200ms 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 //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)); return ( ctrlReq(addr, ep, bmREQ_SET, USB_REQUEST_SET_CONFIGURATION, conf_value, 0x00, 0x0000, 0x0000, 0x0000, NULL, NULL));
} }

View file

@ -194,13 +194,13 @@ public:
virtual void Parse(const uint16_t len, const uint8_t *pbuf, const uint16_t &offset) = 0; 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<USB_NUMDEVICES> addrPool; AddressPoolImpl<USB_NUMDEVICES> addrPool;
USBDeviceConfig* devConfig[USB_NUMDEVICES]; USBDeviceConfig* devConfig[USB_NUMDEVICES];
uint8_t bmHubPre; uint8_t bmHubPre;
public: public:
USB(void); USBHost(void);
void SetHubPreMask() { void SetHubPreMask() {
bmHubPre |= bmHUBPRE; bmHubPre |= bmHUBPRE;
@ -269,27 +269,27 @@ private:
#if 0 //defined(USB_METHODS_INLINE) #if 0 //defined(USB_METHODS_INLINE)
//get device descriptor //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)); return ( ctrlReq(addr, ep, bmREQ_GET_DESCR, USB_REQUEST_GET_DESCRIPTOR, 0x00, USB_DESCRIPTOR_DEVICE, 0x0000, nbytes, dataptr));
} }
//get configuration descriptor //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)); return ( ctrlReq(addr, ep, bmREQ_GET_DESCR, USB_REQUEST_GET_DESCRIPTOR, conf, USB_DESCRIPTOR_CONFIGURATION, 0x0000, nbytes, dataptr));
} }
//get string descriptor //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)); return ( ctrlReq(addr, ep, bmREQ_GET_DESCR, USB_REQUEST_GET_DESCRIPTOR, index, USB_DESCRIPTOR_STRING, langid, nuint8_ts, dataptr));
} }
//set address //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)); return ( ctrlReq(oldaddr, ep, bmREQ_SET, USB_REQUEST_SET_ADDRESS, newaddr, 0x00, 0x0000, 0x0000, NULL));
} }
//set configuration //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)); return ( ctrlReq(addr, ep, bmREQ_SET, USB_REQUEST_SET_CONFIGURATION, conf_value, 0x00, 0x0000, 0x0000, NULL));
} }

View file

@ -83,7 +83,7 @@ const uint32_t WII_PROCONTROLLER_BUTTONS[] PROGMEM = {
}; };
WII::WII(BTD *p, bool pair) : 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; pBtd->pairWithWii = pair;

View file

@ -44,8 +44,8 @@ const uint8_t XBOXOLD_BUTTONS[] PROGMEM = {
3, // Y 3, // Y
}; };
XBOXOLD::XBOXOLD(USB *p) : XBOXOLD::XBOXOLD(USBHost *p) :
pUsb(p), // pointer to USB class instance - mandatory pUsb(p), // pointer to USBHost class instance - mandatory
bAddress(0), // device address - mandatory bAddress(0), // device address - mandatory
bPollEnable(false) { // don't start polling before dongle is connected bPollEnable(false) { // don't start polling before dongle is connected
for(uint8_t i = 0; i < XBOX_MAX_ENDPOINTS; i++) { 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)]; uint8_t buf[sizeof (USB_DEVICE_DESCRIPTOR)];
USB_DEVICE_DESCRIPTOR * udd = reinterpret_cast<USB_DEVICE_DESCRIPTOR*>(buf); USB_DEVICE_DESCRIPTOR * udd = reinterpret_cast<USB_DEVICE_DESCRIPTOR*>(buf);
uint8_t rcode; uint8_t rcode;
UsbDevice *p = NULL; UsbDeviceDefinition *p = NULL;
EpInfo *oldep_ptr = NULL; EpInfo *oldep_ptr = NULL;
uint16_t PID; uint16_t PID;
uint16_t VID; uint16_t VID;

View file

@ -47,9 +47,9 @@ class XBOXOLD : public USBDeviceConfig {
public: public:
/** /**
* Constructor for the XBOXOLD class. * 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 */ /** @name USBDeviceConfig implementation */
/** /**
@ -145,8 +145,8 @@ public:
bool XboxConnected; bool XboxConnected;
protected: protected:
/** Pointer to USB class instance. */ /** Pointer to USBHost class instance. */
USB *pUsb; USBHost *pUsb;
/** Device address. */ /** Device address. */
uint8_t bAddress; uint8_t bAddress;
/** Endpoint info structure. */ /** Endpoint info structure. */

View file

@ -24,8 +24,8 @@
//#define EXTRADEBUG // Uncomment to get even more debugging data //#define EXTRADEBUG // Uncomment to get even more debugging data
//#define PRINTREPORT // Uncomment to print the report send by the Xbox ONE Controller //#define PRINTREPORT // Uncomment to print the report send by the Xbox ONE Controller
XBOXONE::XBOXONE(USB *p) : XBOXONE::XBOXONE(USBHost *p) :
pUsb(p), // pointer to USB class instance - mandatory pUsb(p), // pointer to USBHost class instance - mandatory
bAddress(0), // device address - mandatory bAddress(0), // device address - mandatory
bPollEnable(false) { // don't start polling before dongle is connected bPollEnable(false) { // don't start polling before dongle is connected
for(uint8_t i = 0; i < XBOX_MAX_ENDPOINTS; i++) { 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)]; uint8_t buf[sizeof (USB_DEVICE_DESCRIPTOR)];
USB_DEVICE_DESCRIPTOR * udd = reinterpret_cast<USB_DEVICE_DESCRIPTOR*>(buf); USB_DEVICE_DESCRIPTOR * udd = reinterpret_cast<USB_DEVICE_DESCRIPTOR*>(buf);
uint8_t rcode; uint8_t rcode;
UsbDevice *p = NULL; UsbDeviceDefinition *p = NULL;
EpInfo *oldep_ptr = NULL; EpInfo *oldep_ptr = NULL;
uint16_t PID; uint16_t PID;
uint16_t VID; uint16_t VID;

View file

@ -47,9 +47,9 @@ class XBOXONE : public USBDeviceConfig {
public: public:
/** /**
* Constructor for the XBOXONE class. * 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 */ /** @name USBDeviceConfig implementation */
/** /**
@ -132,8 +132,8 @@ public:
bool XboxOneConnected; bool XboxOneConnected;
protected: protected:
/** Pointer to USB class instance. */ /** Pointer to USBHost class instance. */
USB *pUsb; USBHost *pUsb;
/** Device address. */ /** Device address. */
uint8_t bAddress; uint8_t bAddress;
/** Endpoint info structure. */ /** Endpoint info structure. */

View file

@ -22,8 +22,8 @@
//#define EXTRADEBUG // Uncomment to get even more debugging data //#define EXTRADEBUG // Uncomment to get even more debugging data
//#define PRINTREPORT // Uncomment to print the report send by the Xbox 360 Controller //#define PRINTREPORT // Uncomment to print the report send by the Xbox 360 Controller
XBOXRECV::XBOXRECV(USB *p) : XBOXRECV::XBOXRECV(USBHost *p) :
pUsb(p), // pointer to USB class instance - mandatory pUsb(p), // pointer to USBHost class instance - mandatory
bAddress(0), // device address - mandatory bAddress(0), // device address - mandatory
bPollEnable(false) { // don't start polling before dongle is connected bPollEnable(false) { // don't start polling before dongle is connected
for(uint8_t i = 0; i < XBOX_MAX_ENDPOINTS; i++) { 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]; uint8_t buf[constBufSize];
USB_DEVICE_DESCRIPTOR * udd = reinterpret_cast<USB_DEVICE_DESCRIPTOR*>(buf); USB_DEVICE_DESCRIPTOR * udd = reinterpret_cast<USB_DEVICE_DESCRIPTOR*>(buf);
uint8_t rcode; uint8_t rcode;
UsbDevice *p = NULL; UsbDeviceDefinition *p = NULL;
EpInfo *oldep_ptr = NULL; EpInfo *oldep_ptr = NULL;
uint16_t PID, VID; uint16_t PID, VID;
@ -142,7 +142,7 @@ uint8_t XBOXRECV::Init(uint8_t parent, uint8_t port, bool lowspeed) {
#ifdef EXTRADEBUG #ifdef EXTRADEBUG
Notify(PSTR("\r\nBTD Init"), 0x80); Notify(PSTR("\r\nBTD Init"), 0x80);
#endif #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) { if(!p) {
#ifdef DEBUG_USB_HOST #ifdef DEBUG_USB_HOST

View file

@ -56,9 +56,9 @@ class XBOXRECV : public USBDeviceConfig {
public: public:
/** /**
* Constructor for the XBOXRECV class. * 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 */ /** @name USBDeviceConfig implementation */
/** /**
@ -231,8 +231,8 @@ public:
uint8_t Xbox360Connected[4]; uint8_t Xbox360Connected[4];
protected: protected:
/** Pointer to USB class instance. */ /** Pointer to USBHost class instance. */
USB *pUsb; USBHost *pUsb;
/** Device address. */ /** Device address. */
uint8_t bAddress; uint8_t bAddress;
/** Endpoint info structure. */ /** Endpoint info structure. */

View file

@ -20,8 +20,8 @@
//#define EXTRADEBUG // Uncomment to get even more debugging data //#define EXTRADEBUG // Uncomment to get even more debugging data
//#define PRINTREPORT // Uncomment to print the report send by the Xbox 360 Controller //#define PRINTREPORT // Uncomment to print the report send by the Xbox 360 Controller
XBOXUSB::XBOXUSB(USB *p) : XBOXUSB::XBOXUSB(USBHost *p) :
pUsb(p), // pointer to USB class instance - mandatory pUsb(p), // pointer to USBHost class instance - mandatory
bAddress(0), // device address - mandatory bAddress(0), // device address - mandatory
bPollEnable(false) { // don't start polling before dongle is connected bPollEnable(false) { // don't start polling before dongle is connected
for(uint8_t i = 0; i < XBOX_MAX_ENDPOINTS; i++) { 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)]; uint8_t buf[sizeof (USB_DEVICE_DESCRIPTOR)];
USB_DEVICE_DESCRIPTOR * udd = reinterpret_cast<USB_DEVICE_DESCRIPTOR*>(buf); USB_DEVICE_DESCRIPTOR * udd = reinterpret_cast<USB_DEVICE_DESCRIPTOR*>(buf);
uint8_t rcode; uint8_t rcode;
UsbDevice *p = NULL; UsbDeviceDefinition *p = NULL;
EpInfo *oldep_ptr = NULL; EpInfo *oldep_ptr = NULL;
uint16_t PID; uint16_t PID;
uint16_t VID; uint16_t VID;

View file

@ -54,9 +54,9 @@ class XBOXUSB : public USBDeviceConfig {
public: public:
/** /**
* Constructor for the XBOXUSB class. * 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 */ /** @name USBDeviceConfig implementation */
/** /**
@ -185,8 +185,8 @@ public:
bool Xbox360Connected; bool Xbox360Connected;
protected: protected:
/** Pointer to USB class instance. */ /** Pointer to USBHost class instance. */
USB *pUsb; USBHost *pUsb;
/** Device address. */ /** Device address. */
uint8_t bAddress; uint8_t bAddress;
/** Endpoint info structure. */ /** Endpoint info structure. */

View file

@ -72,7 +72,7 @@ struct UsbDeviceAddress {
#define bmUSB_DEV_ADDR_PARENT 0x38 #define bmUSB_DEV_ADDR_PARENT 0x38
#define bmUSB_DEV_ADDR_HUB 0x40 #define bmUSB_DEV_ADDR_HUB 0x40
struct UsbDevice { struct UsbDeviceDefinition {
EpInfo *epinfo; // endpoint info pointer EpInfo *epinfo; // endpoint info pointer
UsbDeviceAddress address; UsbDeviceAddress address;
uint8_t epcount; // number of endpoints uint8_t epcount; // number of endpoints
@ -82,12 +82,12 @@ struct UsbDevice {
class AddressPool { class AddressPool {
public: 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 uint8_t AllocAddress(uint8_t parent, bool is_hub = false, uint8_t port = 0) = 0;
virtual void FreeAddress(uint8_t addr) = 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_INDEX 0xFF
#define ADDR_ERROR_INVALID_ADDRESS 0xFF #define ADDR_ERROR_INVALID_ADDRESS 0xFF
@ -99,7 +99,7 @@ class AddressPoolImpl : public AddressPool {
uint8_t hubCounter; // hub counter is kept uint8_t hubCounter; // hub counter is kept
// in order to avoid hub address duplication // in order to avoid hub address duplication
UsbDevice thePool[MAX_DEVICES_ALLOWED]; UsbDeviceDefinition thePool[MAX_DEVICES_ALLOWED];
// Initializes address pool entry // Initializes address pool entry
@ -178,7 +178,7 @@ public:
// Returns a pointer to a specified address entry // Returns a pointer to a specified address entry
virtual UsbDevice* GetUsbDevicePtr(uint8_t addr) { virtual UsbDeviceDefinition* GetUsbDevicePtr(uint8_t addr) {
if(!addr) if(!addr)
return thePool; return thePool;

View file

@ -22,7 +22,7 @@ e-mail : support@circuitsathome.com
const uint8_t ADK::epDataInIndex = 1; const uint8_t ADK::epDataInIndex = 1;
const uint8_t ADK::epDataOutIndex = 2; 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* model,
const char* description, const char* description,
const char* version, const char* version,
@ -36,7 +36,7 @@ description(description),
version(version), version(version),
uri(uri), uri(uri),
serial(serial), serial(serial),
pUsb(p), //pointer to USB class instance - mandatory pUsb(p), //pointer to USBHost class instance - mandatory
bAddress(0), //device address - mandatory bAddress(0), //device address - mandatory
bConfNum(0), //configuration number bConfNum(0), //configuration number
bNumEP(1), //if config descriptor needs to be parsed 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<USB_DEVICE_DESCRIPTOR*>(buf); USB_DEVICE_DESCRIPTOR * udd = reinterpret_cast<USB_DEVICE_DESCRIPTOR*>(buf);
uint8_t rcode; uint8_t rcode;
uint8_t num_of_conf; // number of configurations uint8_t num_of_conf; // number of configurations
UsbDevice *p = NULL; UsbDeviceDefinition *p = NULL;
EpInfo *oldep_ptr = NULL; EpInfo *oldep_ptr = NULL;
// get memory address of USB device address pool // get memory address of USB device address pool

4
adk.h
View file

@ -70,7 +70,7 @@ protected:
static const uint8_t epDataOutIndex; // DataOUT endpoint index static const uint8_t epDataOutIndex; // DataOUT endpoint index
/* mandatory members */ /* mandatory members */
USB *pUsb; USBHost *pUsb;
uint8_t bAddress; uint8_t bAddress;
uint8_t bConfNum; // configuration number uint8_t bConfNum; // configuration number
@ -83,7 +83,7 @@ protected:
void PrintEndpointDescriptor(const USB_ENDPOINT_DESCRIPTOR* ep_ptr); void PrintEndpointDescriptor(const USB_ENDPOINT_DESCRIPTOR* ep_ptr);
public: public:
ADK(USB *pUsb, const char* manufacturer, ADK(USBHost *pUsb, const char* manufacturer,
const char* model, const char* model,
const char* description, const char* description,
const char* version, const char* version,

View file

@ -16,7 +16,7 @@ e-mail : support@circuitsathome.com
*/ */
#include "cdc_XR21B1411.h" #include "cdc_XR21B1411.h"
XR21B1411::XR21B1411(USB *p, CDCAsyncOper *pasync) : XR21B1411::XR21B1411(USBHost *p, CDCAsyncOper *pasync) :
ACM(p, pasync) { ACM(p, pasync) {
// Is this needed?? // Is this needed??
_enhanced_status = enhanced_features(); // Set up features _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<USB_DEVICE_DESCRIPTOR*>(buf); USB_DEVICE_DESCRIPTOR * udd = reinterpret_cast<USB_DEVICE_DESCRIPTOR*>(buf);
uint8_t rcode; uint8_t rcode;
UsbDevice *p = NULL; UsbDeviceDefinition *p = NULL;
EpInfo *oldep_ptr = NULL; EpInfo *oldep_ptr = NULL;
uint8_t num_of_conf; // number of configurations uint8_t num_of_conf; // number of configurations

View file

@ -104,7 +104,7 @@ class XR21B1411 : public ACM {
protected: protected:
public: public:
XR21B1411(USB *pusb, CDCAsyncOper *pasync); XR21B1411(USBHost *pusb, CDCAsyncOper *pasync);
/** /**
* Used by the USB core to check what this driver support. * Used by the USB core to check what this driver support.

View file

@ -20,7 +20,7 @@ const uint8_t ACM::epDataInIndex = 1;
const uint8_t ACM::epDataOutIndex = 2; const uint8_t ACM::epDataOutIndex = 2;
const uint8_t ACM::epInterruptInIndex = 3; const uint8_t ACM::epInterruptInIndex = 3;
ACM::ACM(USB *p, CDCAsyncOper *pasync) : ACM::ACM(USBHost *p, CDCAsyncOper *pasync) :
pUsb(p), pUsb(p),
pAsync(pasync), pAsync(pasync),
bAddress(0), bAddress(0),
@ -51,7 +51,7 @@ uint8_t ACM::Init(uint8_t parent, uint8_t port, bool lowspeed) {
USB_DEVICE_DESCRIPTOR * udd = reinterpret_cast<USB_DEVICE_DESCRIPTOR*>(buf); USB_DEVICE_DESCRIPTOR * udd = reinterpret_cast<USB_DEVICE_DESCRIPTOR*>(buf);
uint8_t rcode; uint8_t rcode;
UsbDevice *p = NULL; UsbDeviceDefinition *p = NULL;
EpInfo *oldep_ptr = NULL; EpInfo *oldep_ptr = NULL;
uint8_t num_of_conf; // number of configurations uint8_t num_of_conf; // number of configurations

View file

@ -166,7 +166,7 @@ protected:
static const uint8_t epDataOutIndex; // DataOUT endpoint index static const uint8_t epDataOutIndex; // DataOUT endpoint index
static const uint8_t epInterruptInIndex; // InterruptIN endpoint index static const uint8_t epInterruptInIndex; // InterruptIN endpoint index
USB *pUsb; USBHost *pUsb;
CDCAsyncOper *pAsync; CDCAsyncOper *pAsync;
uint8_t bAddress; uint8_t bAddress;
uint8_t bConfNum; // configuration number uint8_t bConfNum; // configuration number
@ -183,7 +183,7 @@ protected:
void PrintEndpointDescriptor(const USB_ENDPOINT_DESCRIPTOR* ep_ptr); void PrintEndpointDescriptor(const USB_ENDPOINT_DESCRIPTOR* ep_ptr);
public: 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 SetCommFeature(uint16_t fid, uint8_t nbytes, uint8_t *dataptr);
uint8_t GetCommFeature(uint16_t fid, uint8_t nbytes, uint8_t *dataptr); uint8_t GetCommFeature(uint16_t fid, uint8_t nbytes, uint8_t *dataptr);

View file

@ -20,7 +20,7 @@ const uint8_t FTDI::epDataInIndex = 1;
const uint8_t FTDI::epDataOutIndex = 2; const uint8_t FTDI::epDataOutIndex = 2;
const uint8_t FTDI::epInterruptInIndex = 3; 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), pAsync(pasync),
pUsb(p), pUsb(p),
bAddress(0), bAddress(0),
@ -44,7 +44,7 @@ uint8_t FTDI::Init(uint8_t parent, uint8_t port, bool lowspeed) {
uint8_t buf[constBufSize]; uint8_t buf[constBufSize];
USB_DEVICE_DESCRIPTOR * udd = reinterpret_cast<USB_DEVICE_DESCRIPTOR*>(buf); USB_DEVICE_DESCRIPTOR * udd = reinterpret_cast<USB_DEVICE_DESCRIPTOR*>(buf);
uint8_t rcode; uint8_t rcode;
UsbDevice *p = NULL; UsbDeviceDefinition *p = NULL;
EpInfo *oldep_ptr = NULL; EpInfo *oldep_ptr = NULL;
uint8_t num_of_conf; // number of configurations uint8_t num_of_conf; // number of configurations

View file

@ -99,7 +99,7 @@ class FTDI : public USBDeviceConfig, public UsbConfigXtracter {
static const uint8_t epInterruptInIndex; // InterruptIN endpoint index static const uint8_t epInterruptInIndex; // InterruptIN endpoint index
FTDIAsyncOper *pAsync; FTDIAsyncOper *pAsync;
USB *pUsb; USBHost *pUsb;
uint8_t bAddress; uint8_t bAddress;
uint8_t bConfNum; // configuration number uint8_t bConfNum; // configuration number
uint8_t bNumIface; // number of interfaces in the configuration 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); void PrintEndpointDescriptor(const USB_ENDPOINT_DESCRIPTOR* ep_ptr);
public: 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 SetBaudRate(uint32_t baud);
uint8_t SetModemControl(uint16_t control); uint8_t SetModemControl(uint16_t control);

View file

@ -16,7 +16,7 @@ e-mail : support@circuitsathome.com
*/ */
#include "cdcprolific.h" #include "cdcprolific.h"
PL2303::PL2303(USB *p, CDCAsyncOper *pasync) : PL2303::PL2303(USBHost *p, CDCAsyncOper *pasync) :
ACM(p, pasync), ACM(p, pasync),
wPLType(0) { wPLType(0) {
} }
@ -27,7 +27,7 @@ uint8_t PL2303::Init(uint8_t parent, uint8_t port, bool lowspeed) {
uint8_t buf[constBufSize]; uint8_t buf[constBufSize];
USB_DEVICE_DESCRIPTOR * udd = reinterpret_cast<USB_DEVICE_DESCRIPTOR*>(buf); USB_DEVICE_DESCRIPTOR * udd = reinterpret_cast<USB_DEVICE_DESCRIPTOR*>(buf);
uint8_t rcode; uint8_t rcode;
UsbDevice *p = NULL; UsbDeviceDefinition *p = NULL;
EpInfo *oldep_ptr = NULL; EpInfo *oldep_ptr = NULL;
uint8_t num_of_conf; // number of configurations uint8_t num_of_conf; // number of configurations
#ifdef PL2303_COMPAT #ifdef PL2303_COMPAT

View file

@ -123,7 +123,7 @@ class PL2303 : public ACM {
uint16_t wPLType; // Type of chip uint16_t wPLType; // Type of chip
public: public:
PL2303(USB *pusb, CDCAsyncOper *pasync); PL2303(USBHost *pusb, CDCAsyncOper *pasync);
// USBDeviceConfig implementation // USBDeviceConfig implementation
uint8_t Init(uint8_t parent, uint8_t port, bool lowspeed); uint8_t Init(uint8_t parent, uint8_t port, bool lowspeed);

View file

@ -218,7 +218,7 @@ class HIDBoot : public USBHID //public USBDeviceConfig, public UsbConfigXtracter
}; };
public: public:
HIDBoot(USB *p); HIDBoot(USBHost *p);
virtual bool SetReportParser(uint8_t id, HIDReportParser *prs) { virtual bool SetReportParser(uint8_t id, HIDReportParser *prs) {
pRptParser[id] = prs; pRptParser[id] = prs;
@ -252,7 +252,7 @@ public:
}; };
template <const uint8_t BOOT_PROTOCOL> template <const uint8_t BOOT_PROTOCOL>
HIDBoot<BOOT_PROTOCOL>::HIDBoot(USB *p) : HIDBoot<BOOT_PROTOCOL>::HIDBoot(USBHost *p) :
USBHID(p), USBHID(p),
qNextPollTime(0), qNextPollTime(0),
bPollEnable(false) { bPollEnable(false) {
@ -285,7 +285,7 @@ uint8_t HIDBoot<BOOT_PROTOCOL>::Init(uint8_t parent, uint8_t port, bool lowspeed
uint8_t buf[constBufSize]; uint8_t buf[constBufSize];
uint8_t rcode; uint8_t rcode;
UsbDevice *p = NULL; UsbDeviceDefinition *p = NULL;
EpInfo *oldep_ptr = NULL; EpInfo *oldep_ptr = NULL;
uint8_t len = 0; uint8_t len = 0;
//uint16_t cd_len = 0; //uint16_t cd_len = 0;

View file

@ -17,7 +17,7 @@ e-mail : support@circuitsathome.com
#include "hiduniversal.h" #include "hiduniversal.h"
HIDUniversal::HIDUniversal(USB *p) : HIDUniversal::HIDUniversal(USBHost *p) :
USBHID(p), USBHID(p),
qNextPollTime(0), qNextPollTime(0),
pollInterval(0), pollInterval(0),
@ -99,7 +99,7 @@ uint8_t HIDUniversal::Init(uint8_t parent, uint8_t port, bool lowspeed) {
uint8_t buf[constBufSize]; uint8_t buf[constBufSize];
USB_DEVICE_DESCRIPTOR * udd = reinterpret_cast<USB_DEVICE_DESCRIPTOR*>(buf); USB_DEVICE_DESCRIPTOR * udd = reinterpret_cast<USB_DEVICE_DESCRIPTOR*>(buf);
uint8_t rcode; uint8_t rcode;
UsbDevice *p = NULL; UsbDeviceDefinition *p = NULL;
EpInfo *oldep_ptr = NULL; EpInfo *oldep_ptr = NULL;
uint8_t len = 0; uint8_t len = 0;

View file

@ -80,7 +80,7 @@ protected:
}; };
public: public:
HIDUniversal(USB *p); HIDUniversal(USBHost *p);
// HID implementation // HID implementation
bool SetReportParser(uint8_t id, HIDReportParser *prs); bool SetReportParser(uint8_t id, HIDReportParser *prs);

View file

@ -6,7 +6,7 @@
# Datatypes (KEYWORD1) # Datatypes (KEYWORD1)
#################################################### ####################################################
USB KEYWORD1 USBHost KEYWORD1
USBHub KEYWORD1 USBHub KEYWORD1
#################################################### ####################################################

View file

@ -219,7 +219,7 @@ again:
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
BulkOnly::BulkOnly(USB *p) : BulkOnly::BulkOnly(USBHost *p) :
pUsb(p), pUsb(p),
bAddress(0), bAddress(0),
bIface(0), bIface(0),
@ -255,7 +255,7 @@ uint8_t BulkOnly::ConfigureDevice(uint8_t parent, uint8_t port, bool lowspeed) {
uint8_t buf[constBufSize]; uint8_t buf[constBufSize];
USB_DEVICE_DESCRIPTOR * udd = reinterpret_cast<USB_DEVICE_DESCRIPTOR*>(buf); USB_DEVICE_DESCRIPTOR * udd = reinterpret_cast<USB_DEVICE_DESCRIPTOR*>(buf);
uint8_t rcode; uint8_t rcode;
UsbDevice *p = NULL; UsbDeviceDefinition *p = NULL;
EpInfo *oldep_ptr = NULL; EpInfo *oldep_ptr = NULL;
USBTRACE("MS ConfigureDevice\r\n"); USBTRACE("MS ConfigureDevice\r\n");
ClearAllEP(); ClearAllEP();
@ -330,7 +330,7 @@ uint8_t BulkOnly::Init(uint8_t parent, uint8_t port, bool lowspeed) {
USBTRACE("MS Init\r\n"); USBTRACE("MS Init\r\n");
AddressPool &addrPool = pUsb->GetAddressPool(); AddressPool &addrPool = pUsb->GetAddressPool();
UsbDevice *p = addrPool.GetUsbDevicePtr(bAddress); UsbDeviceDefinition *p = addrPool.GetUsbDevicePtr(bAddress);
if(!p) if(!p)
return USB_ERROR_ADDRESS_NOT_FOUND_IN_POOL; return USB_ERROR_ADDRESS_NOT_FOUND_IN_POOL;

View file

@ -465,7 +465,7 @@ protected:
static const uint8_t epDataOutIndex; // DataOUT endpoint index static const uint8_t epDataOutIndex; // DataOUT endpoint index
static const uint8_t epInterruptInIndex; // InterruptIN endpoint index static const uint8_t epInterruptInIndex; // InterruptIN endpoint index
USB *pUsb; USBHost *pUsb;
uint8_t bAddress; uint8_t bAddress;
uint8_t bConfNum; // configuration number uint8_t bConfNum; // configuration number
uint8_t bIface; // interface value uint8_t bIface; // interface value
@ -493,7 +493,7 @@ protected:
return 0; return 0;
}; };
public: public:
BulkOnly(USB *p); BulkOnly(USBHost *p);
uint8_t GetLastUsbError() { uint8_t GetLastUsbError() {
return bLastUsbError; return bLastUsbError;

View file

@ -39,7 +39,7 @@ e-mail : support@circuitsathome.com
static uint8_t lcdPins; //copy of LCD pins 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; lcdPins = 0;
} }

View file

@ -63,10 +63,10 @@ e-mail : support@circuitsathome.com
#define LCD_5x8DOTS 0x00 #define LCD_5x8DOTS 0x00
class Max_LCD : public Print { class Max_LCD : public Print {
USB *pUsb; USBHost *pUsb;
public: public:
Max_LCD(USB *pusb); Max_LCD(USBHost *pusb);
void init(); void init();
void begin(uint8_t cols, uint8_t rows, uint8_t charsize = LCD_5x8DOTS); void begin(uint8_t cols, uint8_t rows, uint8_t charsize = LCD_5x8DOTS);
void clear(); void clear();

View file

@ -120,7 +120,7 @@ struct HidItemPrefix {
uint8_t bSize : 2; uint8_t bSize : 2;
uint8_t bType : 2; uint8_t bType : 2;
uint8_t bTag : 4; uint8_t bTag : 4;
}; } __attribute__((packed));
struct MainItemIOFeature { struct MainItemIOFeature {
uint8_t bmIsConstantOrData : 1; uint8_t bmIsConstantOrData : 1;
@ -131,7 +131,7 @@ struct MainItemIOFeature {
uint8_t bmIsNoPreferedOrPrefered : 1; uint8_t bmIsNoPreferedOrPrefered : 1;
uint8_t bmIsNullOrNoNull : 1; uint8_t bmIsNullOrNoNull : 1;
uint8_t bmIsVolatileOrNonVolatile : 1; uint8_t bmIsVolatileOrNonVolatile : 1;
}; } __attribute__((packed));
class USBHID; class USBHID;
@ -142,7 +142,7 @@ public:
class USBHID : public USBDeviceConfig, public UsbConfigXtracter { class USBHID : public USBDeviceConfig, public UsbConfigXtracter {
protected: protected:
USB *pUsb; // USB class instance pointer USBHost *pUsb; // USBHost class instance pointer
uint8_t bAddress; // address uint8_t bAddress; // address
protected: protected:
@ -162,10 +162,10 @@ protected:
public: public:
USBHID(USB *pusb) : pUsb(pusb) { USBHID(USBHost *pusb) : pUsb(pusb) {
}; };
const USB* GetUsb() { const USBHost* GetUsb() {
return pUsb; return pUsb;
}; };

View file

@ -18,7 +18,7 @@ e-mail : support@circuitsathome.com
bool USBHub::bResetInitiated = false; bool USBHub::bResetInitiated = false;
USBHub::USBHub(USB *p) : USBHub::USBHub(USBHost *p) :
pUsb(p), pUsb(p),
bAddress(0), bAddress(0),
bNbrPorts(0), bNbrPorts(0),
@ -47,7 +47,7 @@ uint8_t USBHub::Init(uint8_t parent, uint8_t port, bool lowspeed) {
HubDescriptor* hd = reinterpret_cast<HubDescriptor*>(buf); HubDescriptor* hd = reinterpret_cast<HubDescriptor*>(buf);
USB_CONFIGURATION_DESCRIPTOR * ucd = reinterpret_cast<USB_CONFIGURATION_DESCRIPTOR*>(buf); USB_CONFIGURATION_DESCRIPTOR * ucd = reinterpret_cast<USB_CONFIGURATION_DESCRIPTOR*>(buf);
uint8_t rcode; uint8_t rcode;
UsbDevice *p = NULL; UsbDeviceDefinition *p = NULL;
EpInfo *oldep_ptr = NULL; EpInfo *oldep_ptr = NULL;
uint8_t len = 0; uint8_t len = 0;
uint16_t cd_len = 0; uint16_t cd_len = 0;

View file

@ -164,7 +164,7 @@ struct HubEvent {
class USBHub : USBDeviceConfig { class USBHub : USBDeviceConfig {
static bool bResetInitiated; // True when reset is triggered 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 EpInfo epInfo[2]; // interrupt endpoint info structure
@ -178,7 +178,7 @@ class USBHub : USBDeviceConfig {
uint8_t PortStatusChange(uint8_t port, HubEvent &evt); uint8_t PortStatusChange(uint8_t port, HubEvent &evt);
public: public:
USBHub(USB *p); USBHub(USBHost *p);
uint8_t ClearHubFeature(uint8_t fid); uint8_t ClearHubFeature(uint8_t fid);
uint8_t ClearPortFeature(uint8_t fid, uint8_t port, uint8_t sel = 0); 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)); 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__ #endif // __USBHUB_H__