Proper initialisation of interface A.
authorVladimir Yakovlev <nagos@inbox.ru>
Thu, 23 Dec 2010 13:05:42 +0000 (16:05 +0300)
committerThomas Jarosch <thomas.jarosch@intra2net.com>
Thu, 30 Dec 2010 09:10:09 +0000 (10:10 +0100)
Write correct ftdi->in_ep and others when initialising interface A.
Without it you can not switch back to interface A, after B.
In sequence A-B-A, B stuck forewer.

src/ftdi.c

index 30b5b55..b248c47 100644 (file)
@@ -93,10 +93,7 @@ int ftdi_init(struct ftdi_context *ftdi)
     ftdi->writebuffer_chunksize = 4096;
     ftdi->max_packet_size = 0;
 
-    ftdi->interface = 0;
-    ftdi->index = 0;
-    ftdi->in_ep = 0x02;
-    ftdi->out_ep = 0x81;
+    ftdi_set_interface(ftdi, INTERFACE_ANY);
     ftdi->bitbang_mode = 1; /* when bitbang is enabled this holds the number of the mode  */
 
     ftdi->error_str = NULL;
@@ -149,7 +146,10 @@ int ftdi_set_interface(struct ftdi_context *ftdi, enum ftdi_interface interface)
     {
         case INTERFACE_ANY:
         case INTERFACE_A:
-            /* ftdi_usb_open_desc cares to set the right index, depending on the found chip */
+            ftdi->interface = 0;
+            ftdi->index     = INTERFACE_A;
+            ftdi->in_ep     = 0x02;
+            ftdi->out_ep    = 0x81;
             break;
         case INTERFACE_B:
             ftdi->interface = 1;