adiv5_swdp.c: Use swdptap_seq_out for initialiation sequence.
This commit is contained in:
parent
e54a826745
commit
7e3fe352ad
|
@ -134,6 +134,7 @@ void swdptap_bit_out(bool val)
|
|||
swdptap_turnaround(0);
|
||||
|
||||
gpio_set_val(SWDIO_PORT, SWDIO_PIN, val);
|
||||
gpio_clear(SWCLK_PORT, SWCLK_PIN);
|
||||
gpio_set(SWCLK_PORT, SWCLK_PIN);
|
||||
gpio_set(SWCLK_PORT, SWCLK_PIN);
|
||||
gpio_clear(SWCLK_PORT, SWCLK_PIN);
|
||||
|
@ -149,9 +150,10 @@ swdptap_seq_out(uint32_t MS, int ticks)
|
|||
swdptap_turnaround(0);
|
||||
while (ticks--) {
|
||||
gpio_set_val(SWDIO_PORT, SWDIO_PIN, data);
|
||||
gpio_set(SWCLK_PORT, SWCLK_PIN);
|
||||
MS >>= 1;
|
||||
data = MS & 1;
|
||||
gpio_set(SWCLK_PORT, SWCLK_PIN);
|
||||
gpio_set(SWCLK_PORT, SWCLK_PIN);
|
||||
gpio_clear(SWCLK_PORT, SWCLK_PIN);
|
||||
}
|
||||
}
|
||||
|
@ -169,13 +171,14 @@ swdptap_seq_out_parity(uint32_t MS, int ticks)
|
|||
|
||||
while (ticks--) {
|
||||
gpio_set_val(SWDIO_PORT, SWDIO_PIN, data);
|
||||
gpio_set(SWCLK_PORT, SWCLK_PIN);
|
||||
parity ^= MS;
|
||||
MS >>= 1;
|
||||
gpio_set(SWCLK_PORT, SWCLK_PIN);
|
||||
data = MS & 1;
|
||||
gpio_clear(SWCLK_PORT, SWCLK_PIN);
|
||||
}
|
||||
gpio_set_val(SWDIO_PORT, SWDIO_PIN, parity & 1);
|
||||
gpio_clear(SWCLK_PORT, SWCLK_PIN);
|
||||
gpio_set(SWCLK_PORT, SWCLK_PIN);
|
||||
gpio_set(SWCLK_PORT, SWCLK_PIN);
|
||||
gpio_clear(SWCLK_PORT, SWCLK_PIN);
|
||||
|
|
|
@ -53,12 +53,12 @@ int adiv5_swdp_scan(void)
|
|||
return -1;
|
||||
|
||||
/* Switch from JTAG to SWD mode */
|
||||
swdptap_seq_out(0xFFFF, 16);
|
||||
for(int i = 0; i < 50; i++)
|
||||
swdptap_bit_out(1);
|
||||
swdptap_seq_out(0xFFFFFFFF, 16);
|
||||
swdptap_seq_out(0xFFFFFFFF, 32);
|
||||
swdptap_seq_out(0xFFFFFFFF, 18);
|
||||
swdptap_seq_out(0xE79E, 16); /* 0b0111100111100111 */
|
||||
for(int i = 0; i < 50; i++)
|
||||
swdptap_bit_out(1);
|
||||
swdptap_seq_out(0xFFFFFFFF, 32);
|
||||
swdptap_seq_out(0xFFFFFFFF, 18);
|
||||
swdptap_seq_out(0, 16);
|
||||
|
||||
/* Read the SW-DP IDCODE register to syncronise */
|
||||
|
|
Loading…
Reference in New Issue