Mercurial > avr_jtag
annotate src/jtag.c @ 4:6b1594fb668f
Improve performance of jtag.c and test it with Python scripts.
- cp_tditdo.py send bits to TDI and hope it will feed back from TDO.
- Expand loops in jtag.c to improve performance.
author | Thinker K.F. Li <thinker@branda.to> |
---|---|
date | Sun, 22 Feb 2009 12:54:45 +0800 |
parents | abf221bf3ce4 |
children | eb14cac68cbb |
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 | |
33 void jtag_tms(char *buf, int nbits) { | |
34 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
|
35 int nbytes, byte; |
2 | 36 int byteoff, bitoff; |
37 int bit; | |
38 | |
4
6b1594fb668f
Improve performance of jtag.c and test it with Python scripts.
Thinker K.F. Li <thinker@branda.to>
parents:
2
diff
changeset
|
39 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
|
40 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
|
41 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
|
42 |
6b1594fb668f
Improve performance of jtag.c and test it with Python scripts.
Thinker K.F. Li <thinker@branda.to>
parents:
2
diff
changeset
|
43 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
|
44 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
|
45 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
|
46 |
6b1594fb668f
Improve performance of jtag.c and test it with Python scripts.
Thinker K.F. Li <thinker@branda.to>
parents:
2
diff
changeset
|
47 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
|
48 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
|
49 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
|
50 |
6b1594fb668f
Improve performance of jtag.c and test it with Python scripts.
Thinker K.F. Li <thinker@branda.to>
parents:
2
diff
changeset
|
51 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
|
52 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
|
53 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
|
54 |
6b1594fb668f
Improve performance of jtag.c and test it with Python scripts.
Thinker K.F. Li <thinker@branda.to>
parents:
2
diff
changeset
|
55 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
|
56 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
|
57 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
|
58 |
6b1594fb668f
Improve performance of jtag.c and test it with Python scripts.
Thinker K.F. Li <thinker@branda.to>
parents:
2
diff
changeset
|
59 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
|
60 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
|
61 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
|
62 |
6b1594fb668f
Improve performance of jtag.c and test it with Python scripts.
Thinker K.F. Li <thinker@branda.to>
parents:
2
diff
changeset
|
63 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
|
64 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
|
65 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
|
66 |
6b1594fb668f
Improve performance of jtag.c and test it with Python scripts.
Thinker K.F. Li <thinker@branda.to>
parents:
2
diff
changeset
|
67 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
|
68 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
|
69 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
|
70 |
6b1594fb668f
Improve performance of jtag.c and test it with Python scripts.
Thinker K.F. Li <thinker@branda.to>
parents:
2
diff
changeset
|
71 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
|
72 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
|
73 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
|
74 } |
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 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
|
77 nbits %= 8; |
2 | 78 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
|
79 bit = byte & (1 << i); |
2 | 80 SEND_BIT(JTAG_TMS, bit); |
81 TCK_LO(); | |
82 } | |
83 } | |
84 | |
85 void jtag_shift(char *buf, int nbits) { | |
86 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
|
87 int nbytes, byte; |
2 | 88 int byteoff, bitoff; |
89 int bit; | |
90 | |
4
6b1594fb668f
Improve performance of jtag.c and test it with Python scripts.
Thinker K.F. Li <thinker@branda.to>
parents:
2
diff
changeset
|
91 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
|
92 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
|
93 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
|
94 |
6b1594fb668f
Improve performance of jtag.c and test it with Python scripts.
Thinker K.F. Li <thinker@branda.to>
parents:
2
diff
changeset
|
95 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
|
96 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
|
97 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
|
98 |
6b1594fb668f
Improve performance of jtag.c and test it with Python scripts.
Thinker K.F. Li <thinker@branda.to>
parents:
2
diff
changeset
|
99 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
|
100 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
|
101 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
|
102 |
6b1594fb668f
Improve performance of jtag.c and test it with Python scripts.
Thinker K.F. Li <thinker@branda.to>
parents:
2
diff
changeset
|
103 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
|
104 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
|
105 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
|
106 |
6b1594fb668f
Improve performance of jtag.c and test it with Python scripts.
Thinker K.F. Li <thinker@branda.to>
parents:
2
diff
changeset
|
107 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
|
108 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
|
109 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
|
110 |
6b1594fb668f
Improve performance of jtag.c and test it with Python scripts.
Thinker K.F. Li <thinker@branda.to>
parents:
2
diff
changeset
|
111 bit = byte & 0x10; |
2 | 112 SEND_BIT(JTAG_TDI, bit); |
113 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
|
114 |
6b1594fb668f
Improve performance of jtag.c and test it with Python scripts.
Thinker K.F. Li <thinker@branda.to>
parents:
2
diff
changeset
|
115 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
|
116 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
|
117 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
|
118 |
6b1594fb668f
Improve performance of jtag.c and test it with Python scripts.
Thinker K.F. Li <thinker@branda.to>
parents:
2
diff
changeset
|
119 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
|
120 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
|
121 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
|
122 |
6b1594fb668f
Improve performance of jtag.c and test it with Python scripts.
Thinker K.F. Li <thinker@branda.to>
parents:
2
diff
changeset
|
123 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
|
124 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
|
125 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
|
126 } |
6b1594fb668f
Improve performance of jtag.c and test it with Python scripts.
Thinker K.F. Li <thinker@branda.to>
parents:
2
diff
changeset
|
127 |
6b1594fb668f
Improve performance of jtag.c and test it with Python scripts.
Thinker K.F. Li <thinker@branda.to>
parents:
2
diff
changeset
|
128 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
|
129 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
|
130 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
|
131 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
|
132 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
|
133 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
|
134 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
|
135 } |
2 | 136 } |
137 } | |
138 | |
139 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
|
140 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
|
141 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
|
142 int tdo; |
2 | 143 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
|
144 int bit; |
2 | 145 |
4
6b1594fb668f
Improve performance of jtag.c and test it with Python scripts.
Thinker K.F. Li <thinker@branda.to>
parents:
2
diff
changeset
|
146 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
|
147 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
|
148 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
|
149 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
|
150 |
6b1594fb668f
Improve performance of jtag.c and test it with Python scripts.
Thinker K.F. Li <thinker@branda.to>
parents:
2
diff
changeset
|
151 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
|
152 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
|
153 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
|
154 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
|
155 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
|
156 else |
6b1594fb668f
Improve performance of jtag.c and test it with Python scripts.
Thinker K.F. Li <thinker@branda.to>
parents:
2
diff
changeset
|
157 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
|
158 TCK_LO(); |
2 | 159 |
4
6b1594fb668f
Improve performance of jtag.c and test it with Python scripts.
Thinker K.F. Li <thinker@branda.to>
parents:
2
diff
changeset
|
160 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
|
161 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
|
162 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
|
163 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
|
164 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
|
165 else |
6b1594fb668f
Improve performance of jtag.c and test it with Python scripts.
Thinker K.F. Li <thinker@branda.to>
parents:
2
diff
changeset
|
166 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
|
167 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
|
168 |
6b1594fb668f
Improve performance of jtag.c and test it with Python scripts.
Thinker K.F. Li <thinker@branda.to>
parents:
2
diff
changeset
|
169 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
|
170 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
|
171 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
|
172 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
|
173 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
|
174 else |
6b1594fb668f
Improve performance of jtag.c and test it with Python scripts.
Thinker K.F. Li <thinker@branda.to>
parents:
2
diff
changeset
|
175 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
|
176 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
|
177 |
6b1594fb668f
Improve performance of jtag.c and test it with Python scripts.
Thinker K.F. Li <thinker@branda.to>
parents:
2
diff
changeset
|
178 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
|
179 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
|
180 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
|
181 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
|
182 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
|
183 else |
6b1594fb668f
Improve performance of jtag.c and test it with Python scripts.
Thinker K.F. Li <thinker@branda.to>
parents:
2
diff
changeset
|
184 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
|
185 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
|
186 |
6b1594fb668f
Improve performance of jtag.c and test it with Python scripts.
Thinker K.F. Li <thinker@branda.to>
parents:
2
diff
changeset
|
187 bit = byte & 0x10; |
2 | 188 SEND_BIT(JTAG_TDI, bit); |
189 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
|
190 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
|
191 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
|
192 else |
6b1594fb668f
Improve performance of jtag.c and test it with Python scripts.
Thinker K.F. Li <thinker@branda.to>
parents:
2
diff
changeset
|
193 obyte &= ~0x10; |
2 | 194 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
|
195 |
6b1594fb668f
Improve performance of jtag.c and test it with Python scripts.
Thinker K.F. Li <thinker@branda.to>
parents:
2
diff
changeset
|
196 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
|
197 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
|
198 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
|
199 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
|
200 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
|
201 else |
6b1594fb668f
Improve performance of jtag.c and test it with Python scripts.
Thinker K.F. Li <thinker@branda.to>
parents:
2
diff
changeset
|
202 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
|
203 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
|
204 |
6b1594fb668f
Improve performance of jtag.c and test it with Python scripts.
Thinker K.F. Li <thinker@branda.to>
parents:
2
diff
changeset
|
205 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
|
206 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
|
207 tdo = GET_TDO(); |
2 | 208 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
|
209 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
|
210 else |
6b1594fb668f
Improve performance of jtag.c and test it with Python scripts.
Thinker K.F. Li <thinker@branda.to>
parents:
2
diff
changeset
|
211 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
|
212 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
|
213 |
6b1594fb668f
Improve performance of jtag.c and test it with Python scripts.
Thinker K.F. Li <thinker@branda.to>
parents:
2
diff
changeset
|
214 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
|
215 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
|
216 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
|
217 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
|
218 obyte |= 0x80; |
2 | 219 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
|
220 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
|
221 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
|
222 |
6b1594fb668f
Improve performance of jtag.c and test it with Python scripts.
Thinker K.F. Li <thinker@branda.to>
parents:
2
diff
changeset
|
223 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
|
224 } |
6b1594fb668f
Improve performance of jtag.c and test it with Python scripts.
Thinker K.F. Li <thinker@branda.to>
parents:
2
diff
changeset
|
225 |
6b1594fb668f
Improve performance of jtag.c and test it with Python scripts.
Thinker K.F. Li <thinker@branda.to>
parents:
2
diff
changeset
|
226 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
|
227 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
|
228 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
|
229 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
|
230 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
|
231 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
|
232 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
|
233 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
|
234 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
|
235 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
|
236 else |
6b1594fb668f
Improve performance of jtag.c and test it with Python scripts.
Thinker K.F. Li <thinker@branda.to>
parents:
2
diff
changeset
|
237 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
|
238 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
|
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 obuf[i] = obyte; |
2 | 241 } |
242 } |