usbBlaster,ftdiJtagMPSSE: fix alignment for 1 bit len read transaction
This commit is contained in:
parent
84aa0d14b9
commit
8ee65e7f9d
|
|
@ -271,7 +271,8 @@ int FtdiJtagMPSSE::writeTDI(uint8_t *tdi, uint8_t *tdo, uint32_t len, bool last)
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned char last_bit = (tdi) ? *tx_ptr : 0;
|
unsigned char last_bit = (tdi) ? *tx_ptr : 0;
|
||||||
bool double_write = true;
|
// never double write when nb_bit == 0
|
||||||
|
bool double_write = (nb_bit != 0) ? true : false;
|
||||||
|
|
||||||
if (nb_bit != 0) {
|
if (nb_bit != 0) {
|
||||||
display("%s read/write %d bit\n", __func__, nb_bit);
|
display("%s read/write %d bit\n", __func__, nb_bit);
|
||||||
|
|
@ -333,7 +334,7 @@ int FtdiJtagMPSSE::writeTDI(uint8_t *tdi, uint8_t *tdo, uint32_t len, bool last)
|
||||||
index++;
|
index++;
|
||||||
}
|
}
|
||||||
/* in this case for 1 one it's always bit 7 */
|
/* in this case for 1 one it's always bit 7 */
|
||||||
*rx_ptr |= ((c[index] & 0x80) << (7 - nb_bit));
|
*rx_ptr |= (((c[index]) & 0x80) >> (7 - nb_bit));
|
||||||
} else if (_ch552WA) {
|
} else if (_ch552WA) {
|
||||||
mpsse_write();
|
mpsse_write();
|
||||||
ftdi_read_data(_ftdi, c, 1);
|
ftdi_read_data(_ftdi, c, 1);
|
||||||
|
|
|
||||||
|
|
@ -211,6 +211,8 @@ int UsbBlaster::writeTDI(uint8_t *tx, uint8_t *rx, uint32_t len, bool end)
|
||||||
int num_read = _nb_bit;
|
int num_read = _nb_bit;
|
||||||
if (writeBit((rx)? rx_ptr:NULL, num_read/2) < 0)
|
if (writeBit((rx)? rx_ptr:NULL, num_read/2) < 0)
|
||||||
return -EXIT_FAILURE;
|
return -EXIT_FAILURE;
|
||||||
|
if (rx) // realign bits
|
||||||
|
*rx_ptr >>= (8 - nb_bit);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* set TMS high */
|
/* set TMS high */
|
||||||
|
|
@ -225,7 +227,7 @@ int UsbBlaster::writeTDI(uint8_t *tx, uint8_t *rx, uint32_t len, bool end)
|
||||||
if (writeBit((rx)? &tmp:NULL, 1) < 0)
|
if (writeBit((rx)? &tmp:NULL, 1) < 0)
|
||||||
return -EXIT_FAILURE;
|
return -EXIT_FAILURE;
|
||||||
if (rx)
|
if (rx)
|
||||||
*rx_ptr = (tmp & 0x80) | ((*rx_ptr) >> 1);
|
*rx_ptr |= (tmp & 0x80) >> (7 - nb_bit);
|
||||||
_in_buf[_nb_bit++] = mask;
|
_in_buf[_nb_bit++] = mask;
|
||||||
if (writeBit(NULL, 0) < 0)
|
if (writeBit(NULL, 0) < 0)
|
||||||
return -EXIT_FAILURE;
|
return -EXIT_FAILURE;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue