Fixed for compatibility with Paradigma USB Serial device.

Dependencies:   mbed-rtos

Fork of USBHost by mbed official

Files at this revision

API Documentation at this revision

Comitter:
leihen
Date:
Sat Jun 22 10:48:26 2013 +0000
Parent:
10:0c11cf1cc218
Child:
12:ee5bb3a6193f
Commit message:
Modified to work with Paradigma USB device.

Changed in this revision

USBHost/USBHost.cpp Show annotated file Show diff for this revision Revisions of this file
USBHostSerial/USBHostSerial.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/USBHost/USBHost.cpp	Mon Mar 18 14:46:56 2013 +0000
+++ b/USBHost/USBHost.cpp	Sat Jun 22 10:48:26 2013 +0000
@@ -155,7 +155,7 @@
                         Thread::wait(100);
                     }
                     
-                    USB_INFO("New device connected: %p [hub: %d - port: %d]", &devices[i], usb_msg->hub, usb_msg->port);
+                    USB_INFO("New device connected: %p [hub: %d - port: %d - class: %d]", &devices[i], usb_msg->hub, usb_msg->port, buf[4]);
                     
 #if MAX_HUB_NB
                     if (buf[4] == HUB_CLASS) {
@@ -907,12 +907,14 @@
     while (index < len) {
         len_desc = conf_descr[index];
         id = conf_descr[index+1];
+        USB_INFO("Next ID in ConfDescr");
         switch (id) {
             case CONFIGURATION_DESCRIPTOR:
                 USB_DBG("dev: %p has %d intf", dev, conf_descr[4]);
                 dev->setNbIntf(conf_descr[4]);
                 break;
             case INTERFACE_DESCRIPTOR:
+                USB_INFO("Interface_Descriptor found !");
                 if(pEnumerator->parseInterface(conf_descr[index + 2], conf_descr[index + 5], conf_descr[index + 6], conf_descr[index + 7])) {
                     if (intf_nb++ <= MAX_INTF) {
                         current_intf = conf_descr[index + 2];
@@ -928,8 +930,10 @@
                 }
                 break;
             case ENDPOINT_DESCRIPTOR:
+                USB_INFO("Endpoint_Descriptor found!");
                 if (parsing_intf && (intf_nb <= MAX_INTF) ) {
                     if (nb_endpoints_used < MAX_ENDPOINT_PER_INTERFACE) {
+                        USB_INFO("Making call to useEndpoint");
                         if( pEnumerator->useEndpoint(current_intf, (ENDPOINT_TYPE)(conf_descr[index + 3] & 0x03), (ENDPOINT_DIRECTION)((conf_descr[index + 2] >> 7) + 1)) ) {
                             // if the USBEndpoint is isochronous -> skip it (TODO: fix this)
                             if ((conf_descr[index + 3] & 0x03) != ISOCHRONOUS_ENDPOINT) {
--- a/USBHostSerial/USBHostSerial.cpp	Mon Mar 18 14:46:56 2013 +0000
+++ b/USBHostSerial/USBHostSerial.cpp	Sat Jun 22 10:48:26 2013 +0000
@@ -95,7 +95,8 @@
         int len = bulk_in->getLengthTransferred();
         if (bulk_in->getState() == USB_TYPE_IDLE) {
             for (int i = 0; i < len; i++) {
-                circ_buf.queue(buf[i]);
+                if (i > 1)
+                    circ_buf.queue(buf[i]);
             }
             rx.call();
             host->bulkRead(dev, bulk_in, buf, size_bulk_in, false);
@@ -160,13 +161,20 @@
 
 /*virtual*/ bool USBHostSerial::parseInterface(uint8_t intf_nb, uint8_t intf_class, uint8_t intf_subclass, uint8_t intf_protocol) //Must return true if the interface should be parsed
 {
+    USB_DBG("HENRY Parsing Interface : %d : %d : %d : %d : %d", serial_intf, intf_class, intf_subclass, intf_protocol, SERIAL_CLASS);
+/*
     if ((serial_intf == -1) &&
         (intf_class == SERIAL_CLASS) &&
         (intf_subclass == 0x00) &&
         (intf_protocol == 0x00)) {
         serial_intf = intf_nb;
         return true;
+    }*/
+    if ((serial_intf == -1)){
+        serial_intf = intf_nb;
+        return true;
     }
+
     return false;
 }