From 5ec12e41039900e26a716ca6024ad863789737a6 Mon Sep 17 00:00:00 2001 From: Roland Ruckerbauer Date: Tue, 26 Nov 2019 19:14:24 +0100 Subject: [PATCH] Support arbitrary bit counts jtagtap_tdi_tdo_seq pc-hosted --- src/platforms/pc-hosted/jtagtap.c | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/src/platforms/pc-hosted/jtagtap.c b/src/platforms/pc-hosted/jtagtap.c index fee3f13..cce1c71 100644 --- a/src/platforms/pc-hosted/jtagtap.c +++ b/src/platforms/pc-hosted/jtagtap.c @@ -95,8 +95,7 @@ void jtagtap_tdi_tdo_seq(uint8_t *DO, const uint8_t final_tms, const uint8_t *DI uint64_t DIl=*(uint64_t *)DI; - if(!ticks) return; - if (!DI && !DO) return; + if(!ticks || !DI) return; /* Reduce the length of DI according to the bits we're transmitting */ DIl&=(1L<<(ticks+1))-1; @@ -112,14 +111,8 @@ void jtagtap_tdi_tdo_seq(uint8_t *DO, const uint8_t final_tms, const uint8_t *DI } if (DO) { - uint64_t Dol; - int i = 8; - while (ticks > 0) { - Dol = remotehston(8 , (char *)&construct[s - i]); - memcpy (DO, &Dol, (ticks + 7) / 8); - ticks -= 64; - i += 8; - } + for (unsigned int i = 1; i*8 <= (unsigned int)ticks; i++) + DO[i - 1] = remotehston(2 , (char *)&construct[s - (i * 2)]); } }