libftdi Archives

Subject: [PATCH]: Add 4232H interfaces

From: Alex Harford <harford@xxxxxxxxx>
To: libftdi@xxxxxxxxxxxxxxxxxxxxxxx
Date: Mon, 4 May 2009 20:03:42 -0700
This patch allows C/D BUS to be used on the 4232H, and initializes the
default interface for 2232H/4232H.

Alex

diff -ur libftdi-0.15.old/src/ftdi.c libftdi-0.15/src/ftdi.c
--- libftdi-0.15.old/src/ftdi.c 2009-05-04 14:35:44.000000000 -0700
+++ libftdi-0.15/src/ftdi.c     2009-05-04 16:19:36.000000000 -0700
@@ -129,7 +129,7 @@
     Open selected channels on a chip, otherwise use first channel.

     \param ftdi pointer to ftdi_context
-    \param interface Interface to use for FT2232C chips.
+    \param interface Interface to use for FT2232C/2232H/4232H chips.

     \retval  0: all fine
     \retval -1: unknown interface
@@ -147,6 +147,18 @@
         ftdi->in_ep     = 0x04;
         ftdi->out_ep    = 0x83;
         break;
+    case INTERFACE_C:
+        ftdi->interface = 2;
+        ftdi->index     = INTERFACE_C;
+        ftdi->in_ep     = 0x06;
+        ftdi->out_ep    = 0x85;
+        break;
+    case INTERFACE_D:
+        ftdi->interface = 3;
+        ftdi->index     = INTERFACE_D;
+        ftdi->in_ep     = 0x08;
+        ftdi->out_ep    = 0x87;
+        break;
     default:
         ftdi_error_return(-1, "Unknown interface");
     }
@@ -412,10 +424,16 @@
             ftdi->index = INTERFACE_A;
     } else if (dev->descriptor.bcdDevice == 0x600)
         ftdi->type = TYPE_R;
-    else if (dev->descriptor.bcdDevice == 0x700)
+    else if (dev->descriptor.bcdDevice == 0x700) {
         ftdi->type = TYPE_2232H;
-    else if (dev->descriptor.bcdDevice == 0x800)
+        if (!ftdi->index)
+            ftdi->index = INTERFACE_A;
+    }
+    else if (dev->descriptor.bcdDevice == 0x800) {
         ftdi->type = TYPE_4232H;
+        if (!ftdi->index)
+            ftdi->index = INTERFACE_A;
+    }

     ftdi_error_return(0, "all fine");
 }
diff -ur libftdi-0.15.old/src/ftdi.h libftdi-0.15/src/ftdi.h
--- libftdi-0.15.old/src/ftdi.h 2009-05-04 14:35:41.000000000 -0700
+++ libftdi-0.15/src/ftdi.h     2009-05-04 14:24:31.000000000 -0700
@@ -48,7 +48,9 @@
 enum ftdi_interface {
     INTERFACE_ANY = 0,
     INTERFACE_A   = 1,
-    INTERFACE_B   = 2
+    INTERFACE_B   = 2,
+    INTERFACE_C   = 3,
+    INTERFACE_D   = 4
 };

 /* Shifting commands IN MPSSE Mode*/

--
libftdi - see http://www.intra2net.com/en/developer/libftdi for details.
To unsubscribe send a mail to libftdi+unsubscribe@xxxxxxxxxxxxxxxxxxxxxxx   

Current Thread