Merge pull request #118 from UweBonnes/mpsse_toggle

ftdiJtagMPSSE: Fix TCK toggle for large  numbers.
This commit is contained in:
Gwenhael Goavec-Merou 2021-09-29 06:31:50 +02:00 committed by GitHub
commit 2e64a52cb5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 18 additions and 11 deletions

View File

@ -169,17 +169,24 @@ int FtdiJtagMPSSE::toggleClk(uint8_t tms, uint8_t tdi, uint32_t clk_len)
if (_ftdi->type == TYPE_2232H || _ftdi->type == TYPE_4232H || if (_ftdi->type == TYPE_2232H || _ftdi->type == TYPE_4232H ||
_ftdi->type == TYPE_232H) { _ftdi->type == TYPE_232H) {
uint8_t buf[] = {static_cast<uint8_t>(0x8f), 0, 0}; uint8_t buf[] = {static_cast<uint8_t>(0x8f), 0, 0};
if (clk_len > 8) { while (len) {
buf[1] = ((len / 8) ) & 0xff; unsigned int chunk = len;
buf[2] = ((len / 8) >> 8) & 0xff; if (chunk > 0x10000 * 8)
mpsse_store(buf, 3); chunk = 0x10000 * 8;
len %= 8; if (chunk > 8) {
} unsigned cycles8 = chunk / 8;
len -= cycles8 * 8;
if (len > 0) { cycles8 --;
buf[0] = 0x8E; buf[1] = ((cycles8) ) & 0xff;
buf[1] = len - 1; buf[2] = ((cycles8) >> 8) & 0xff;
mpsse_store(buf, 2); mpsse_store(buf, 3);
}
if (len && len < 9) {
buf[0] = 0x8E;
buf[1] = len - 1;
mpsse_store(buf, 2);
len = 0;
}
} }
ret = clk_len; ret = clk_len;
} else { } else {