update files to correct FSF address
[openocd.git] / src / jtag / drivers / OpenULINK / src / jtag.c
blob8940fc6f642eafe4165dc107afb3c1c442452d6f
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 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. *
19 ***************************************************************************/
21 #include "jtag.h"
23 #include "io.h"
24 #include "msgtypes.h"
25 #include "common.h"
27 #include <stdbool.h>
29 /** Delay value for SCAN_IN operations with less than maximum TCK frequency */
30 uint8_t delay_scan_in;
32 /** Delay value for SCAN_OUT operations with less than maximum TCK frequency */
33 uint8_t delay_scan_out;
35 /** Delay value for SCAN_IO operations with less than maximum TCK frequency */
36 uint8_t delay_scan_io;
38 /** Delay value for CLOCK_TCK operations with less than maximum frequency */
39 uint8_t delay_tck;
41 /** Delay value for CLOCK_TMS operations with less than maximum frequency */
42 uint8_t delay_tms;
44 /**
45 * Perform JTAG SCAN-IN operation at maximum TCK frequency.
47 * Dummy data is shifted into the JTAG chain via TDI, TDO data is sampled and
48 * stored in the EP2 IN buffer.
50 * Maximum achievable TCK frequency is 182 kHz for ULINK clocked at 24 MHz.
52 * @param out_offset offset in OUT2BUF where payload data starts
54 void jtag_scan_in(uint8_t out_offset, uint8_t in_offset)
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;
61 uint8_t outb_buffer;
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];
71 if (tms_count_start > 0)
72 jtag_clock_tms(tms_count_start, tms_sequence_start);
74 outb_buffer = OUTB & ~(PIN_TDI | PIN_TCK | PIN_TMS);
76 /* Shift all bytes except the last byte */
77 for (i = 0; i < scan_size_bytes - 1; i++) {
78 tdo_data = 0;
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);
85 if (GET_TDO())
86 tdo_data |= 0x80;
89 /* Copy TDO data to IN2BUF */
90 IN2BUF[i + in_offset] = tdo_data;
93 tdo_data = 0;
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;
104 OUTB = outb_buffer; /* TCK change here */
105 tdo_data = tdo_data >> 1;
106 OUTB = (outb_buffer | PIN_TCK);
108 if (GET_TDO())
109 tdo_data |= 0x80;
111 tdo_data = tdo_data >> (8 - bits_last_byte);
113 /* Copy TDO data to IN2BUF */
114 IN2BUF[i + in_offset] = tdo_data;
116 /* Move to correct end state */
117 if (tms_count_end > 0)
118 jtag_clock_tms(tms_count_end, tms_sequence_end);
122 * Perform JTAG SCAN-IN operation at variable TCK frequency.
124 * Dummy data is shifted into the JTAG chain via TDI, TDO data is sampled and
125 * stored in the EP2 IN buffer.
127 * Maximum achievable TCK frequency is 113 kHz for ULINK clocked at 24 MHz.
129 * @param out_offset offset in OUT2BUF where payload data starts
131 void jtag_slow_scan_in(uint8_t out_offset, uint8_t in_offset)
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;
138 uint8_t outb_buffer;
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];
148 if (tms_count_start > 0)
149 jtag_slow_clock_tms(tms_count_start, tms_sequence_start);
151 outb_buffer = OUTB & ~(PIN_TDI | PIN_TCK | PIN_TMS);
153 /* Shift all bytes except the last byte */
154 for (i = 0; i < scan_size_bytes - 1; i++) {
155 tdo_data = 0;
157 for (j = 0; j < 8; j++) {
158 OUTB = outb_buffer; /* TCK changes here */
159 for (k = 0; k < delay_scan_in; k++)
161 tdo_data = tdo_data >> 1;
163 OUTB = (outb_buffer | PIN_TCK);
164 for (k = 0; k < delay_scan_in; k++)
167 if (GET_TDO())
168 tdo_data |= 0x80;
171 /* Copy TDO data to IN2BUF */
172 IN2BUF[i + in_offset] = tdo_data;
175 tdo_data = 0;
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;
186 OUTB = outb_buffer; /* TCK change here */
187 for (k = 0; k < delay_scan_in; k++)
189 tdo_data = tdo_data >> 1;
191 OUTB = (outb_buffer | PIN_TCK);
192 for (k = 0; k < delay_scan_in; k++)
195 if (GET_TDO())
196 tdo_data |= 0x80;
198 tdo_data = tdo_data >> (8 - bits_last_byte);
200 /* Copy TDO data to IN2BUF */
201 IN2BUF[i + in_offset] = tdo_data;
203 /* Move to correct end state */
204 if (tms_count_end > 0)
205 jtag_slow_clock_tms(tms_count_end, tms_sequence_end);
209 * Perform JTAG SCAN-OUT operation at maximum TCK frequency.
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.
215 * Maximum achievable TCK frequency is 142 kHz for ULINK clocked at 24 MHz.
217 * @param out_offset offset in OUT2BUF where payload data starts
219 void jtag_scan_out(uint8_t out_offset)
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;
226 uint8_t outb_buffer;
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];
236 if (tms_count_start > 0)
237 jtag_clock_tms(tms_count_start, tms_sequence_start);
239 outb_buffer = OUTB & ~(PIN_TCK | PIN_TMS);
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];
245 for (j = 0; j < 8; j++) {
246 if (tdi_data & 0x01)
247 outb_buffer |= PIN_TDI;
248 else
249 outb_buffer &= ~PIN_TDI;
251 OUTB = outb_buffer; /* TDI and TCK change here */
252 tdi_data = tdi_data >> 1;
253 OUTB = (outb_buffer | PIN_TCK);
257 tdi_data = OUT2BUF[i + out_offset + 5];
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;
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;
273 OUTB = outb_buffer; /* TDI and TCK change here */
274 tdi_data = tdi_data >> 1;
275 OUTB = (outb_buffer | PIN_TCK);
278 /* Move to correct end state */
279 if (tms_count_end > 0)
280 jtag_clock_tms(tms_count_end, tms_sequence_end);
284 * Perform JTAG SCAN-OUT operation at maximum TCK frequency.
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.
290 * Maximum achievable TCK frequency is 97 kHz for ULINK clocked at 24 MHz.
292 * @param out_offset offset in OUT2BUF where payload data starts
294 void jtag_slow_scan_out(uint8_t out_offset)
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;
301 uint8_t outb_buffer;
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];
311 if (tms_count_start > 0)
312 jtag_slow_clock_tms(tms_count_start, tms_sequence_start);
314 outb_buffer = OUTB & ~(PIN_TCK | PIN_TMS);
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];
320 for (j = 0; j < 8; j++) {
321 if (tdi_data & 0x01)
322 outb_buffer |= PIN_TDI;
323 else
324 outb_buffer &= ~PIN_TDI;
326 OUTB = outb_buffer; /* TDI and TCK change here */
327 for (k = 0; k < delay_scan_out; k++)
329 tdi_data = tdi_data >> 1;
331 OUTB = (outb_buffer | PIN_TCK);
332 for (k = 0; k < delay_scan_out; k++)
337 tdi_data = OUT2BUF[i + out_offset + 5];
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;
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;
353 OUTB = outb_buffer; /* TDI and TCK change here */
354 for (k = 0; k < delay_scan_out; k++)
356 tdi_data = tdi_data >> 1;
358 OUTB = (outb_buffer | PIN_TCK);
359 for (k = 0; k < delay_scan_out; k++)
363 /* Move to correct end state */
364 if (tms_count_end > 0)
365 jtag_slow_clock_tms(tms_count_end, tms_sequence_end);
369 * Perform bidirectional JTAG SCAN operation at maximum TCK frequency.
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.
375 * Maximum achievable TCK frequency is 100 kHz for ULINK clocked at 24 MHz.
377 * @param out_offset offset in OUT2BUF where payload data starts
379 void jtag_scan_io(uint8_t out_offset, uint8_t in_offset)
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;
386 uint8_t outb_buffer;
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];
396 if (tms_count_start > 0)
397 jtag_clock_tms(tms_count_start, tms_sequence_start);
399 outb_buffer = OUTB & ~(PIN_TCK | PIN_TMS);
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;
406 for (j = 0; j < 8; j++) {
407 if (tdi_data & 0x01)
408 outb_buffer |= PIN_TDI;
409 else
410 outb_buffer &= ~PIN_TDI;
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;
417 if (GET_TDO())
418 tdo_data |= 0x80;
421 /* Copy TDO data to IN2BUF */
422 IN2BUF[i + in_offset] = tdo_data;
425 tdi_data = OUT2BUF[i + out_offset + 5];
426 tdo_data = 0;
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;
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;
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;
447 if (GET_TDO())
448 tdo_data |= 0x80;
450 tdo_data = tdo_data >> (8 - bits_last_byte);
452 /* Copy TDO data to IN2BUF */
453 IN2BUF[i + in_offset] = tdo_data;
455 /* Move to correct end state */
456 if (tms_count_end > 0)
457 jtag_clock_tms(tms_count_end, tms_sequence_end);
461 * Perform bidirectional JTAG SCAN operation at maximum TCK frequency.
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.
467 * Maximum achievable TCK frequency is 78 kHz for ULINK clocked at 24 MHz.
469 * @param out_offset offset in OUT2BUF where payload data starts
471 void jtag_slow_scan_io(uint8_t out_offset, uint8_t in_offset)
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;
478 uint8_t outb_buffer;
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];
488 if (tms_count_start > 0)
489 jtag_slow_clock_tms(tms_count_start, tms_sequence_start);
491 outb_buffer = OUTB & ~(PIN_TCK | PIN_TMS);
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;
498 for (j = 0; j < 8; j++) {
499 if (tdi_data & 0x01)
500 outb_buffer |= PIN_TDI;
501 else
502 outb_buffer &= ~PIN_TDI;
504 OUTB = outb_buffer; /* TDI and TCK change here */
505 for (k = 0; k < delay_scan_io; k++)
507 tdi_data = tdi_data >> 1;
509 OUTB = (outb_buffer | PIN_TCK);
510 for (k = 0; k < delay_scan_io; k++)
512 tdo_data = tdo_data >> 1;
514 if (GET_TDO())
515 tdo_data |= 0x80;
518 /* Copy TDO data to IN2BUF */
519 IN2BUF[i + in_offset] = tdo_data;
522 tdi_data = OUT2BUF[i + out_offset + 5];
523 tdo_data = 0;
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;
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;
539 OUTB = outb_buffer; /* TDI and TCK change here */
540 for (k = 0; k < delay_scan_io; k++)
542 tdi_data = tdi_data >> 1;
544 OUTB = (outb_buffer | PIN_TCK);
545 for (k = 0; k < delay_scan_io; k++)
547 tdo_data = tdo_data >> 1;
549 if (GET_TDO())
550 tdo_data |= 0x80;
552 tdo_data = tdo_data >> (8 - bits_last_byte);
554 /* Copy TDO data to IN2BUF */
555 IN2BUF[i + in_offset] = tdo_data;
557 /* Move to correct end state */
558 if (tms_count_end > 0)
559 jtag_slow_clock_tms(tms_count_end, tms_sequence_end);
563 * Generate TCK clock cycles.
565 * Maximum achievable TCK frequency is 375 kHz for ULINK clocked at 24 MHz.
567 * @param count number of TCK clock cyclces to generate.
569 void jtag_clock_tck(uint16_t count)
571 uint16_t i;
572 uint8_t outb_buffer = OUTB & ~(PIN_TCK);
574 for (i = 0; i < count; i++) {
575 OUTB = outb_buffer;
576 OUTB = outb_buffer | PIN_TCK;
581 * Generate TCK clock cycles at variable frequency.
583 * Maximum achieveable TCK frequency is 166.6 kHz for ULINK clocked at 24 MHz.
585 * @param count number of TCK clock cyclces to generate.
587 void jtag_slow_clock_tck(uint16_t count)
589 uint16_t i;
590 uint8_t j;
591 uint8_t outb_buffer = OUTB & ~(PIN_TCK);
593 for (i = 0; i < count; i++) {
594 OUTB = outb_buffer;
595 for (j = 0; j < delay_tck; j++)
597 OUTB = outb_buffer | PIN_TCK;
598 for (j = 0; j < delay_tck; j++)
604 * Perform TAP FSM state transitions at maximum TCK frequency.
606 * Maximum achievable TCK frequency is 176 kHz for ULINK clocked at 24 MHz.
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.
612 void jtag_clock_tms(uint8_t count, uint8_t sequence)
614 uint8_t outb_buffer = OUTB & ~(PIN_TCK);
615 uint8_t i;
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;
624 OUTB = outb_buffer;
625 sequence = sequence >> 1;
626 OUTB = outb_buffer | PIN_TCK;
631 * Perform TAP-FSM state transitions at less than maximum TCK frequency.
633 * Maximum achievable TCK frequency is 117 kHz for ULINK clocked at 24 MHz.
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.
639 void jtag_slow_clock_tms(uint8_t count, uint8_t sequence)
641 uint8_t outb_buffer = OUTB & ~(PIN_TCK);
642 uint8_t i, j;
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;
651 OUTB = outb_buffer;
652 for (j = 0; j < delay_tms; j++)
654 sequence = sequence >> 1;
655 OUTB = outb_buffer | PIN_TCK;
656 for (j = 0; j < delay_tms; j++)
662 * Get current JTAG signal states.
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.
668 uint16_t jtag_get_signals(void)
670 uint8_t input_signal_state, output_signal_state;
672 input_signal_state = 0;
673 output_signal_state = 0;
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;
688 /* Get states of output pins */
689 output_signal_state = PINSB & MASK_PORTB_DIRECTION_OUT;
691 return ((uint16_t)input_signal_state << 8) | ((uint16_t)output_signal_state);
695 * Set state of JTAG output signals.
697 * @param low signals which should be de-asserted.
698 * @param high signals which should be asserted.
700 void jtag_set_signals(uint8_t low, uint8_t high)
702 OUTB &= ~(low & MASK_PORTB_DIRECTION_OUT);
703 OUTB |= (high & MASK_PORTB_DIRECTION_OUT);
707 * Configure TCK delay parameters.
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.
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)
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;