Mercurial > avr_jtag
annotate src/jtag.c @ 6:42dec3428c77
Define TMS transition patterns
author | Thinker K.F. Li <thinker@branda.to> |
---|---|
date | Sun, 22 Feb 2009 14:12:29 +0800 |
parents | eb14cac68cbb |
children | 61f27549de57 |
rev | line source |
---|---|
2 | 1 #include <stdio.h> |
2 #include <util/delay.h> | |
3 #include "jtag.h" | |
4 #include "avriotools.h" | |
5 | |
6 /* It is supposed to work at 1Mbps */ | |
4
6b1594fb668f
Improve performance of jtag.c and test it with Python scripts.
Thinker K.F. Li <thinker@branda.to>
parents:
2
diff
changeset
|
7 #define CLK_DELAY() |
2 | 8 |
9 void jtag_init(void) { | |
10 pin_mode(&JTAG_PORT, JTAG_TCK, PM_OUTPUT); | |
11 pin_mode(&JTAG_PORT, JTAG_TMS, PM_OUTPUT); | |
12 pin_mode(&JTAG_PORT, JTAG_TDI, PM_OUTPUT); | |
13 pin_mode(&JTAG_PORT, JTAG_TDO, PM_INPUT); | |
14 pin_lo(JTAG_PORT, JTAG_TCK); | |
15 pin_lo(JTAG_PORT, JTAG_TMS); | |
16 pin_lo(JTAG_PORT, JTAG_TDI); | |
17 } | |
18 | |
19 #define TCK_LO() pin_lo(JTAG_PORT, JTAG_TCK) | |
20 #define TCK_HI() pin_hi(JTAG_PORT, JTAG_TCK) | |
21 #define SEND_BIT(pin, bit) \ | |
22 do { \ | |
23 if(bit) \ | |
4
6b1594fb668f
Improve performance of jtag.c and test it with Python scripts.
Thinker K.F. Li <thinker@branda.to>
parents:
2
diff
changeset
|
24 pin_hi(JTAG_PORT, pin); \ |
2 | 25 else \ |
4
6b1594fb668f
Improve performance of jtag.c and test it with Python scripts.
Thinker K.F. Li <thinker@branda.to>
parents:
2
diff
changeset
|
26 pin_lo(JTAG_PORT, pin); \ |
2 | 27 CLK_DELAY(); \ |
28 TCK_HI(); \ | |
29 CLK_DELAY(); \ | |
30 } while(0) | |
31 #define GET_TDO() (JTAG_PIN & _BV(JTAG_TDO)) | |
32 | |
5
eb14cac68cbb
Transite TAP controller to shift state.
Thinker K.F. Li <thinker@branda.to>
parents:
4
diff
changeset
|
33 /*! |
eb14cac68cbb
Transite TAP controller to shift state.
Thinker K.F. Li <thinker@branda.to>
parents:
4
diff
changeset
|
34 * Before shifting registers, TAP controller must move to last state before |
eb14cac68cbb
Transite TAP controller to shift state.
Thinker K.F. Li <thinker@branda.to>
parents:
4
diff
changeset
|
35 * shift state. The state machine transite to shift state when shifting |
eb14cac68cbb
Transite TAP controller to shift state.
Thinker K.F. Li <thinker@branda.to>
parents:
4
diff
changeset
|
36 * starts. |
eb14cac68cbb
Transite TAP controller to shift state.
Thinker K.F. Li <thinker@branda.to>
parents:
4
diff
changeset
|
37 */ |
2 | 38 void jtag_tms(char *buf, int nbits) { |
39 int i; | |
4
6b1594fb668f
Improve performance of jtag.c and test it with Python scripts.
Thinker K.F. Li <thinker@branda.to>
parents:
2
diff
changeset
|
40 int nbytes, byte; |
2 | 41 int byteoff, bitoff; |
42 int bit; | |
43 | |
4
6b1594fb668f
Improve performance of jtag.c and test it with Python scripts.
Thinker K.F. Li <thinker@branda.to>
parents:
2
diff
changeset
|
44 nbytes = nbits / 8; |
6b1594fb668f
Improve performance of jtag.c and test it with Python scripts.
Thinker K.F. Li <thinker@branda.to>
parents:
2
diff
changeset
|
45 for(i = 0; i < nbytes; i++) { |
6b1594fb668f
Improve performance of jtag.c and test it with Python scripts.
Thinker K.F. Li <thinker@branda.to>
parents:
2
diff
changeset
|
46 byte = buf[i]; |
6b1594fb668f
Improve performance of jtag.c and test it with Python scripts.
Thinker K.F. Li <thinker@branda.to>
parents:
2
diff
changeset
|
47 |
6b1594fb668f
Improve performance of jtag.c and test it with Python scripts.
Thinker K.F. Li <thinker@branda.to>
parents:
2
diff
changeset
|
48 bit = byte & 0x01; |
6b1594fb668f
Improve performance of jtag.c and test it with Python scripts.
Thinker K.F. Li <thinker@branda.to>
parents:
2
diff
changeset
|
49 SEND_BIT(JTAG_TMS, bit); |
6b1594fb668f
Improve performance of jtag.c and test it with Python scripts.
Thinker K.F. Li <thinker@branda.to>
parents:
2
diff
changeset
|
50 TCK_LO(); |
6b1594fb668f
Improve performance of jtag.c and test it with Python scripts.
Thinker K.F. Li <thinker@branda.to>
parents:
2
diff
changeset
|
51 |
6b1594fb668f
Improve performance of jtag.c and test it with Python scripts.
Thinker K.F. Li <thinker@branda.to>
parents:
2
diff
changeset
|
52 bit = byte & 0x02; |
6b1594fb668f
Improve performance of jtag.c and test it with Python scripts.
Thinker K.F. Li <thinker@branda.to>
parents:
2
diff
changeset
|
53 SEND_BIT(JTAG_TMS, bit); |
6b1594fb668f
Improve performance of jtag.c and test it with Python scripts.
Thinker K.F. Li <thinker@branda.to>
parents:
2
diff
changeset
|
54 TCK_LO(); |
6b1594fb668f
Improve performance of jtag.c and test it with Python scripts.
Thinker K.F. Li <thinker@branda.to>
parents:
2
diff
changeset
|
55 |
6b1594fb668f
Improve performance of jtag.c and test it with Python scripts.
Thinker K.F. Li <thinker@branda.to>
parents:
2
diff
changeset
|
56 bit = byte & 0x04; |
6b1594fb668f
Improve performance of jtag.c and test it with Python scripts.
Thinker K.F. Li <thinker@branda.to>
parents:
2
diff
changeset
|
57 SEND_BIT(JTAG_TMS, bit); |
6b1594fb668f
Improve performance of jtag.c and test it with Python scripts.
Thinker K.F. Li <thinker@branda.to>
parents:
2
diff
changeset
|
58 TCK_LO(); |
6b1594fb668f
Improve performance of jtag.c and test it with Python scripts.
Thinker K.F. Li <thinker@branda.to>
parents:
2
diff
changeset
|
59 |
6b1594fb668f
Improve performance of jtag.c and test it with Python scripts.
Thinker K.F. Li <thinker@branda.to>
parents:
2
diff
changeset
|
60 bit = byte & 0x08; |
6b1594fb668f
Improve performance of jtag.c and test it with Python scripts.
Thinker K.F. Li <thinker@branda.to>
parents:
2
diff
changeset
|
61 SEND_BIT(JTAG_TMS, bit); |
6b1594fb668f
Improve performance of jtag.c and test it with Python scripts.
Thinker K.F. Li <thinker@branda.to>
parents:
2
diff
changeset
|
62 TCK_LO(); |
6b1594fb668f
Improve performance of jtag.c and test it with Python scripts.
Thinker K.F. Li <thinker@branda.to>
parents:
2
diff
changeset
|
63 |
6b1594fb668f
Improve performance of jtag.c and test it with Python scripts.
Thinker K.F. Li <thinker@branda.to>
parents:
2
diff
changeset
|
64 bit = byte & 0x10; |
6b1594fb668f
Improve performance of jtag.c and test it with Python scripts.
Thinker K.F. Li <thinker@branda.to>
parents:
2
diff
changeset
|
65 SEND_BIT(JTAG_TMS, bit); |
6b1594fb668f
Improve performance of jtag.c and test it with Python scripts.
Thinker K.F. Li <thinker@branda.to>
parents:
2
diff
changeset
|
66 TCK_LO(); |
6b1594fb668f
Improve performance of jtag.c and test it with Python scripts.
Thinker K.F. Li <thinker@branda.to>
parents:
2
diff
changeset
|
67 |
6b1594fb668f
Improve performance of jtag.c and test it with Python scripts.
Thinker K.F. Li <thinker@branda.to>
parents:
2
diff
changeset
|
68 bit = byte & 0x20; |
6b1594fb668f
Improve performance of jtag.c and test it with Python scripts.
Thinker K.F. Li <thinker@branda.to>
parents:
2
diff
changeset
|
69 SEND_BIT(JTAG_TMS, bit); |
6b1594fb668f
Improve performance of jtag.c and test it with Python scripts.
Thinker K.F. Li <thinker@branda.to>
parents:
2
diff
changeset
|
70 TCK_LO(); |
6b1594fb668f
Improve performance of jtag.c and test it with Python scripts.
Thinker K.F. Li <thinker@branda.to>
parents:
2
diff
changeset
|
71 |
6b1594fb668f
Improve performance of jtag.c and test it with Python scripts.
Thinker K.F. Li <thinker@branda.to>
parents:
2
diff
changeset
|
72 bit = byte & 0x40; |
6b1594fb668f
Improve performance of jtag.c and test it with Python scripts.
Thinker K.F. Li <thinker@branda.to>
parents:
2
diff
changeset
|
73 SEND_BIT(JTAG_TMS, bit); |
6b1594fb668f
Improve performance of jtag.c and test it with Python scripts.
Thinker K.F. Li <thinker@branda.to>
parents:
2
diff
changeset
|
74 TCK_LO(); |
6b1594fb668f
Improve performance of jtag.c and test it with Python scripts.
Thinker K.F. Li <thinker@branda.to>
parents:
2
diff
changeset
|
75 |
6b1594fb668f
Improve performance of jtag.c and test it with Python scripts.
Thinker K.F. Li <thinker@branda.to>
parents:
2
diff
changeset
|
76 bit = byte & 0x80; |
6b1594fb668f
Improve performance of jtag.c and test it with Python scripts.
Thinker K.F. Li <thinker@branda.to>
parents:
2
diff
changeset
|
77 SEND_BIT(JTAG_TMS, bit); |
6b1594fb668f
Improve performance of jtag.c and test it with Python scripts.
Thinker K.F. Li <thinker@branda.to>
parents:
2
diff
changeset
|
78 TCK_LO(); |
6b1594fb668f
Improve performance of jtag.c and test it with Python scripts.
Thinker K.F. Li <thinker@branda.to>
parents:
2
diff
changeset
|
79 } |
6b1594fb668f
Improve performance of jtag.c and test it with Python scripts.
Thinker K.F. Li <thinker@branda.to>
parents:
2
diff
changeset
|
80 |
6b1594fb668f
Improve performance of jtag.c and test it with Python scripts.
Thinker K.F. Li <thinker@branda.to>
parents:
2
diff
changeset
|
81 byte = buf[i]; |
6b1594fb668f
Improve performance of jtag.c and test it with Python scripts.
Thinker K.F. Li <thinker@branda.to>
parents:
2
diff
changeset
|
82 nbits %= 8; |
2 | 83 for(i = 0; i < nbits; i++) { |
4
6b1594fb668f
Improve performance of jtag.c and test it with Python scripts.
Thinker K.F. Li <thinker@branda.to>
parents:
2
diff
changeset
|
84 bit = byte & (1 << i); |
2 | 85 SEND_BIT(JTAG_TMS, bit); |
86 TCK_LO(); | |
87 } | |
88 } | |
89 | |
90 void jtag_shift(char *buf, int nbits) { | |
91 int i; | |
4
6b1594fb668f
Improve performance of jtag.c and test it with Python scripts.
Thinker K.F. Li <thinker@branda.to>
parents:
2
diff
changeset
|
92 int nbytes, byte; |
2 | 93 int byteoff, bitoff; |
94 int bit; | |
95 | |
5
eb14cac68cbb
Transite TAP controller to shift state.
Thinker K.F. Li <thinker@branda.to>
parents:
4
diff
changeset
|
96 /* Transite to shift state. |
eb14cac68cbb
Transite TAP controller to shift state.
Thinker K.F. Li <thinker@branda.to>
parents:
4
diff
changeset
|
97 * \sa jtag_tms() |
eb14cac68cbb
Transite TAP controller to shift state.
Thinker K.F. Li <thinker@branda.to>
parents:
4
diff
changeset
|
98 */ |
eb14cac68cbb
Transite TAP controller to shift state.
Thinker K.F. Li <thinker@branda.to>
parents:
4
diff
changeset
|
99 pin_lo(JTAG_PORT, JTAG_TMS); |
eb14cac68cbb
Transite TAP controller to shift state.
Thinker K.F. Li <thinker@branda.to>
parents:
4
diff
changeset
|
100 |
4
6b1594fb668f
Improve performance of jtag.c and test it with Python scripts.
Thinker K.F. Li <thinker@branda.to>
parents:
2
diff
changeset
|
101 nbytes = nbits / 8; |
6b1594fb668f
Improve performance of jtag.c and test it with Python scripts.
Thinker K.F. Li <thinker@branda.to>
parents:
2
diff
changeset
|
102 for(i = 0; i < nbytes; i++) { |
6b1594fb668f
Improve performance of jtag.c and test it with Python scripts.
Thinker K.F. Li <thinker@branda.to>
parents:
2
diff
changeset
|
103 byte = buf[i]; |
6b1594fb668f
Improve performance of jtag.c and test it with Python scripts.
Thinker K.F. Li <thinker@branda.to>
parents:
2
diff
changeset
|
104 |
6b1594fb668f
Improve performance of jtag.c and test it with Python scripts.
Thinker K.F. Li <thinker@branda.to>
parents:
2
diff
changeset
|
105 bit = byte & 0x01; |
6b1594fb668f
Improve performance of jtag.c and test it with Python scripts.
Thinker K.F. Li <thinker@branda.to>
parents:
2
diff
changeset
|
106 SEND_BIT(JTAG_TDI, bit); |
6b1594fb668f
Improve performance of jtag.c and test it with Python scripts.
Thinker K.F. Li <thinker@branda.to>
parents:
2
diff
changeset
|
107 TCK_LO(); |
6b1594fb668f
Improve performance of jtag.c and test it with Python scripts.
Thinker K.F. Li <thinker@branda.to>
parents:
2
diff
changeset
|
108 |
6b1594fb668f
Improve performance of jtag.c and test it with Python scripts.
Thinker K.F. Li <thinker@branda.to>
parents:
2
diff
changeset
|
109 bit = byte & 0x02; |
6b1594fb668f
Improve performance of jtag.c and test it with Python scripts.
Thinker K.F. Li <thinker@branda.to>
parents:
2
diff
changeset
|
110 SEND_BIT(JTAG_TDI, bit); |
6b1594fb668f
Improve performance of jtag.c and test it with Python scripts.
Thinker K.F. Li <thinker@branda.to>
parents:
2
diff
changeset
|
111 TCK_LO(); |
6b1594fb668f
Improve performance of jtag.c and test it with Python scripts.
Thinker K.F. Li <thinker@branda.to>
parents:
2
diff
changeset
|
112 |
6b1594fb668f
Improve performance of jtag.c and test it with Python scripts.
Thinker K.F. Li <thinker@branda.to>
parents:
2
diff
changeset
|
113 bit = byte & 0x04; |
6b1594fb668f
Improve performance of jtag.c and test it with Python scripts.
Thinker K.F. Li <thinker@branda.to>
parents:
2
diff
changeset
|
114 SEND_BIT(JTAG_TDI, bit); |
6b1594fb668f
Improve performance of jtag.c and test it with Python scripts.
Thinker K.F. Li <thinker@branda.to>
parents:
2
diff
changeset
|
115 TCK_LO(); |
6b1594fb668f
Improve performance of jtag.c and test it with Python scripts.
Thinker K.F. Li <thinker@branda.to>
parents:
2
diff
changeset
|
116 |
6b1594fb668f
Improve performance of jtag.c and test it with Python scripts.
Thinker K.F. Li <thinker@branda.to>
parents:
2
diff
changeset
|
117 bit = byte & 0x08; |
6b1594fb668f
Improve performance of jtag.c and test it with Python scripts.
Thinker K.F. Li <thinker@branda.to>
parents:
2
diff
changeset
|
118 SEND_BIT(JTAG_TDI, bit); |
6b1594fb668f
Improve performance of jtag.c and test it with Python scripts.
Thinker K.F. Li <thinker@branda.to>
parents:
2
diff
changeset
|
119 TCK_LO(); |
6b1594fb668f
Improve performance of jtag.c and test it with Python scripts.
Thinker K.F. Li <thinker@branda.to>
parents:
2
diff
changeset
|
120 |
6b1594fb668f
Improve performance of jtag.c and test it with Python scripts.
Thinker K.F. Li <thinker@branda.to>
parents:
2
diff
changeset
|
121 bit = byte & 0x10; |
2 | 122 SEND_BIT(JTAG_TDI, bit); |
123 TCK_LO(); | |
4
6b1594fb668f
Improve performance of jtag.c and test it with Python scripts.
Thinker K.F. Li <thinker@branda.to>
parents:
2
diff
changeset
|
124 |
6b1594fb668f
Improve performance of jtag.c and test it with Python scripts.
Thinker K.F. Li <thinker@branda.to>
parents:
2
diff
changeset
|
125 bit = byte & 0x20; |
6b1594fb668f
Improve performance of jtag.c and test it with Python scripts.
Thinker K.F. Li <thinker@branda.to>
parents:
2
diff
changeset
|
126 SEND_BIT(JTAG_TDI, bit); |
6b1594fb668f
Improve performance of jtag.c and test it with Python scripts.
Thinker K.F. Li <thinker@branda.to>
parents:
2
diff
changeset
|
127 TCK_LO(); |
6b1594fb668f
Improve performance of jtag.c and test it with Python scripts.
Thinker K.F. Li <thinker@branda.to>
parents:
2
diff
changeset
|
128 |
6b1594fb668f
Improve performance of jtag.c and test it with Python scripts.
Thinker K.F. Li <thinker@branda.to>
parents:
2
diff
changeset
|
129 bit = byte & 0x40; |
6b1594fb668f
Improve performance of jtag.c and test it with Python scripts.
Thinker K.F. Li <thinker@branda.to>
parents:
2
diff
changeset
|
130 SEND_BIT(JTAG_TDI, bit); |
6b1594fb668f
Improve performance of jtag.c and test it with Python scripts.
Thinker K.F. Li <thinker@branda.to>
parents:
2
diff
changeset
|
131 TCK_LO(); |
6b1594fb668f
Improve performance of jtag.c and test it with Python scripts.
Thinker K.F. Li <thinker@branda.to>
parents:
2
diff
changeset
|
132 |
6b1594fb668f
Improve performance of jtag.c and test it with Python scripts.
Thinker K.F. Li <thinker@branda.to>
parents:
2
diff
changeset
|
133 bit = byte & 0x80; |
6b1594fb668f
Improve performance of jtag.c and test it with Python scripts.
Thinker K.F. Li <thinker@branda.to>
parents:
2
diff
changeset
|
134 SEND_BIT(JTAG_TDI, bit); |
6b1594fb668f
Improve performance of jtag.c and test it with Python scripts.
Thinker K.F. Li <thinker@branda.to>
parents:
2
diff
changeset
|
135 TCK_LO(); |
6b1594fb668f
Improve performance of jtag.c and test it with Python scripts.
Thinker K.F. Li <thinker@branda.to>
parents:
2
diff
changeset
|
136 } |
6b1594fb668f
Improve performance of jtag.c and test it with Python scripts.
Thinker K.F. Li <thinker@branda.to>
parents:
2
diff
changeset
|
137 |
6b1594fb668f
Improve performance of jtag.c and test it with Python scripts.
Thinker K.F. Li <thinker@branda.to>
parents:
2
diff
changeset
|
138 nbits %= 8; |
6b1594fb668f
Improve performance of jtag.c and test it with Python scripts.
Thinker K.F. Li <thinker@branda.to>
parents:
2
diff
changeset
|
139 if(nbits) { |
6b1594fb668f
Improve performance of jtag.c and test it with Python scripts.
Thinker K.F. Li <thinker@branda.to>
parents:
2
diff
changeset
|
140 byte = buf[i]; |
6b1594fb668f
Improve performance of jtag.c and test it with Python scripts.
Thinker K.F. Li <thinker@branda.to>
parents:
2
diff
changeset
|
141 for(i = 0; i < nbits; i++) { |
6b1594fb668f
Improve performance of jtag.c and test it with Python scripts.
Thinker K.F. Li <thinker@branda.to>
parents:
2
diff
changeset
|
142 bit = byte & (1 << i); |
6b1594fb668f
Improve performance of jtag.c and test it with Python scripts.
Thinker K.F. Li <thinker@branda.to>
parents:
2
diff
changeset
|
143 SEND_BIT(JTAG_TDI, bit); |
6b1594fb668f
Improve performance of jtag.c and test it with Python scripts.
Thinker K.F. Li <thinker@branda.to>
parents:
2
diff
changeset
|
144 TCK_LO(); |
6b1594fb668f
Improve performance of jtag.c and test it with Python scripts.
Thinker K.F. Li <thinker@branda.to>
parents:
2
diff
changeset
|
145 } |
2 | 146 } |
147 } | |
148 | |
149 void jtag_shift_inout(char *ibuf, char *obuf, int nbits) { | |
4
6b1594fb668f
Improve performance of jtag.c and test it with Python scripts.
Thinker K.F. Li <thinker@branda.to>
parents:
2
diff
changeset
|
150 int i, j; |
6b1594fb668f
Improve performance of jtag.c and test it with Python scripts.
Thinker K.F. Li <thinker@branda.to>
parents:
2
diff
changeset
|
151 int nbytes, byte, obyte; |
6b1594fb668f
Improve performance of jtag.c and test it with Python scripts.
Thinker K.F. Li <thinker@branda.to>
parents:
2
diff
changeset
|
152 int tdo; |
2 | 153 int byteoff, bitoff; |
4
6b1594fb668f
Improve performance of jtag.c and test it with Python scripts.
Thinker K.F. Li <thinker@branda.to>
parents:
2
diff
changeset
|
154 int bit; |
2 | 155 |
5
eb14cac68cbb
Transite TAP controller to shift state.
Thinker K.F. Li <thinker@branda.to>
parents:
4
diff
changeset
|
156 /* Transite to shift state. |
eb14cac68cbb
Transite TAP controller to shift state.
Thinker K.F. Li <thinker@branda.to>
parents:
4
diff
changeset
|
157 * \sa jtag_tms() |
eb14cac68cbb
Transite TAP controller to shift state.
Thinker K.F. Li <thinker@branda.to>
parents:
4
diff
changeset
|
158 */ |
eb14cac68cbb
Transite TAP controller to shift state.
Thinker K.F. Li <thinker@branda.to>
parents:
4
diff
changeset
|
159 pin_lo(JTAG_PORT, JTAG_TMS); |
eb14cac68cbb
Transite TAP controller to shift state.
Thinker K.F. Li <thinker@branda.to>
parents:
4
diff
changeset
|
160 |
4
6b1594fb668f
Improve performance of jtag.c and test it with Python scripts.
Thinker K.F. Li <thinker@branda.to>
parents:
2
diff
changeset
|
161 nbytes = nbits / 8; |
6b1594fb668f
Improve performance of jtag.c and test it with Python scripts.
Thinker K.F. Li <thinker@branda.to>
parents:
2
diff
changeset
|
162 for(i = 0; i < nbytes; i++) { |
6b1594fb668f
Improve performance of jtag.c and test it with Python scripts.
Thinker K.F. Li <thinker@branda.to>
parents:
2
diff
changeset
|
163 byte = ibuf[i]; |
6b1594fb668f
Improve performance of jtag.c and test it with Python scripts.
Thinker K.F. Li <thinker@branda.to>
parents:
2
diff
changeset
|
164 obyte = 0; |
6b1594fb668f
Improve performance of jtag.c and test it with Python scripts.
Thinker K.F. Li <thinker@branda.to>
parents:
2
diff
changeset
|
165 |
6b1594fb668f
Improve performance of jtag.c and test it with Python scripts.
Thinker K.F. Li <thinker@branda.to>
parents:
2
diff
changeset
|
166 bit = byte & 0x01; |
6b1594fb668f
Improve performance of jtag.c and test it with Python scripts.
Thinker K.F. Li <thinker@branda.to>
parents:
2
diff
changeset
|
167 SEND_BIT(JTAG_TDI, bit); |
6b1594fb668f
Improve performance of jtag.c and test it with Python scripts.
Thinker K.F. Li <thinker@branda.to>
parents:
2
diff
changeset
|
168 tdo = GET_TDO(); |
6b1594fb668f
Improve performance of jtag.c and test it with Python scripts.
Thinker K.F. Li <thinker@branda.to>
parents:
2
diff
changeset
|
169 if(tdo) |
6b1594fb668f
Improve performance of jtag.c and test it with Python scripts.
Thinker K.F. Li <thinker@branda.to>
parents:
2
diff
changeset
|
170 obyte |= 0x01; |
6b1594fb668f
Improve performance of jtag.c and test it with Python scripts.
Thinker K.F. Li <thinker@branda.to>
parents:
2
diff
changeset
|
171 else |
6b1594fb668f
Improve performance of jtag.c and test it with Python scripts.
Thinker K.F. Li <thinker@branda.to>
parents:
2
diff
changeset
|
172 obyte &= ~0x01; |
6b1594fb668f
Improve performance of jtag.c and test it with Python scripts.
Thinker K.F. Li <thinker@branda.to>
parents:
2
diff
changeset
|
173 TCK_LO(); |
2 | 174 |
4
6b1594fb668f
Improve performance of jtag.c and test it with Python scripts.
Thinker K.F. Li <thinker@branda.to>
parents:
2
diff
changeset
|
175 bit = byte & 0x02; |
6b1594fb668f
Improve performance of jtag.c and test it with Python scripts.
Thinker K.F. Li <thinker@branda.to>
parents:
2
diff
changeset
|
176 SEND_BIT(JTAG_TDI, bit); |
6b1594fb668f
Improve performance of jtag.c and test it with Python scripts.
Thinker K.F. Li <thinker@branda.to>
parents:
2
diff
changeset
|
177 tdo = GET_TDO(); |
6b1594fb668f
Improve performance of jtag.c and test it with Python scripts.
Thinker K.F. Li <thinker@branda.to>
parents:
2
diff
changeset
|
178 if(tdo) |
6b1594fb668f
Improve performance of jtag.c and test it with Python scripts.
Thinker K.F. Li <thinker@branda.to>
parents:
2
diff
changeset
|
179 obyte |= 0x02; |
6b1594fb668f
Improve performance of jtag.c and test it with Python scripts.
Thinker K.F. Li <thinker@branda.to>
parents:
2
diff
changeset
|
180 else |
6b1594fb668f
Improve performance of jtag.c and test it with Python scripts.
Thinker K.F. Li <thinker@branda.to>
parents:
2
diff
changeset
|
181 obyte &= ~0x02; |
6b1594fb668f
Improve performance of jtag.c and test it with Python scripts.
Thinker K.F. Li <thinker@branda.to>
parents:
2
diff
changeset
|
182 TCK_LO(); |
6b1594fb668f
Improve performance of jtag.c and test it with Python scripts.
Thinker K.F. Li <thinker@branda.to>
parents:
2
diff
changeset
|
183 |
6b1594fb668f
Improve performance of jtag.c and test it with Python scripts.
Thinker K.F. Li <thinker@branda.to>
parents:
2
diff
changeset
|
184 bit = byte & 0x04; |
6b1594fb668f
Improve performance of jtag.c and test it with Python scripts.
Thinker K.F. Li <thinker@branda.to>
parents:
2
diff
changeset
|
185 SEND_BIT(JTAG_TDI, bit); |
6b1594fb668f
Improve performance of jtag.c and test it with Python scripts.
Thinker K.F. Li <thinker@branda.to>
parents:
2
diff
changeset
|
186 tdo = GET_TDO(); |
6b1594fb668f
Improve performance of jtag.c and test it with Python scripts.
Thinker K.F. Li <thinker@branda.to>
parents:
2
diff
changeset
|
187 if(tdo) |
6b1594fb668f
Improve performance of jtag.c and test it with Python scripts.
Thinker K.F. Li <thinker@branda.to>
parents:
2
diff
changeset
|
188 obyte |= 0x04; |
6b1594fb668f
Improve performance of jtag.c and test it with Python scripts.
Thinker K.F. Li <thinker@branda.to>
parents:
2
diff
changeset
|
189 else |
6b1594fb668f
Improve performance of jtag.c and test it with Python scripts.
Thinker K.F. Li <thinker@branda.to>
parents:
2
diff
changeset
|
190 obyte &= ~0x04; |
6b1594fb668f
Improve performance of jtag.c and test it with Python scripts.
Thinker K.F. Li <thinker@branda.to>
parents:
2
diff
changeset
|
191 TCK_LO(); |
6b1594fb668f
Improve performance of jtag.c and test it with Python scripts.
Thinker K.F. Li <thinker@branda.to>
parents:
2
diff
changeset
|
192 |
6b1594fb668f
Improve performance of jtag.c and test it with Python scripts.
Thinker K.F. Li <thinker@branda.to>
parents:
2
diff
changeset
|
193 bit = byte & 0x08; |
6b1594fb668f
Improve performance of jtag.c and test it with Python scripts.
Thinker K.F. Li <thinker@branda.to>
parents:
2
diff
changeset
|
194 SEND_BIT(JTAG_TDI, bit); |
6b1594fb668f
Improve performance of jtag.c and test it with Python scripts.
Thinker K.F. Li <thinker@branda.to>
parents:
2
diff
changeset
|
195 tdo = GET_TDO(); |
6b1594fb668f
Improve performance of jtag.c and test it with Python scripts.
Thinker K.F. Li <thinker@branda.to>
parents:
2
diff
changeset
|
196 if(tdo) |
6b1594fb668f
Improve performance of jtag.c and test it with Python scripts.
Thinker K.F. Li <thinker@branda.to>
parents:
2
diff
changeset
|
197 obyte |= 0x08; |
6b1594fb668f
Improve performance of jtag.c and test it with Python scripts.
Thinker K.F. Li <thinker@branda.to>
parents:
2
diff
changeset
|
198 else |
6b1594fb668f
Improve performance of jtag.c and test it with Python scripts.
Thinker K.F. Li <thinker@branda.to>
parents:
2
diff
changeset
|
199 obyte &= ~0x08; |
6b1594fb668f
Improve performance of jtag.c and test it with Python scripts.
Thinker K.F. Li <thinker@branda.to>
parents:
2
diff
changeset
|
200 TCK_LO(); |
6b1594fb668f
Improve performance of jtag.c and test it with Python scripts.
Thinker K.F. Li <thinker@branda.to>
parents:
2
diff
changeset
|
201 |
6b1594fb668f
Improve performance of jtag.c and test it with Python scripts.
Thinker K.F. Li <thinker@branda.to>
parents:
2
diff
changeset
|
202 bit = byte & 0x10; |
2 | 203 SEND_BIT(JTAG_TDI, bit); |
204 tdo = GET_TDO(); | |
4
6b1594fb668f
Improve performance of jtag.c and test it with Python scripts.
Thinker K.F. Li <thinker@branda.to>
parents:
2
diff
changeset
|
205 if(tdo) |
6b1594fb668f
Improve performance of jtag.c and test it with Python scripts.
Thinker K.F. Li <thinker@branda.to>
parents:
2
diff
changeset
|
206 obyte |= 0x10; |
6b1594fb668f
Improve performance of jtag.c and test it with Python scripts.
Thinker K.F. Li <thinker@branda.to>
parents:
2
diff
changeset
|
207 else |
6b1594fb668f
Improve performance of jtag.c and test it with Python scripts.
Thinker K.F. Li <thinker@branda.to>
parents:
2
diff
changeset
|
208 obyte &= ~0x10; |
2 | 209 TCK_LO(); |
4
6b1594fb668f
Improve performance of jtag.c and test it with Python scripts.
Thinker K.F. Li <thinker@branda.to>
parents:
2
diff
changeset
|
210 |
6b1594fb668f
Improve performance of jtag.c and test it with Python scripts.
Thinker K.F. Li <thinker@branda.to>
parents:
2
diff
changeset
|
211 bit = byte & 0x20; |
6b1594fb668f
Improve performance of jtag.c and test it with Python scripts.
Thinker K.F. Li <thinker@branda.to>
parents:
2
diff
changeset
|
212 SEND_BIT(JTAG_TDI, bit); |
6b1594fb668f
Improve performance of jtag.c and test it with Python scripts.
Thinker K.F. Li <thinker@branda.to>
parents:
2
diff
changeset
|
213 tdo = GET_TDO(); |
6b1594fb668f
Improve performance of jtag.c and test it with Python scripts.
Thinker K.F. Li <thinker@branda.to>
parents:
2
diff
changeset
|
214 if(tdo) |
6b1594fb668f
Improve performance of jtag.c and test it with Python scripts.
Thinker K.F. Li <thinker@branda.to>
parents:
2
diff
changeset
|
215 obyte |= 0x20; |
6b1594fb668f
Improve performance of jtag.c and test it with Python scripts.
Thinker K.F. Li <thinker@branda.to>
parents:
2
diff
changeset
|
216 else |
6b1594fb668f
Improve performance of jtag.c and test it with Python scripts.
Thinker K.F. Li <thinker@branda.to>
parents:
2
diff
changeset
|
217 obyte &= ~0x20; |
6b1594fb668f
Improve performance of jtag.c and test it with Python scripts.
Thinker K.F. Li <thinker@branda.to>
parents:
2
diff
changeset
|
218 TCK_LO(); |
6b1594fb668f
Improve performance of jtag.c and test it with Python scripts.
Thinker K.F. Li <thinker@branda.to>
parents:
2
diff
changeset
|
219 |
6b1594fb668f
Improve performance of jtag.c and test it with Python scripts.
Thinker K.F. Li <thinker@branda.to>
parents:
2
diff
changeset
|
220 bit = byte & 0x40; |
6b1594fb668f
Improve performance of jtag.c and test it with Python scripts.
Thinker K.F. Li <thinker@branda.to>
parents:
2
diff
changeset
|
221 SEND_BIT(JTAG_TDI, bit); |
6b1594fb668f
Improve performance of jtag.c and test it with Python scripts.
Thinker K.F. Li <thinker@branda.to>
parents:
2
diff
changeset
|
222 tdo = GET_TDO(); |
2 | 223 if(tdo) |
4
6b1594fb668f
Improve performance of jtag.c and test it with Python scripts.
Thinker K.F. Li <thinker@branda.to>
parents:
2
diff
changeset
|
224 obyte |= 0x40; |
6b1594fb668f
Improve performance of jtag.c and test it with Python scripts.
Thinker K.F. Li <thinker@branda.to>
parents:
2
diff
changeset
|
225 else |
6b1594fb668f
Improve performance of jtag.c and test it with Python scripts.
Thinker K.F. Li <thinker@branda.to>
parents:
2
diff
changeset
|
226 obyte &= ~0x40; |
6b1594fb668f
Improve performance of jtag.c and test it with Python scripts.
Thinker K.F. Li <thinker@branda.to>
parents:
2
diff
changeset
|
227 TCK_LO(); |
6b1594fb668f
Improve performance of jtag.c and test it with Python scripts.
Thinker K.F. Li <thinker@branda.to>
parents:
2
diff
changeset
|
228 |
6b1594fb668f
Improve performance of jtag.c and test it with Python scripts.
Thinker K.F. Li <thinker@branda.to>
parents:
2
diff
changeset
|
229 bit = byte & 0x80; |
6b1594fb668f
Improve performance of jtag.c and test it with Python scripts.
Thinker K.F. Li <thinker@branda.to>
parents:
2
diff
changeset
|
230 SEND_BIT(JTAG_TDI, bit); |
6b1594fb668f
Improve performance of jtag.c and test it with Python scripts.
Thinker K.F. Li <thinker@branda.to>
parents:
2
diff
changeset
|
231 tdo = GET_TDO(); |
6b1594fb668f
Improve performance of jtag.c and test it with Python scripts.
Thinker K.F. Li <thinker@branda.to>
parents:
2
diff
changeset
|
232 if(tdo) |
6b1594fb668f
Improve performance of jtag.c and test it with Python scripts.
Thinker K.F. Li <thinker@branda.to>
parents:
2
diff
changeset
|
233 obyte |= 0x80; |
2 | 234 else |
4
6b1594fb668f
Improve performance of jtag.c and test it with Python scripts.
Thinker K.F. Li <thinker@branda.to>
parents:
2
diff
changeset
|
235 obyte &= ~0x80; |
6b1594fb668f
Improve performance of jtag.c and test it with Python scripts.
Thinker K.F. Li <thinker@branda.to>
parents:
2
diff
changeset
|
236 TCK_LO(); |
6b1594fb668f
Improve performance of jtag.c and test it with Python scripts.
Thinker K.F. Li <thinker@branda.to>
parents:
2
diff
changeset
|
237 |
6b1594fb668f
Improve performance of jtag.c and test it with Python scripts.
Thinker K.F. Li <thinker@branda.to>
parents:
2
diff
changeset
|
238 obuf[i] = obyte; |
6b1594fb668f
Improve performance of jtag.c and test it with Python scripts.
Thinker K.F. Li <thinker@branda.to>
parents:
2
diff
changeset
|
239 } |
6b1594fb668f
Improve performance of jtag.c and test it with Python scripts.
Thinker K.F. Li <thinker@branda.to>
parents:
2
diff
changeset
|
240 |
6b1594fb668f
Improve performance of jtag.c and test it with Python scripts.
Thinker K.F. Li <thinker@branda.to>
parents:
2
diff
changeset
|
241 nbits %= 8; |
6b1594fb668f
Improve performance of jtag.c and test it with Python scripts.
Thinker K.F. Li <thinker@branda.to>
parents:
2
diff
changeset
|
242 if(nbits) { |
6b1594fb668f
Improve performance of jtag.c and test it with Python scripts.
Thinker K.F. Li <thinker@branda.to>
parents:
2
diff
changeset
|
243 byte = ibuf[i]; |
6b1594fb668f
Improve performance of jtag.c and test it with Python scripts.
Thinker K.F. Li <thinker@branda.to>
parents:
2
diff
changeset
|
244 obyte = 0; |
6b1594fb668f
Improve performance of jtag.c and test it with Python scripts.
Thinker K.F. Li <thinker@branda.to>
parents:
2
diff
changeset
|
245 for(j = 0; j < nbits; j++) { |
6b1594fb668f
Improve performance of jtag.c and test it with Python scripts.
Thinker K.F. Li <thinker@branda.to>
parents:
2
diff
changeset
|
246 bit = byte & (1 << j); |
6b1594fb668f
Improve performance of jtag.c and test it with Python scripts.
Thinker K.F. Li <thinker@branda.to>
parents:
2
diff
changeset
|
247 SEND_BIT(JTAG_TDI, bit); |
6b1594fb668f
Improve performance of jtag.c and test it with Python scripts.
Thinker K.F. Li <thinker@branda.to>
parents:
2
diff
changeset
|
248 tdo = GET_TDO(); |
6b1594fb668f
Improve performance of jtag.c and test it with Python scripts.
Thinker K.F. Li <thinker@branda.to>
parents:
2
diff
changeset
|
249 if(tdo) |
6b1594fb668f
Improve performance of jtag.c and test it with Python scripts.
Thinker K.F. Li <thinker@branda.to>
parents:
2
diff
changeset
|
250 obyte |= 1 << j; |
6b1594fb668f
Improve performance of jtag.c and test it with Python scripts.
Thinker K.F. Li <thinker@branda.to>
parents:
2
diff
changeset
|
251 else |
6b1594fb668f
Improve performance of jtag.c and test it with Python scripts.
Thinker K.F. Li <thinker@branda.to>
parents:
2
diff
changeset
|
252 obyte &= ~(1 << j); |
6b1594fb668f
Improve performance of jtag.c and test it with Python scripts.
Thinker K.F. Li <thinker@branda.to>
parents:
2
diff
changeset
|
253 TCK_LO(); |
6b1594fb668f
Improve performance of jtag.c and test it with Python scripts.
Thinker K.F. Li <thinker@branda.to>
parents:
2
diff
changeset
|
254 } |
6b1594fb668f
Improve performance of jtag.c and test it with Python scripts.
Thinker K.F. Li <thinker@branda.to>
parents:
2
diff
changeset
|
255 obuf[i] = obyte; |
2 | 256 } |
257 } |