libftdi-git Archives

Subject: port libftdi to libusb-1.0 branch, master, updated. v0.17-204-gc7e4c09

From: libftdi-git@xxxxxxxxxxxxxxxxxxxxxxx
To: libftdi-git@xxxxxxxxxxxxxxxxxxxxxxx
Date: Tue, 28 Jun 2011 16:30:17 +0200 (CEST)
The branch, master has been updated
       via  c7e4c09e68cfa6f5e112334aa1b3bb23401c8dc7 (commit)
      from  77377af7cb038876829f2421dba5977718ca154f (commit)


- Log -----------------------------------------------------------------
commit c7e4c09e68cfa6f5e112334aa1b3bb23401c8dc7
Author: Uwe Bonnes <bon@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx>
Date:   Fri Jun 17 17:47:21 2011 +0200

    Beginning of FT232H support. Many EEPROM values still need to be deciphered!

-----------------------------------------------------------------------

Summary of changes:
 src/ftdi.c |   33 ++++++++++++++++++++++++++++++---
 src/ftdi.h |   17 ++++++++++++++++-
 2 files changed, 46 insertions(+), 4 deletions(-)

diff --git a/src/ftdi.c b/src/ftdi.c
index 33b6a50..e7902d4 100644
--- a/src/ftdi.c
+++ b/src/ftdi.c
@@ -428,7 +428,7 @@ static unsigned int _ftdi_determine_max_packet_size(struct 
ftdi_context *ftdi, l
     // Determine maximum packet size. Init with default value.
     // New hi-speed devices from FTDI use a packet size of 512 bytes
     // but could be connected to a normal speed USB hub -> 64 bytes packet 
size.
-    if (ftdi->type == TYPE_2232H || ftdi->type == TYPE_4232H)
+    if (ftdi->type == TYPE_2232H || ftdi->type == TYPE_4232H || ftdi->type == 
TYPE_232H )
         packet_size = 512;
     else
         packet_size = 64;
@@ -564,6 +564,8 @@ int ftdi_usb_open_dev(struct ftdi_context *ftdi, 
libusb_device *dev)
         ftdi->type = TYPE_2232H;
     else if (desc.bcdDevice == 0x800)
         ftdi->type = TYPE_4232H;
+    else if (desc.bcdDevice == 0x900)
+        ftdi->type = TYPE_232H;
 
     // Determine maximum packet size
     ftdi->max_packet_size = _ftdi_determine_max_packet_size(ftdi, dev);
@@ -2205,6 +2207,10 @@ int ftdi_eeprom_initdefaults(struct ftdi_context *ftdi, 
char * manufacturer,
     if ((ftdi->type == TYPE_AM) || (ftdi->type == TYPE_BM) ||
             (ftdi->type == TYPE_R))
         eeprom->product_id = 0x6001;
+    else if (ftdi->type == TYPE_4232H)
+        eeprom->product_id = 0x6011;
+    else if (ftdi->type == TYPE_232H)
+        eeprom->product_id = 0x6014;
     else
         eeprom->product_id = 0x6010;
     if (ftdi->type == TYPE_AM)
@@ -2366,6 +2372,9 @@ int ftdi_eeprom_build(struct ftdi_context *ftdi)
         case TYPE_4232H:
             output[0x07] = 0x08;
             break;
+        case TYPE_232H:
+            output[0x07] = 0x09;
+            break;
         default:
             output[0x07] = 0x00;
     }
@@ -2408,9 +2417,12 @@ int ftdi_eeprom_build(struct ftdi_context *ftdi)
     // Dynamic content
     // Strings start at 0x94 (TYPE_AM, TYPE_BM)
     // 0x96 (TYPE_2232C), 0x98 (TYPE_R) and 0x9a (TYPE_x232H)
+    // 0xa0 (TYPE_232H)
     i = 0;
     switch (ftdi->type)
     {
+        case TYPE_232H:
+            i += 2;
         case TYPE_2232H:
         case TYPE_4232H:
             i += 2;
@@ -2642,7 +2654,14 @@ int ftdi_eeprom_build(struct ftdi_context *ftdi)
 
             break;
         case TYPE_4232H:
+            output[0x18] = eeprom->chip;
             fprintf(stderr,"FIXME: Build FT4232H specific EEPROM settings\n");
+            break;
+        case TYPE_232H:
+            output[0x1e] = eeprom->chip;
+            fprintf(stderr,"FIXME: Build FT232H specific EEPROM settings\n");
+            break;
+              
     }
 
     // calculate checksum
@@ -2878,10 +2897,15 @@ int ftdi_eeprom_decode(struct ftdi_context *ftdi, int 
verbose)
         eeprom->group3_schmitt = (buf[0x0d] >> 4) & IS_SCHMITT;
         eeprom->group3_slew    = (buf[0x0d] >> 4) & SLOW_SLEW;
     }
+    else if (ftdi->type == TYPE_232H)
+    {
+        eeprom->chip = buf[0x1e];
+        /*FIXME: Decipher more values*/
+    }
 
     if (verbose)
     {
-        char *channel_mode[] = {"UART","245","CPU", "unknown", "OPTO"};
+        char *channel_mode[] = {"UART","245","CPU", "unknown", "OPTO"/*, 
"FT1284"*/};
         fprintf(stdout, "VID:     0x%04x\n",eeprom->vendor_id);
         fprintf(stdout, "PID:     0x%04x\n",eeprom->product_id);
         fprintf(stdout, "Release: 0x%04x\n",release);
@@ -2914,7 +2938,7 @@ int ftdi_eeprom_decode(struct ftdi_context *ftdi, int 
verbose)
                     channel_mode[eeprom->channel_a_type],
                     (eeprom->channel_a_driver)?" VCP":"",
                     (eeprom->high_current_a)?" High Current IO":"");
-        if ((ftdi->type >= TYPE_2232C) && (ftdi->type != TYPE_R))
+        if ((ftdi->type >= TYPE_2232C) && (ftdi->type != TYPE_R) && 
(ftdi->type != TYPE_232H))
             fprintf(stdout,"Channel B has Mode %s%s%s\n",
                     channel_mode[eeprom->channel_b_type],
                     (eeprom->channel_b_driver)?" VCP":"",
@@ -3431,6 +3455,9 @@ int ftdi_write_eeprom_location(struct ftdi_context *ftdi, 
int eeprom_addr,
         case TYPE_4232H:
             chip_type_location = 0x18;
             break;
+        case TYPE_232H:
+            chip_type_location = 0x1e;
+            break;
         default:
             ftdi_error_return(-4, "Device can't access unprotected area");
     }
diff --git a/src/ftdi.h b/src/ftdi.h
index b43f6ec..dced21d 100644
--- a/src/ftdi.h
+++ b/src/ftdi.h
@@ -23,7 +23,7 @@
 #define FTDI_MAX_EEPROM_SIZE 256
 
 /** FTDI chip type */
-enum ftdi_chip_type { TYPE_AM=0, TYPE_BM=1, TYPE_2232C=2, TYPE_R=3, 
TYPE_2232H=4, TYPE_4232H=5 };
+enum ftdi_chip_type { TYPE_AM=0, TYPE_BM=1, TYPE_2232C=2, TYPE_R=3, 
TYPE_2232H=4, TYPE_4232H=5, TYPE_232H=6 };
 /** Parity mode for ftdi_set_line_property() */
 enum ftdi_parity_type { NONE=0, ODD=1, EVEN=2, MARK=3, SPACE=4 };
 /** Number of stop bits for ftdi_set_line_property() */
@@ -85,6 +85,21 @@ enum ftdi_module_detach_mode
 #define LOOPBACK_START 0x84
 #define LOOPBACK_END   0x85
 #define TCK_DIVISOR    0x86
+/* H Type specific commands */
+#define DIS_DIV_5       0x8a
+#define EN_DIV_5        0x8b
+#define EN_3_PHASE      0x8c
+#define DIS_3_PHASE     0x8d
+#define CLK_BITS        0x8e
+#define CLK_BYTES       0x8f
+#define CLK_WAIT_HIGH   0x94
+#define CLK_WAIT_LOW    0x95
+#define EN_ADAPTIVE     0x96
+#define DIS_ADAPTIVE    0x97
+#define CLK_BYTES_OR_HIGH 0x9c
+#define CLK_BYTES_OR_LOW  0x0d
+/*FT232H specific commands */
+#define DRIVE_OPEN_COLLECTOR 0x9e
 /* Value Low */
 /* Value HIGH */ /*rate is 12000000/((1+value)*2) */
 #define DIV_VALUE(rate) (rate > 6000000)?0:((6000000/rate -1) > 0xffff)? 
0xffff: (6000000/rate -1)


hooks/post-receive
-- 
port libftdi to libusb-1.0

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

Current Thread
  • port libftdi to libusb-1.0 branch, master, updated. v0.17-204-gc7e4c09, libftdi-git <=