Skip to content

Commit

Permalink
jtagtap: Equalize _next & _cycle, replace line reset
Browse files Browse the repository at this point in the history
* SWD line reset needs 50 clocks with high TMS/SWDIO,
  this was achieved by looping over jtagtap_next() which incurs function call delays;
* Use jtagtap_cycle() instead which seems appropriate here, and discards TDO anyways;
* The adiv5_swd.c:swd_line_reset_sequence() counterpart seems less fitting to duplicate in jtagtap.
  • Loading branch information
ALTracer committed Nov 25, 2023
1 parent 6aac352 commit 8d73f51
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/platforms/common/jtagtap.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,12 @@ void jtagtap_init(void)
jtag_proc.tap_idle_cycles = 1;

/* Ensure we're in JTAG mode */
#if 1
jtagtap_cycle(true, false, 51U);
#else
for (size_t i = 0; i <= 50U; ++i)
jtagtap_next(true, false); /* 50 + 1 idle cycles for SWD reset */
#endif
jtagtap_tms_seq(0xe73cU, 16U); /* SWD to JTAG sequence */
}

Expand Down Expand Up @@ -100,8 +104,10 @@ static bool jtagtap_next_no_delay() __attribute__((optimize(3)));
static bool jtagtap_next_no_delay()
{
gpio_set(TCK_PORT, TCK_PIN);
__asm__("nop" ::: "memory");
const uint16_t result = gpio_get(TDO_PORT, TDO_PIN);
gpio_clear(TCK_PORT, TCK_PIN);
__asm__("nop" ::: "memory");
return result != 0;
}

Expand Down Expand Up @@ -327,6 +333,7 @@ static void jtagtap_cycle_no_delay(const size_t clock_cycles)
gpio_set(TCK_PORT, TCK_PIN);
__asm__ volatile("nop" ::: "memory");
gpio_clear(TCK_PORT, TCK_PIN);
__asm__ volatile("nop" ::: "memory");
}
}

Expand Down

0 comments on commit 8d73f51

Please sign in to comment.