Decode the x232H specific port functions
authorUwe Bonnes <bon@elektron.ikp.physik.tu-darmstadt.de>
Thu, 9 Sep 2010 21:33:11 +0000 (23:33 +0200)
committerThomas Jarosch <thomas.jarosch@intra2net.com>
Mon, 20 Sep 2010 13:34:39 +0000 (15:34 +0200)
src/ftdi.c
src/ftdi.h

index 389cf01..355ea58 100644 (file)
@@ -2661,11 +2661,20 @@ int ftdi_eeprom_decode(struct ftdi_context *ftdi, unsigned char *buf, int size,
         eeprom->cbus_function[3] = (buf[0x15] >> 4) & 0x0f;
         eeprom->cbus_function[4] = buf[0x16] & 0x0f;
     }
-    else if (ftdi->type == TYPE_2232H)
-    {
-    }
-    else if (ftdi->type == TYPE_4232H)
-    {
+    else if ((ftdi->type == TYPE_2232H) ||(ftdi->type == TYPE_4232H)) 
+    {
+        eeprom->group0_drive   =  buf[0x0c]       & DRIVE_16MA;
+        eeprom->group0_schmitt =  buf[0x0c]       & IS_SCHMITT;
+        eeprom->group0_slew    =  buf[0x0c]       & SLOW_SLEW;
+        eeprom->group1_drive   = (buf[0x0c] >> 4) & 0x3;
+        eeprom->group1_schmitt = (buf[0x0c] >> 4) & IS_SCHMITT;
+        eeprom->group1_slew    = (buf[0x0c] >> 4) & SLOW_SLEW;
+        eeprom->group2_drive   =  buf[0x0d]       & DRIVE_16MA;
+        eeprom->group2_schmitt =  buf[0x0d]       & IS_SCHMITT;
+        eeprom->group2_slew    =  buf[0x0d]       & SLOW_SLEW;
+        eeprom->group3_drive   = (buf[0x0d] >> 4) & DRIVE_16MA;
+        eeprom->group3_schmitt = (buf[0x0d] >> 4) & IS_SCHMITT;
+        eeprom->group3_slew    = (buf[0x0d] >> 4) & SLOW_SLEW;
     }
     
     if(verbose)
@@ -2687,7 +2696,7 @@ int ftdi_eeprom_decode(struct ftdi_context *ftdi, unsigned char *buf, int size,
         if(eeprom->serial)
             fprintf(stdout, "Serial:       %s\n",eeprom->serial);
         fprintf(stdout,     "Checksum      : %04x\n", checksum);
-        if ((ftdi->type = TYPE_2232C) || (ftdi->type = TYPE_R))
+        if (ftdi->type >= TYPE_2232C)
             fprintf(stdout,"Channel A has Mode %s%s%s\n", 
                     channel_mode[eeprom->channel_a_type],
                     (eeprom->channel_a_driver)?" VCP":"",
@@ -2697,6 +2706,29 @@ int ftdi_eeprom_decode(struct ftdi_context *ftdi, unsigned char *buf, int size,
                     channel_mode[eeprom->channel_b_type],
                     (eeprom->channel_b_driver)?" VCP":"",
                     (eeprom->high_current_b)?" High Currenr IO":"");
+        if ((ftdi->type == TYPE_2232H) || (ftdi->type == TYPE_4232H)) 
+        {
+            fprintf(stdout,"%s has %d mA drive%s%s\n",
+                    (ftdi->type == TYPE_2232H)?"AL":"A",
+                    (eeprom->group0_drive+1) *4,
+                    (eeprom->group0_schmitt)?" Schmitt Input":"",
+                    (eeprom->group0_slew)?" Slow Slew":"");
+            fprintf(stdout,"%s has %d mA drive%s%s\n",
+                    (ftdi->type == TYPE_2232H)?"AH":"B",
+                    (eeprom->group1_drive+1) *4,
+                    (eeprom->group1_schmitt)?" Schmitt Input":"",
+                    (eeprom->group1_slew)?" Slow Slew":"");
+            fprintf(stdout,"%s has %d mA drive%s%s\n",
+                    (ftdi->type == TYPE_2232H)?"BL":"C",
+                    (eeprom->group2_drive+1) *4,
+                    (eeprom->group2_schmitt)?" Schmitt Input":"",
+                    (eeprom->group2_slew)?" Slow Slew":"");
+            fprintf(stdout,"%s has %d mA drive%s%s\n",
+                    (ftdi->type == TYPE_2232H)?"BH":"D",
+                    (eeprom->group3_drive+1) *4,
+                    (eeprom->group3_schmitt)?" Schmitt Input":"",
+                    (eeprom->group3_slew)?" Slow Slew":"");
+        }
 
     }
 
index 0b4a487..2f6402a 100644 (file)
@@ -216,6 +216,7 @@ struct ftdi_eeprom
     /*  Driver Type, 1 = VCP */
     int channel_a_driver;
     int channel_b_driver;
+
     /* Special function of FT232R devices (and possibly others as well) */
     /** CBUS pin function. See CBUS_xxx defines. */
     int cbus_function[5];
@@ -226,6 +227,25 @@ struct ftdi_eeprom
     /** Select inversion of data lines (bitmask). */
     int invert;
 
+    /*2232H/4432H Group specific values */
+    /* Group0 is AL on 2322H and A on 4232H
+       Group1 is AH on 2232H and B on 4232H
+       Group2 is BL on 2322H and C on 4232H
+       Group3 is BH on 2232H and C on 4232H*/
+    int group0_drive;
+    int group0_schmitt;
+    int group0_slew;
+    int group1_drive;
+    int group1_schmitt;
+    int group1_slew;
+    int group2_drive;
+    int group2_schmitt;
+    int group2_slew;
+    int group3_drive;
+    int group3_schmitt;
+    int group3_slew;
+    
+
     /** eeprom size in bytes. This doesn't get stored in the eeprom
         but is the only way to pass it to ftdi_eeprom_build. */
     int size;
@@ -352,6 +372,13 @@ struct ftdi_device_list
 #define CHANNEL_IS_CPU  0x2
 #define CHANNEL_IS_OPTO 0x4
 
+#define DRIVE_4MA  0
+#define DRIVE_8MA  1
+#define DRIVE_12MA 2
+#define DRIVE_16MA 3
+#define SLOW_SLEW  4
+#define IS_SCHMITT 8
+
 /** Driver Type. */
 #define DRIVER_VCP 0x08