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;
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;
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,
}
}
- if (nread || (*writepos != prev_data) || (i == num-1))
+ if ((tr[i].cmdTrans == PP_READ) || (*writepos != prev_data) || (i == num-1))
writepos++;
}
}
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",
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) {
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)