comparison src/jtag.c @ 5:eb14cac68cbb

Transite TAP controller to shift state. - shift commands will transite state machine of TAP controller to shift state before starting shifting.
author Thinker K.F. Li <thinker@branda.to>
date Sun, 22 Feb 2009 13:55:50 +0800
parents 6b1594fb668f
children 61f27549de57
comparison
equal deleted inserted replaced
4:6b1594fb668f 5:eb14cac68cbb
28 TCK_HI(); \ 28 TCK_HI(); \
29 CLK_DELAY(); \ 29 CLK_DELAY(); \
30 } while(0) 30 } while(0)
31 #define GET_TDO() (JTAG_PIN & _BV(JTAG_TDO)) 31 #define GET_TDO() (JTAG_PIN & _BV(JTAG_TDO))
32 32
33 /*!
34 * Before shifting registers, TAP controller must move to last state before
35 * shift state. The state machine transite to shift state when shifting
36 * starts.
37 */
33 void jtag_tms(char *buf, int nbits) { 38 void jtag_tms(char *buf, int nbits) {
34 int i; 39 int i;
35 int nbytes, byte; 40 int nbytes, byte;
36 int byteoff, bitoff; 41 int byteoff, bitoff;
37 int bit; 42 int bit;
86 int i; 91 int i;
87 int nbytes, byte; 92 int nbytes, byte;
88 int byteoff, bitoff; 93 int byteoff, bitoff;
89 int bit; 94 int bit;
90 95
96 /* Transite to shift state.
97 * \sa jtag_tms()
98 */
99 pin_lo(JTAG_PORT, JTAG_TMS);
100
91 nbytes = nbits / 8; 101 nbytes = nbits / 8;
92 for(i = 0; i < nbytes; i++) { 102 for(i = 0; i < nbytes; i++) {
93 byte = buf[i]; 103 byte = buf[i];
94 104
95 bit = byte & 0x01; 105 bit = byte & 0x01;
141 int nbytes, byte, obyte; 151 int nbytes, byte, obyte;
142 int tdo; 152 int tdo;
143 int byteoff, bitoff; 153 int byteoff, bitoff;
144 int bit; 154 int bit;
145 155
156 /* Transite to shift state.
157 * \sa jtag_tms()
158 */
159 pin_lo(JTAG_PORT, JTAG_TMS);
160
146 nbytes = nbits / 8; 161 nbytes = nbits / 8;
147 for(i = 0; i < nbytes; i++) { 162 for(i = 0; i < nbytes; i++) {
148 byte = ibuf[i]; 163 byte = ibuf[i];
149 obyte = 0; 164 obyte = 0;
150 165