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){
68 for (bit = 0; bit < bitcount; bit++) {
69 /* write MOSI on trailing edge of previous clock */
77 SETTMS;//TMS high on last bit to exit.
81 /* read MISO on trailing edge */
86 word = ((word << 16) | (word >> 4)) & 0x000FFFFF;
103 //! Shift 16 bits in and out.
104 unsigned int jtagtrans16(unsigned int word){ //REMOVEME
108 for (bit = 0; bit < 16; bit++) {
109 // write MOSI on trailing edge of previous clock
117 SETTMS;//TMS high on last bit to exit.
121 // read MISO on trailing edge
137 //! Stop JTAG, release pins
143 unsigned int drwidth=20;
144 //! Shift all bits of the DR.
145 unsigned long jtag_dr_shift20(unsigned long in){
158 // shift DR, then idle
159 return(jtagtransn(in,20));
163 //! Shift 16 bits of the DR.
164 unsigned int jtag_dr_shift16(unsigned int in){
177 // shift DR, then idle
178 return(jtagtransn(in,16));
182 //! Shift 8 bits of the IR.
183 unsigned char jtag_ir_shift8(unsigned char in){
199 // shift IR, then idle.
200 return(jtagtrans8(in));
203 //! Handles a monitor command.
204 void jtaghandle(unsigned char app,
208 //START handled by specific JTAG
218 cmddata[0]=jtag_ir_shift8(cmddata[0]);
222 cmddataword[0]=jtag_dr_shift16(cmddataword[0]);