Skip to content

Commit 06d187c

Browse files
committed
Fix incompatibilty with original DirtyJTAG that breaks UrJTAG
1 parent 4a2b1c2 commit 06d187c

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

pio_jtag.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ void jtag_task();//to process USB OUT packets while waiting for DMA to finish
88

99
#define DMA
1010

11+
static bool last_tdo = false;
12+
1113
#if 0
1214
static bool pins_source = false; //false: PIO, true: GPIO
1315

@@ -130,6 +132,7 @@ void __time_critical_func(pio_jtag_write_blocking)(const pio_jtag_inst_t *jtag,
130132
}
131133
}
132134
}
135+
last_tdo = !!(x & 1);
133136
}
134137

135138
void __time_critical_func(pio_jtag_write_read_blocking)(const pio_jtag_inst_t *jtag, const uint8_t *bsrc, uint8_t *bdst,
@@ -178,8 +181,9 @@ void __time_critical_func(pio_jtag_write_read_blocking)(const pio_jtag_inst_t *j
178181
}
179182
}
180183
}
181-
//fix the last byte
182-
if (last_shift)
184+
last_tdo = !!(*rx_last_byte_p & 1);
185+
// fix the last byte
186+
if (last_shift)
183187
{
184188
*rx_last_byte_p = *rx_last_byte_p << last_shift;
185189
}
@@ -232,12 +236,8 @@ uint8_t __time_critical_func(pio_jtag_write_tms_blocking)(const pio_jtag_inst_t
232236
}
233237
}
234238
}
235-
//fix the last byte
236-
if (last_shift)
237-
{
238-
x = x << last_shift;
239-
}
240-
return x;
239+
last_tdo = !!(x & 1);
240+
return last_tdo ? 0xFF : 0x00;
241241
}
242242

243243
static void init_pins(uint pin_tck, uint pin_tdi, uint pin_tdo, uint pin_tms, uint pin_rst, uint pin_trst)
@@ -323,7 +323,7 @@ void jtag_set_clk(const pio_jtag_inst_t *jtag, bool value)
323323

324324
bool jtag_get_tdo(const pio_jtag_inst_t *jtag)
325325
{
326-
return !! toggle_bits_in_buffer[0];
326+
return last_tdo;
327327
}
328328

329329

0 commit comments

Comments
 (0)