From: michael Date: Sun, 29 Apr 2007 21:50:09 +0000 (+0000) Subject: make sure that there is valid data if the last command in a transfer is X-Git-Url: https://git.zerfleddert.de/cgi-bin/gitweb.cgi/usb-driver/commitdiff_plain/59b06a85e237c6e1ec74c22eac16ee010f07c630 make sure that there is valid data if the last command in a transfer is a read --- diff --git a/jtagkey.c b/jtagkey.c index 249e9d9..7707ae0 100644 --- a/jtagkey.c +++ b/jtagkey.c @@ -79,6 +79,7 @@ static int jtagkey_set_bbmode(unsigned char mode) { if (bitbang_mode != mode) { DPRINTF("switching bitbang-mode!\n"); + /* Wait for the latency-timer to kick in */ usleep(2); if ((ret = ftdi_set_bitmode(&ftdic, JTAGKEY_TCK|JTAGKEY_TDI|JTAGKEY_TMS|JTAGKEY_OEn, mode)) != 0) { @@ -236,6 +237,10 @@ int jtagkey_transfer(WD_TRANSFER *tr, int fd, unsigned int request, int ppbase, if (nread) { DPRINTF("writing %d bytes\n", writepos-writebuf); + + *writepos = last_data; + writepos++; + jtagkey_set_bbmode(BITMODE_SYNCBB); ftdi_write_data(&ftdic, writebuf, writepos-writebuf); @@ -276,6 +281,7 @@ int jtagkey_transfer(WD_TRANSFER *tr, int fd, unsigned int request, int ppbase, switch(tr[i].cmdTrans) { case PP_READ: data = *readpos; + #ifdef DEBUG DPRINTF("READ: 0x%x\n", data); jtagkey_state(data);