build: cleanup src/jtag/drivers directory
[openocd.git] / src / jtag / drivers / OpenULINK / src / jtag.c
1 /***************************************************************************
2 * Copyright (C) 2011 by Martin Schmoelzer *
3 * <martin.schmoelzer@student.tuwien.ac.at> *
4 * *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) any later version. *
9 * *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
14 * *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the *
17 * Free Software Foundation, Inc., *
18 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19 ***************************************************************************/
20
21 #include "jtag.h"
22
23 #include "io.h"
24 #include "msgtypes.h"
25 #include "common.h"
26
27 #include <stdbool.h>
28
29 /** Delay value for SCAN_IN operations with less than maximum TCK frequency */
30 uint8_t delay_scan_in;
31
32 /** Delay value for SCAN_OUT operations with less than maximum TCK frequency */
33 uint8_t delay_scan_out;
34
35 /** Delay value for SCAN_IO operations with less than maximum TCK frequency */
36 uint8_t delay_scan_io;
37
38 /** Delay value for CLOCK_TCK operations with less than maximum frequency */
39 uint8_t delay_tck;
40
41 /** Delay value for CLOCK_TMS operations with less than maximum frequency */
42 uint8_t delay_tms;
43
44 /**
45 * Perform JTAG SCAN-IN operation at maximum TCK frequency.
46 *
47 * Dummy data is shifted into the JTAG chain via TDI, TDO data is sampled and
48 * stored in the EP2 IN buffer.
49 *
50 * Maximum achievable TCK frequency is 182 kHz for ULINK clocked at 24 MHz.
51 *
52 * @param out_offset offset in OUT2BUF where payload data starts
53 */
54 void jtag_scan_in(uint8_t out_offset, uint8_t in_offset)
55 {
56 uint8_t scan_size_bytes, bits_last_byte;
57 uint8_t tms_count_start, tms_count_end;
58 uint8_t tms_sequence_start, tms_sequence_end;
59 uint8_t tdo_data, i, j;
60
61 uint8_t outb_buffer;
62
63 /* Get parameters from OUT2BUF */
64 scan_size_bytes = OUT2BUF[out_offset];
65 bits_last_byte = OUT2BUF[out_offset + 1];
66 tms_count_start = (OUT2BUF[out_offset + 2] >> 4) & 0x0F;
67 tms_count_end = OUT2BUF[out_offset + 2] & 0x0F;
68 tms_sequence_start = OUT2BUF[out_offset + 3];
69 tms_sequence_end = OUT2BUF[out_offset + 4];
70
71 if (tms_count_start > 0)
72 jtag_clock_tms(tms_count_start, tms_sequence_start);
73
74 outb_buffer = OUTB & ~(PIN_TDI | PIN_TCK | PIN_TMS);
75
76 /* Shift all bytes except the last byte */
77 for (i = 0; i < scan_size_bytes - 1; i++) {
78 tdo_data = 0;
79
80 for (j = 0; j < 8; j++) {
81 OUTB = outb_buffer; /* TCK changes here */
82 tdo_data = tdo_data >> 1;
83 OUTB = (outb_buffer | PIN_TCK);
84
85 if (GET_TDO())
86 tdo_data |= 0x80;
87 }
88
89 /* Copy TDO data to IN2BUF */
90 IN2BUF[i + in_offset] = tdo_data;
91 }
92
93 tdo_data = 0;
94
95 /* Shift the last byte */
96 for (j = 0; j < bits_last_byte; j++) {
97 /* Assert TMS signal if requested and this is the last bit */
98 if ((j == bits_last_byte - 1) && (tms_count_end > 0)) {
99 outb_buffer |= PIN_TMS;
100 tms_count_end--;
101 tms_sequence_end = tms_sequence_end >> 1;
102 }
103
104 OUTB = outb_buffer; /* TCK change here */
105 tdo_data = tdo_data >> 1;
106 OUTB = (outb_buffer | PIN_TCK);
107
108 if (GET_TDO())
109 tdo_data |= 0x80;
110 }
111 tdo_data = tdo_data >> (8 - bits_last_byte);
112
113 /* Copy TDO data to IN2BUF */
114 IN2BUF[i + in_offset] = tdo_data;
115
116 /* Move to correct end state */
117 if (tms_count_end > 0)
118 jtag_clock_tms(tms_count_end, tms_sequence_end);
119 }
120
121 /**
122 * Perform JTAG SCAN-IN operation at variable TCK frequency.
123 *
124 * Dummy data is shifted into the JTAG chain via TDI, TDO data is sampled and
125 * stored in the EP2 IN buffer.
126 *
127 * Maximum achievable TCK frequency is 113 kHz for ULINK clocked at 24 MHz.
128 *
129 * @param out_offset offset in OUT2BUF where payload data starts
130 */
131 void jtag_slow_scan_in(uint8_t out_offset, uint8_t in_offset)
132 {
133 uint8_t scan_size_bytes, bits_last_byte;
134 uint8_t tms_count_start, tms_count_end;
135 uint8_t tms_sequence_start, tms_sequence_end;
136 uint8_t tdo_data, i, j, k;
137
138 uint8_t outb_buffer;
139
140 /* Get parameters from OUT2BUF */
141 scan_size_bytes = OUT2BUF[out_offset];
142 bits_last_byte = OUT2BUF[out_offset + 1];
143 tms_count_start = (OUT2BUF[out_offset + 2] >> 4) & 0x0F;
144 tms_count_end = OUT2BUF[out_offset + 2] & 0x0F;
145 tms_sequence_start = OUT2BUF[out_offset + 3];
146 tms_sequence_end = OUT2BUF[out_offset + 4];
147
148 if (tms_count_start > 0)
149 jtag_slow_clock_tms(tms_count_start, tms_sequence_start);
150
151 outb_buffer = OUTB & ~(PIN_TDI | PIN_TCK | PIN_TMS);
152
153 /* Shift all bytes except the last byte */
154 for (i = 0; i < scan_size_bytes - 1; i++) {
155 tdo_data = 0;
156
157 for (j = 0; j < 8; j++) {
158 OUTB = outb_buffer; /* TCK changes here */
159 for (k = 0; k < delay_scan_in; k++)
160 ;
161 tdo_data = tdo_data >> 1;
162
163 OUTB = (outb_buffer | PIN_TCK);
164 for (k = 0; k < delay_scan_in; k++)
165 ;
166
167 if (GET_TDO())
168 tdo_data |= 0x80;
169 }
170
171 /* Copy TDO data to IN2BUF */
172 IN2BUF[i + in_offset] = tdo_data;
173 }
174
175 tdo_data = 0;
176
177 /* Shift the last byte */
178 for (j = 0; j < bits_last_byte; j++) {
179 /* Assert TMS signal if requested and this is the last bit */
180 if ((j == bits_last_byte - 1) && (tms_count_end > 0)) {
181 outb_buffer |= PIN_TMS;
182 tms_count_end--;
183 tms_sequence_end = tms_sequence_end >> 1;
184 }
185
186 OUTB = outb_buffer; /* TCK change here */
187 for (k = 0; k < delay_scan_in; k++)
188 ;
189 tdo_data = tdo_data >> 1;
190
191 OUTB = (outb_buffer | PIN_TCK);
192 for (k = 0; k < delay_scan_in; k++)
193 ;
194
195 if (GET_TDO())
196 tdo_data |= 0x80;
197 }
198 tdo_data = tdo_data >> (8 - bits_last_byte);
199
200 /* Copy TDO data to IN2BUF */
201 IN2BUF[i + in_offset] = tdo_data;
202
203 /* Move to correct end state */
204 if (tms_count_end > 0)
205 jtag_slow_clock_tms(tms_count_end, tms_sequence_end);
206 }
207
208 /**
209 * Perform JTAG SCAN-OUT operation at maximum TCK frequency.
210 *
211 * Data stored in EP2 OUT buffer is shifted into the JTAG chain via TDI, TDO
212 * data is not sampled.
213 * The TAP-FSM state is alyways left in the PAUSE-DR/PAUSE-IR state.
214 *
215 * Maximum achievable TCK frequency is 142 kHz for ULINK clocked at 24 MHz.
216 *
217 * @param out_offset offset in OUT2BUF where payload data starts
218 */
219 void jtag_scan_out(uint8_t out_offset)
220 {
221 uint8_t scan_size_bytes, bits_last_byte;
222 uint8_t tms_count_start, tms_count_end;
223 uint8_t tms_sequence_start, tms_sequence_end;
224 uint8_t tdi_data, i, j;
225
226 uint8_t outb_buffer;
227
228 /* Get parameters from OUT2BUF */
229 scan_size_bytes = OUT2BUF[out_offset];
230 bits_last_byte = OUT2BUF[out_offset + 1];
231 tms_count_start = (OUT2BUF[out_offset + 2] >> 4) & 0x0F;
232 tms_count_end = OUT2BUF[out_offset + 2] & 0x0F;
233 tms_sequence_start = OUT2BUF[out_offset + 3];
234 tms_sequence_end = OUT2BUF[out_offset + 4];
235
236 if (tms_count_start > 0)
237 jtag_clock_tms(tms_count_start, tms_sequence_start);
238
239 outb_buffer = OUTB & ~(PIN_TCK | PIN_TMS);
240
241 /* Shift all bytes except the last byte */
242 for (i = 0; i < scan_size_bytes - 1; i++) {
243 tdi_data = OUT2BUF[i + out_offset + 5];
244
245 for (j = 0; j < 8; j++) {
246 if (tdi_data & 0x01)
247 outb_buffer |= PIN_TDI;
248 else
249 outb_buffer &= ~PIN_TDI;
250
251 OUTB = outb_buffer; /* TDI and TCK change here */
252 tdi_data = tdi_data >> 1;
253 OUTB = (outb_buffer | PIN_TCK);
254 }
255 }
256
257 tdi_data = OUT2BUF[i + out_offset + 5];
258
259 /* Shift the last byte */
260 for (j = 0; j < bits_last_byte; j++) {
261 if (tdi_data & 0x01)
262 outb_buffer |= PIN_TDI;
263 else
264 outb_buffer &= ~PIN_TDI;
265
266 /* Assert TMS signal if requested and this is the last bit */
267 if ((j == bits_last_byte - 1) && (tms_count_end > 0)) {
268 outb_buffer |= PIN_TMS;
269 tms_count_end--;
270 tms_sequence_end = tms_sequence_end >> 1;
271 }
272
273 OUTB = outb_buffer; /* TDI and TCK change here */
274 tdi_data = tdi_data >> 1;
275 OUTB = (outb_buffer | PIN_TCK);
276 }
277
278 /* Move to correct end state */
279 if (tms_count_end > 0)
280 jtag_clock_tms(tms_count_end, tms_sequence_end);
281 }
282
283 /**
284 * Perform JTAG SCAN-OUT operation at maximum TCK frequency.
285 *
286 * Data stored in EP2 OUT buffer is shifted into the JTAG chain via TDI, TDO
287 * data is not sampled.
288 * The TAP-FSM state is alyways left in the PAUSE-DR/PAUSE-IR state.
289 *
290 * Maximum achievable TCK frequency is 97 kHz for ULINK clocked at 24 MHz.
291 *
292 * @param out_offset offset in OUT2BUF where payload data starts
293 */
294 void jtag_slow_scan_out(uint8_t out_offset)
295 {
296 uint8_t scan_size_bytes, bits_last_byte;
297 uint8_t tms_count_start, tms_count_end;
298 uint8_t tms_sequence_start, tms_sequence_end;
299 uint8_t tdi_data, i, j, k;
300
301 uint8_t outb_buffer;
302
303 /* Get parameters from OUT2BUF */
304 scan_size_bytes = OUT2BUF[out_offset];
305 bits_last_byte = OUT2BUF[out_offset + 1];
306 tms_count_start = (OUT2BUF[out_offset + 2] >> 4) & 0x0F;
307 tms_count_end = OUT2BUF[out_offset + 2] & 0x0F;
308 tms_sequence_start = OUT2BUF[out_offset + 3];
309 tms_sequence_end = OUT2BUF[out_offset + 4];
310
311 if (tms_count_start > 0)
312 jtag_slow_clock_tms(tms_count_start, tms_sequence_start);
313
314 outb_buffer = OUTB & ~(PIN_TCK | PIN_TMS);
315
316 /* Shift all bytes except the last byte */
317 for (i = 0; i < scan_size_bytes - 1; i++) {
318 tdi_data = OUT2BUF[i + out_offset + 5];
319
320 for (j = 0; j < 8; j++) {
321 if (tdi_data & 0x01)
322 outb_buffer |= PIN_TDI;
323 else
324 outb_buffer &= ~PIN_TDI;
325
326 OUTB = outb_buffer; /* TDI and TCK change here */
327 for (k = 0; k < delay_scan_out; k++)
328 ;
329 tdi_data = tdi_data >> 1;
330
331 OUTB = (outb_buffer | PIN_TCK);
332 for (k = 0; k < delay_scan_out; k++)
333 ;
334 }
335 }
336
337 tdi_data = OUT2BUF[i + out_offset + 5];
338
339 /* Shift the last byte */
340 for (j = 0; j < bits_last_byte; j++) {
341 if (tdi_data & 0x01)
342 outb_buffer |= PIN_TDI;
343 else
344 outb_buffer &= ~PIN_TDI;
345
346 /* Assert TMS signal if requested and this is the last bit */
347 if ((j == bits_last_byte - 1) && (tms_count_end > 0)) {
348 outb_buffer |= PIN_TMS;
349 tms_count_end--;
350 tms_sequence_end = tms_sequence_end >> 1;
351 }
352
353 OUTB = outb_buffer; /* TDI and TCK change here */
354 for (k = 0; k < delay_scan_out; k++)
355 ;
356 tdi_data = tdi_data >> 1;
357
358 OUTB = (outb_buffer | PIN_TCK);
359 for (k = 0; k < delay_scan_out; k++)
360 ;
361 }
362
363 /* Move to correct end state */
364 if (tms_count_end > 0)
365 jtag_slow_clock_tms(tms_count_end, tms_sequence_end);
366 }
367
368 /**
369 * Perform bidirectional JTAG SCAN operation at maximum TCK frequency.
370 *
371 * Data stored in EP2 OUT buffer is shifted into the JTAG chain via TDI, TDO
372 * data is sampled and stored in the EP2 IN buffer.
373 * The TAP-FSM state is alyways left in the PAUSE-DR/PAUSE-IR state.
374 *
375 * Maximum achievable TCK frequency is 100 kHz for ULINK clocked at 24 MHz.
376 *
377 * @param out_offset offset in OUT2BUF where payload data starts
378 */
379 void jtag_scan_io(uint8_t out_offset, uint8_t in_offset)
380 {
381 uint8_t scan_size_bytes, bits_last_byte;
382 uint8_t tms_count_start, tms_count_end;
383 uint8_t tms_sequence_start, tms_sequence_end;
384 uint8_t tdi_data, tdo_data, i, j;
385
386 uint8_t outb_buffer;
387
388 /* Get parameters from OUT2BUF */
389 scan_size_bytes = OUT2BUF[out_offset];
390 bits_last_byte = OUT2BUF[out_offset + 1];
391 tms_count_start = (OUT2BUF[out_offset + 2] >> 4) & 0x0F;
392 tms_count_end = OUT2BUF[out_offset + 2] & 0x0F;
393 tms_sequence_start = OUT2BUF[out_offset + 3];
394 tms_sequence_end = OUT2BUF[out_offset + 4];
395
396 if (tms_count_start > 0)
397 jtag_clock_tms(tms_count_start, tms_sequence_start);
398
399 outb_buffer = OUTB & ~(PIN_TCK | PIN_TMS);
400
401 /* Shift all bytes except the last byte */
402 for (i = 0; i < scan_size_bytes - 1; i++) {
403 tdi_data = OUT2BUF[i + out_offset + 5];
404 tdo_data = 0;
405
406 for (j = 0; j < 8; j++) {
407 if (tdi_data & 0x01)
408 outb_buffer |= PIN_TDI;
409 else
410 outb_buffer &= ~PIN_TDI;
411
412 OUTB = outb_buffer; /* TDI and TCK change here */
413 tdi_data = tdi_data >> 1;
414 OUTB = (outb_buffer | PIN_TCK);
415 tdo_data = tdo_data >> 1;
416
417 if (GET_TDO())
418 tdo_data |= 0x80;
419 }
420
421 /* Copy TDO data to IN2BUF */
422 IN2BUF[i + in_offset] = tdo_data;
423 }
424
425 tdi_data = OUT2BUF[i + out_offset + 5];
426 tdo_data = 0;
427
428 /* Shift the last byte */
429 for (j = 0; j < bits_last_byte; j++) {
430 if (tdi_data & 0x01)
431 outb_buffer |= PIN_TDI;
432 else
433 outb_buffer &= ~PIN_TDI;
434
435 /* Assert TMS signal if requested and this is the last bit */
436 if ((j == bits_last_byte - 1) && (tms_count_end > 0)) {
437 outb_buffer |= PIN_TMS;
438 tms_count_end--;
439 tms_sequence_end = tms_sequence_end >> 1;
440 }
441
442 OUTB = outb_buffer; /* TDI and TCK change here */
443 tdi_data = tdi_data >> 1;
444 OUTB = (outb_buffer | PIN_TCK);
445 tdo_data = tdo_data >> 1;
446
447 if (GET_TDO())
448 tdo_data |= 0x80;
449 }
450 tdo_data = tdo_data >> (8 - bits_last_byte);
451
452 /* Copy TDO data to IN2BUF */
453 IN2BUF[i + in_offset] = tdo_data;
454
455 /* Move to correct end state */
456 if (tms_count_end > 0)
457 jtag_clock_tms(tms_count_end, tms_sequence_end);
458 }
459
460 /**
461 * Perform bidirectional JTAG SCAN operation at maximum TCK frequency.
462 *
463 * Data stored in EP2 OUT buffer is shifted into the JTAG chain via TDI, TDO
464 * data is sampled and stored in the EP2 IN buffer.
465 * The TAP-FSM state is alyways left in the PAUSE-DR/PAUSE-IR state.
466 *
467 * Maximum achievable TCK frequency is 78 kHz for ULINK clocked at 24 MHz.
468 *
469 * @param out_offset offset in OUT2BUF where payload data starts
470 */
471 void jtag_slow_scan_io(uint8_t out_offset, uint8_t in_offset)
472 {
473 uint8_t scan_size_bytes, bits_last_byte;
474 uint8_t tms_count_start, tms_count_end;
475 uint8_t tms_sequence_start, tms_sequence_end;
476 uint8_t tdi_data, tdo_data, i, j, k;
477
478 uint8_t outb_buffer;
479
480 /* Get parameters from OUT2BUF */
481 scan_size_bytes = OUT2BUF[out_offset];
482 bits_last_byte = OUT2BUF[out_offset + 1];
483 tms_count_start = (OUT2BUF[out_offset + 2] >> 4) & 0x0F;
484 tms_count_end = OUT2BUF[out_offset + 2] & 0x0F;
485 tms_sequence_start = OUT2BUF[out_offset + 3];
486 tms_sequence_end = OUT2BUF[out_offset + 4];
487
488 if (tms_count_start > 0)
489 jtag_slow_clock_tms(tms_count_start, tms_sequence_start);
490
491 outb_buffer = OUTB & ~(PIN_TCK | PIN_TMS);
492
493 /* Shift all bytes except the last byte */
494 for (i = 0; i < scan_size_bytes - 1; i++) {
495 tdi_data = OUT2BUF[i + out_offset + 5];
496 tdo_data = 0;
497
498 for (j = 0; j < 8; j++) {
499 if (tdi_data & 0x01)
500 outb_buffer |= PIN_TDI;
501 else
502 outb_buffer &= ~PIN_TDI;
503
504 OUTB = outb_buffer; /* TDI and TCK change here */
505 for (k = 0; k < delay_scan_io; k++)
506 ;
507 tdi_data = tdi_data >> 1;
508
509 OUTB = (outb_buffer | PIN_TCK);
510 for (k = 0; k < delay_scan_io; k++)
511 ;
512 tdo_data = tdo_data >> 1;
513
514 if (GET_TDO())
515 tdo_data |= 0x80;
516 }
517
518 /* Copy TDO data to IN2BUF */
519 IN2BUF[i + in_offset] = tdo_data;
520 }
521
522 tdi_data = OUT2BUF[i + out_offset + 5];
523 tdo_data = 0;
524
525 /* Shift the last byte */
526 for (j = 0; j < bits_last_byte; j++) {
527 if (tdi_data & 0x01)
528 outb_buffer |= PIN_TDI;
529 else
530 outb_buffer &= ~PIN_TDI;
531
532 /* Assert TMS signal if requested and this is the last bit */
533 if ((j == bits_last_byte - 1) && (tms_count_end > 0)) {
534 outb_buffer |= PIN_TMS;
535 tms_count_end--;
536 tms_sequence_end = tms_sequence_end >> 1;
537 }
538
539 OUTB = outb_buffer; /* TDI and TCK change here */
540 for (k = 0; k < delay_scan_io; k++)
541 ;
542 tdi_data = tdi_data >> 1;
543
544 OUTB = (outb_buffer | PIN_TCK);
545 for (k = 0; k < delay_scan_io; k++)
546 ;
547 tdo_data = tdo_data >> 1;
548
549 if (GET_TDO())
550 tdo_data |= 0x80;
551 }
552 tdo_data = tdo_data >> (8 - bits_last_byte);
553
554 /* Copy TDO data to IN2BUF */
555 IN2BUF[i + in_offset] = tdo_data;
556
557 /* Move to correct end state */
558 if (tms_count_end > 0)
559 jtag_slow_clock_tms(tms_count_end, tms_sequence_end);
560 }
561
562 /**
563 * Generate TCK clock cycles.
564 *
565 * Maximum achievable TCK frequency is 375 kHz for ULINK clocked at 24 MHz.
566 *
567 * @param count number of TCK clock cyclces to generate.
568 */
569 void jtag_clock_tck(uint16_t count)
570 {
571 uint16_t i;
572 uint8_t outb_buffer = OUTB & ~(PIN_TCK);
573
574 for (i = 0; i < count; i++) {
575 OUTB = outb_buffer;
576 OUTB = outb_buffer | PIN_TCK;
577 }
578 }
579
580 /**
581 * Generate TCK clock cycles at variable frequency.
582 *
583 * Maximum achieveable TCK frequency is 166.6 kHz for ULINK clocked at 24 MHz.
584 *
585 * @param count number of TCK clock cyclces to generate.
586 */
587 void jtag_slow_clock_tck(uint16_t count)
588 {
589 uint16_t i;
590 uint8_t j;
591 uint8_t outb_buffer = OUTB & ~(PIN_TCK);
592
593 for (i = 0; i < count; i++) {
594 OUTB = outb_buffer;
595 for (j = 0; j < delay_tck; j++)
596 ;
597 OUTB = outb_buffer | PIN_TCK;
598 for (j = 0; j < delay_tck; j++)
599 ;
600 }
601 }
602
603 /**
604 * Perform TAP FSM state transitions at maximum TCK frequency.
605 *
606 * Maximum achievable TCK frequency is 176 kHz for ULINK clocked at 24 MHz.
607 *
608 * @param count the number of state transitions to perform.
609 * @param sequence the TMS pin levels for each state transition, starting with
610 * the least-significant bit.
611 */
612 void jtag_clock_tms(uint8_t count, uint8_t sequence)
613 {
614 uint8_t outb_buffer = OUTB & ~(PIN_TCK);
615 uint8_t i;
616
617 for (i = 0; i < count; i++) {
618 /* Set TMS pin according to sequence parameter */
619 if (sequence & 0x1)
620 outb_buffer |= PIN_TMS;
621 else
622 outb_buffer &= ~PIN_TMS;
623
624 OUTB = outb_buffer;
625 sequence = sequence >> 1;
626 OUTB = outb_buffer | PIN_TCK;
627 }
628 }
629
630 /**
631 * Perform TAP-FSM state transitions at less than maximum TCK frequency.
632 *
633 * Maximum achievable TCK frequency is 117 kHz for ULINK clocked at 24 MHz.
634 *
635 * @param count the number of state transitions to perform.
636 * @param sequence the TMS pin levels for each state transition, starting with
637 * the least-significant bit.
638 */
639 void jtag_slow_clock_tms(uint8_t count, uint8_t sequence)
640 {
641 uint8_t outb_buffer = OUTB & ~(PIN_TCK);
642 uint8_t i, j;
643
644 for (i = 0; i < count; i++) {
645 /* Set TMS pin according to sequence parameter */
646 if (sequence & 0x1)
647 outb_buffer |= PIN_TMS;
648 else
649 outb_buffer &= ~PIN_TMS;
650
651 OUTB = outb_buffer;
652 for (j = 0; j < delay_tms; j++)
653 ;
654 sequence = sequence >> 1;
655 OUTB = outb_buffer | PIN_TCK;
656 for (j = 0; j < delay_tms; j++)
657 ;
658 }
659 }
660
661 /**
662 * Get current JTAG signal states.
663 *
664 * @return a 16-bit integer where the most-significant byte contains the state
665 * of the JTAG input signals and the least-significant byte cotains the state
666 * of the JTAG output signals.
667 */
668 uint16_t jtag_get_signals(void)
669 {
670 uint8_t input_signal_state, output_signal_state;
671
672 input_signal_state = 0;
673 output_signal_state = 0;
674
675 /* Get states of input pins */
676 if (GET_TDO())
677 input_signal_state |= SIGNAL_TDO;
678 if (GET_BRKOUT())
679 input_signal_state |= SIGNAL_BRKOUT;
680 if (GET_TRAP())
681 input_signal_state |= SIGNAL_TRAP;
682 if (GET_RTCK()) {
683 /* Using RTCK this way would be extremely slow,
684 * implemented only for the sake of completeness */
685 input_signal_state |= SIGNAL_RTCK;
686 }
687
688 /* Get states of output pins */
689 output_signal_state = PINSB & MASK_PORTB_DIRECTION_OUT;
690
691 return ((uint16_t)input_signal_state << 8) | ((uint16_t)output_signal_state);
692 }
693
694 /**
695 * Set state of JTAG output signals.
696 *
697 * @param low signals which should be de-asserted.
698 * @param high signals which should be asserted.
699 */
700 void jtag_set_signals(uint8_t low, uint8_t high)
701 {
702 OUTB &= ~(low & MASK_PORTB_DIRECTION_OUT);
703 OUTB |= (high & MASK_PORTB_DIRECTION_OUT);
704 }
705
706 /**
707 * Configure TCK delay parameters.
708 *
709 * @param scan_in number of delay cycles in scan_in operations.
710 * @param scan_out number of delay cycles in scan_out operations.
711 * @param scan_io number of delay cycles in scan_io operations.
712 * @param tck number of delay cycles in clock_tck operations.
713 * @param tms number of delay cycles in clock_tms operations.
714 */
715 void jtag_configure_tck_delay(uint8_t scan_in, uint8_t scan_out,
716 uint8_t scan_io, uint8_t tck, uint8_t tms)
717 {
718 delay_scan_in = scan_in;
719 delay_scan_out = scan_out;
720 delay_scan_io = scan_io;
721 delay_tck = tck;
722 delay_tms = tms;
723 }

Linking to existing account procedure

If you already have an account and want to add another login method you MUST first sign in with your existing account and then change URL to read https://review.openocd.org/login/?link to get to this page again but this time it'll work for linking. Thank you.

SSH host keys fingerprints

1024 SHA256:YKx8b7u5ZWdcbp7/4AeXNaqElP49m6QrwfXaqQGJAOk gerrit-code-review@openocd.zylin.com (DSA)
384 SHA256:jHIbSQa4REvwCFG4cq5LBlBLxmxSqelQPem/EXIrxjk gerrit-code-review@openocd.org (ECDSA)
521 SHA256:UAOPYkU9Fjtcao0Ul/Rrlnj/OsQvt+pgdYSZ4jOYdgs gerrit-code-review@openocd.org (ECDSA)
256 SHA256:A13M5QlnozFOvTllybRZH6vm7iSt0XLxbA48yfc2yfY gerrit-code-review@openocd.org (ECDSA)
256 SHA256:spYMBqEYoAOtK7yZBrcwE8ZpYt6b68Cfh9yEVetvbXg gerrit-code-review@openocd.org (ED25519)
+--[ED25519 256]--+
|=..              |
|+o..   .         |
|*.o   . .        |
|+B . . .         |
|Bo. = o S        |
|Oo.+ + =         |
|oB=.* = . o      |
| =+=.+   + E     |
|. .=o   . o      |
+----[SHA256]-----+
2048 SHA256:0Onrb7/PHjpo6iVZ7xQX2riKN83FJ3KGU0TvI0TaFG4 gerrit-code-review@openocd.zylin.com (RSA)