GambitDev / F401RE-USBHost

Dependencies:   FATFileSystem

Fork of F401RE-USBHost by Norimasa Okamoto

Revision:
22:eaefd60717c4
Parent:
21:b4d53cc6d6ac
Child:
23:7e6294a61139
--- a/USBHostSocketModem/USBHostSocketModem.cpp	Mon Jun 22 18:49:28 2015 +0000
+++ b/USBHostSocketModem/USBHostSocketModem.cpp	Mon Jun 22 19:57:32 2015 +0000
@@ -19,6 +19,12 @@
 
 #define DEVICE_TO_HOST  0x80
 #define HOST_TO_DEVICE  0x00
+#define DTR 0x0003
+//Communications and CDC Control Class
+#define CDCCONTROL 0x2
+//CDC Data Class
+#define CDCDATA 0xA
+
 
 USBHostSocketModem::USBHostSocketModem()
 {
@@ -72,14 +78,6 @@
                     printf("bulk_in == NULL\n");
                 }
                 bulk_in = dev->getEndpoint(bulk_intf, BULK_ENDPOINT, IN);
-                //int address1 = dev->getEndpoint(msd_intf, BULK_ENDPOINT, OUT).getAddress();
-                //int address2 = dev->getEndpoint(msd_intf, BULK_ENDPOINT, OUT).getAddress();
-                //printf("add1 = %i\n",address1);
-                //printf("add2 = %i\n",address2);
-                /*
-                int_in = dev->getEndpoint(msd_intf, INTERRUPT_ENDPOINT, IN);
-                int_out = dev->getEndpoint(msd_intf, INTERRUPT_ENDPOINT, OUT);
-                */
                 printf("!SocketModem Found!\n");
                 
                 if (!bulk_in || !bulk_out){
@@ -111,14 +109,14 @@
     //printf("subclass = %i\n",intf_subclass);
     //printf("msd_intf = %i\n",msd_intf);
     printf("intf_class = %i\n",intf_class);
-    if ((sm_intf == -1) && (intf_class == 0x2))
+    if ((sm_intf == -1) && (intf_class == CDCCONTROL))
     {
         sm_intf = intf_nb;
         int_intf = intf_nb;
         //printf("parse interface: sm_intf = %i\n", sm_intf);
         return true;
     }
-    else if ((sm_intf == 0) && (intf_class == 0xa))
+    else if ((sm_intf == 0) && (intf_class == CDCDATA))
     {
         sm_intf = intf_nb;
         bulk_intf = intf_nb;
@@ -148,8 +146,7 @@
 void USBHostSocketModem::setDTR()
 {
     //Set USB DTR to enable communication
-    uint16_t dtr = 0x0003;
-    int res = host->controlWrite(dev, 0x21, 0x22, dtr, 0, NULL, 0);
+    int res = host->controlWrite(dev, 0x21, 0x22, DTR, 0, NULL, 0);
 }