1 //GoodFET JTAG Application
4 //Higher level left to client application.
11 //! Set up the pins for JTAG mode.
21 //! Shift 8 bits in and out.
22 unsigned char jtagtrans8(unsigned char byte){
25 for (bit = 0; bit < 8; bit++) {
26 /* write MOSI on trailing edge of previous clock */
34 SETTMS;//TMS high on last bit to exit.
38 /* read MISO on trailing edge */
54 //! Shift n bits in and out.
55 unsigned long jtagtransn(unsigned long word,
56 unsigned int bitcount){
58 unsigned int high=(word>>16);
63 for (bit = 0; bit < bitcount; bit++) {
64 /* write MOSI on trailing edge of previous clock */
72 SETTMS;//TMS high on last bit to exit.
76 /* read MISO on trailing edge */
81 word = ((word << 16) | (word >> 4)) & 0x000FFFFF;
98 //! Shift 16 bits in and out.
99 unsigned int jtagtrans16(unsigned int word){ //REMOVEME
103 for (bit = 0; bit < 16; bit++) {
104 // write MOSI on trailing edge of previous clock
112 SETTMS;//TMS high on last bit to exit.
116 // read MISO on trailing edge
132 //! Stop JTAG, release pins
138 unsigned int drwidth=20;
139 //! Shift all bits of the DR.
140 unsigned long jtag_dr_shift(unsigned long in){
153 // shift DR, then idle
154 return(jtagtransn(in,drwidth));
158 //! Shift 16 bits of the DR.
159 unsigned int jtag_dr_shift16(unsigned int in){
160 //This name is deprecated, kept around to find 16-bit dependent code.
161 return jtag_dr_shift(in);
165 //! Shift 8 bits of the IR.
166 unsigned char jtag_ir_shift8(unsigned char in){
182 // shift IR, then idle.
183 return(jtagtrans8(in));
186 //! Handles a monitor command.
187 void jtaghandle(unsigned char app,
191 //START handled by specific JTAG
201 cmddata[0]=jtag_ir_shift8(cmddata[0]);
205 cmddataword[0]=jtag_dr_shift16(cmddataword[0]);