]> cvs.zerfleddert.de Git - usb-driver/commitdiff
some microoptimazation
authormichael <michael>
Tue, 1 May 2007 10:21:51 +0000 (10:21 +0000)
committermichael <michael>
Tue, 1 May 2007 10:21:51 +0000 (10:21 +0000)
jtagkey.c

index 129cfe1cc652d9d9f4214f74bfb1483d0036a4bd..fc762d368d211604cb0cb53ec6cdd2fca5ac775a 100644 (file)
--- a/jtagkey.c
+++ b/jtagkey.c
@@ -161,6 +161,7 @@ static void *jtagkey_reader(void *thread_arg) {
        pthread_exit(NULL);
 }
 
+/* TODO: Interpret JTAG commands and transfer in MPSSE mode */
 int jtagkey_transfer(WD_TRANSFER *tr, int fd, unsigned int request, int ppbase, int ecpbase, int num) {
        int ret = 0;
        int i;
@@ -171,7 +172,7 @@ int jtagkey_transfer(WD_TRANSFER *tr, int fd, unsigned int request, int ppbase,
        static unsigned char last_write = 0x00;
        static unsigned char writebuf[USBBUFSIZE], *writepos = writebuf;
        static unsigned char readbuf[USBBUFSIZE], *readpos;
-       unsigned char data, prev_data;
+       unsigned char data, prev_data, last_cyc_write;
        struct jtagkey_reader_arg targ;
        pthread_t reader_thread;
 
@@ -212,6 +213,8 @@ int jtagkey_transfer(WD_TRANSFER *tr, int fd, unsigned int request, int ppbase,
                writepos = writebuf;
        }
 
+       last_cyc_write = last_write;
+
        for (i = 0; i < num; i++) {
                DPRINTF("dwPort: 0x%lx, cmdTrans: %lu, dwbytes: %ld, fautoinc: %ld, dwoptions: %ld\n",
                                (unsigned long)tr[i].dwPort, tr[i].cmdTrans, tr[i].dwBytes,
@@ -283,7 +286,7 @@ int jtagkey_transfer(WD_TRANSFER *tr, int fd, unsigned int request, int ppbase,
                        }
                }
 
-               if (nread || (*writepos != prev_data) || (i == num-1))
+               if ((tr[i].cmdTrans == PP_READ) || (*writepos != prev_data) || (i == num-1))
                        writepos++;
        }
 
@@ -316,6 +319,7 @@ int jtagkey_transfer(WD_TRANSFER *tr, int fd, unsigned int request, int ppbase,
        }
 
        readpos = readbuf;
+       last_write = last_cyc_write;
 
        for (i = 0; i < num; i++) {
                DPRINTF("dwPort: 0x%lx, cmdTrans: %lu, dwbytes: %ld, fautoinc: %ld, dwoptions: %ld\n",
@@ -324,6 +328,10 @@ int jtagkey_transfer(WD_TRANSFER *tr, int fd, unsigned int request, int ppbase,
 
                port = (unsigned long)tr[i].dwPort;
                val = tr[i].Data.Byte;
+
+               if ((tr[i].cmdTrans != PP_READ) && (val == last_write) && (i != num-1))
+                       continue;
+
                readpos++;
 
                if (port == ppbase + PP_DATA) {
@@ -345,7 +353,7 @@ int jtagkey_transfer(WD_TRANSFER *tr, int fd, unsigned int request, int ppbase,
                                        if ((data & JTAGKEY_TDO) && (last_write & PP_PROG))
                                                val |= PP_TDO;
 
-                                       if (!(last_write & PP_PROG))
+                                       if (~last_write & PP_PROG)
                                                val |= 0x08;
 
                                        if (last_write & 0x40)
Impressum, Datenschutz