]> git.zerfleddert.de Git - usb-driver/blobdiff - jtagkey.c
Add support for different interfaces on FTDI chips.
[usb-driver] / jtagkey.c
index fc9587cb5dcc1e23e873e08d40ea38470fd0e96e..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;
@@ -175,7 +175,7 @@ int jtagkey_transfer(WD_TRANSFER *tr, int fd, unsigned int request, int ppbase,
                unsigned char *pos = writebuf;
                int len;
 
-               DPRINTF("writing %d bytes due to %d following reads in %d chunks or full buffer\n", writepos-writebuf, nread, num);
+               DPRINTF("writing %zd bytes due to %d following reads in %d chunks or full buffer\n", writepos-writebuf, nread, num);
                jtagkey_latency(BULK_LATENCY);
 
                targ.num = writepos-pos;
@@ -188,7 +188,7 @@ int jtagkey_transfer(WD_TRANSFER *tr, int fd, unsigned int request, int ppbase,
                        if (len > USBBUFSIZE)
                                len = USBBUFSIZE;
 
-                       DPRINTF("combined write of %d/%d\n",len,writepos-pos);
+                       DPRINTF("combined write of %d/%zd\n",len,writepos-pos);
                        ftdi_write_data(&ftdic, pos, len);
                        pos += len;
                }
@@ -279,7 +279,7 @@ int jtagkey_transfer(WD_TRANSFER *tr, int fd, unsigned int request, int ppbase,
 
        if (nread)
        {
-               DPRINTF("writing %d bytes\n", writepos-writebuf);
+               DPRINTF("writing %zd bytes\n", writepos-writebuf);
 
                *writepos = last_data;
                writepos++;
@@ -293,10 +293,8 @@ int jtagkey_transfer(WD_TRANSFER *tr, int fd, unsigned int request, int ppbase,
                pthread_join(reader_thread, NULL);
 
 #ifdef DEBUG
-               DPRINTF("write: ");
-               hexdump(writebuf, writepos-writebuf);
-               DPRINTF("read: ");
-               hexdump(readbuf, i);
+               hexdump(writebuf, writepos-writebuf, "->");
+               hexdump(readbuf, i, "<-");
 #endif
 
                writepos = writebuf;
Impressum, Datenschutz