Skip to content

Commit 7e2f391

Browse files
committed
Unbreak jtag
1 parent b93097f commit 7e2f391

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/jtag.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -333,17 +333,18 @@ fn transfer<DEPS>(
333333
fn shift_register_data<DEPS>(
334334
jtag: &mut impl Jtag<DEPS>,
335335
mut data: u32,
336-
mut clocks: u8,
336+
clock_cycles: u8,
337337
exit_shift: bool,
338338
) -> u32 {
339339
// All bits except last with TMS = 0
340340
let mut captured_dr = 0;
341+
let mut clocks = clock_cycles;
341342
while clocks > 1 {
342343
let bits = (clocks - 1).min(8);
343344

344345
let captured_byte = shift_tdi(jtag, data as u8, bits, false);
345346
captured_dr >>= bits;
346-
captured_dr |= (captured_byte as u32) << (32 - bits);
347+
captured_dr |= (captured_byte as u32) << (clock_cycles - bits);
347348

348349
data >>= bits;
349350
clocks -= bits;
@@ -352,7 +353,7 @@ fn shift_register_data<DEPS>(
352353
// Last bit (with TMS = 1 if exit_shift)
353354
let captured_byte = shift_tdi(jtag, data as u8, 1, exit_shift);
354355
captured_dr >>= 1;
355-
captured_dr |= (captured_byte as u32) << 31;
356+
captured_dr |= (captured_byte as u32) << (clock_cycles - 1);
356357

357358
captured_dr
358359
}

0 commit comments

Comments
 (0)