]> git.zerfleddert.de Git - usb-driver/commitdiff
Add support for different interfaces on FTDI chips.
authorMichal Demin <michaldemin@gmail.com>
Mon, 10 Jan 2011 13:54:10 +0000 (14:54 +0100)
committerMichael Gernoth <michael@gernoth.net>
Sun, 23 Jan 2011 11:52:27 +0000 (12:52 +0100)
Signed-off-by: Michal Demin <michaldemin@gmail.com>
config.c
config.h
jtagkey.c
libusb-driverrc

index a39902e99e8a04f683f398266f0cc13ffddc94e8..2963129fbc95fc49d7bddf65f51605dd77a3ea53 100644 (file)
--- a/config.c
+++ b/config.c
@@ -23,6 +23,7 @@ static void read_config() {
 #ifdef JTAGKEY
        char *pbuf;
        unsigned short vid, pid;
+       unsigned short iface;
        int line, len, num;
 #endif
 
@@ -152,7 +153,7 @@ static void read_config() {
                                pbuf = buf + i;
 
                                for (; i < len; i++) {
-                                       if (buf[i] == ' ' || buf[i] == '\t')
+                                       if (buf[i] == ' ' || buf[i] == '\t' || buf[i] == ':')
                                                break;
                                }
 
@@ -163,9 +164,16 @@ static void read_config() {
                                        continue;
                                }
 
+                               iface = 0;
+                               pbuf = buf + i;
+                               if (pbuf[0] == ':') {
+                                       iface = atoi(pbuf + 1);
+                               }
+
                                pp_config[num].real = 0;
                                pp_config[num].usb_vid = vid;
                                pp_config[num].usb_pid = pid;
+                               pp_config[num].usb_iface = iface;
                                pp_config[num].open = jtagkey_open;
                                pp_config[num].close = jtagkey_close;
                                pp_config[num].transfer = jtagkey_transfer;
@@ -243,3 +251,20 @@ unsigned short config_usb_pid(int num) {
 
        return ret;
 }
+
+unsigned short config_usb_iface(int num) {
+       unsigned short ret = 0x00;
+       int i;
+       
+       read_config();
+       
+       for (i=0; i<sizeof(pp_config)/sizeof(struct parport_config); i++) {
+               if (pp_config[i].num == num) {
+                       ret = pp_config[i].usb_iface;
+                       break;
+               }
+       }
+
+       return ret;
+}
+
index f8005878f19c9f8a111c21af8ee523f0aeb50fc9..0c8097b20bfee02ccd67278bd738f6ee84e59c39 100644 (file)
--- a/config.h
+++ b/config.h
@@ -4,6 +4,7 @@ struct parport_config {
        unsigned char real;
        unsigned short usb_vid;
        unsigned short usb_pid;
+       unsigned short usb_iface;
        int (*open) (int num);
        void (*close) (int handle);
        int (*transfer) (WD_TRANSFER *tr, int fd, unsigned int request, int ppbase, int ecpbase, int num);
@@ -13,3 +14,4 @@ struct parport_config __attribute__ ((visibility ("hidden"))) *config_get(int nu
 unsigned char __attribute__ ((visibility ("hidden"))) config_is_real_pport(int num);
 unsigned short __attribute__ ((visibility ("hidden"))) config_usb_vid(int num);
 unsigned short __attribute__ ((visibility ("hidden"))) config_usb_pid(int num);
+unsigned short __attribute__ ((visibility ("hidden"))) config_usb_iface(int num);
index a3cb8eb9a2235559ae3a3034ac82fc59c069d8a8..c4f2beeb9679deb554d2c7e3496f8aaa680f07e7 100644 (file)
--- a/jtagkey.c
+++ b/jtagkey.c
@@ -32,7 +32,7 @@ static int jtagkey_latency(int latency) {
        return ret;
 }
 
-static int jtagkey_init(unsigned short vid, unsigned short pid) {
+static int jtagkey_init(unsigned short vid, unsigned short pid, unsigned short iface) {
        int ret = 0;
        unsigned char c;
 
@@ -51,7 +51,7 @@ static int jtagkey_init(unsigned short vid, unsigned short pid) {
                return ret;
        }
 
-       if ((ret = ftdi_set_interface(&ftdic, INTERFACE_A)) != 0) {
+       if ((ret = ftdi_set_interface(&ftdic, iface)) != 0) {
                fprintf(stderr, "unable to set interface: %d (%s)\n", ret, ftdi_get_error_string(&ftdic));
                return ret;
        }
@@ -93,7 +93,7 @@ static int jtagkey_init(unsigned short vid, unsigned short pid) {
 int jtagkey_open(int num) {
        int ret;
 
-       ret = jtagkey_init(config_usb_vid(num), config_usb_pid(num));
+       ret = jtagkey_init(config_usb_vid(num), config_usb_pid(num), config_usb_iface(num));
 
        if (ret >= 0)
                ret = 0xff;
index 98d0e31e4a8c7e090163bea542581d5dfb72c1d8..9cf82304116fe413c38a461c81dc42f76fe85e03 100644 (file)
@@ -4,3 +4,6 @@
 
 # Amontec Jtagkey
 LPT2 = FTDI:0403:cff8
+# Dangerous Prototypes Bus Blaster v2
+LPT3 = FTDI:0403:6010:2
+
Impressum, Datenschutz