1 //GoodFET JTAG Application
4 //Higher level left to client application.
11 //! Set up the pins for JTAG mode.
23 //! Shift 8 bits in and out.
24 unsigned char jtagtrans8(unsigned char byte){
27 for (bit = 0; bit < 8; bit++) {
28 /* write MOSI on trailing edge of previous clock */
36 SETTMS;//TMS high on last bit to exit.
40 /* read MISO on trailing edge */
56 //! Shift n bits in and out.
57 unsigned long jtagtransn(unsigned long word,
58 unsigned int bitcount){
70 for (bit = 0; bit < bitcount; bit++) {
71 /* write MOSI on trailing edge of previous clock */
79 SETTMS;//TMS high on last bit to exit.
83 /* read MISO on trailing edge */
88 word = ((word << 16) | (word >> 4)) & 0x000FFFFF;
105 //! Shift 16 bits in and out.
106 unsigned int jtagtrans16(unsigned int word){ //REMOVEME
110 for (bit = 0; bit < 16; bit++) {
111 // write MOSI on trailing edge of previous clock
119 SETTMS;//TMS high on last bit to exit.
123 // read MISO on trailing edge
139 //! Stop JTAG, release pins
145 unsigned int drwidth=20;
146 //! Shift all bits of the DR.
147 unsigned long jtag_dr_shift20(unsigned long in){
160 // shift DR, then idle
161 return(jtagtransn(in,20));
165 //! Shift 16 bits of the DR.
166 unsigned int jtag_dr_shift16(unsigned int in){
179 // shift DR, then idle
180 return(jtagtransn(in,16));
184 //! Shift 8 bits of the IR.
185 unsigned char jtag_ir_shift8(unsigned char in){
201 // shift IR, then idle.
202 return(jtagtrans8(in));
205 //! Handles a monitor command.
206 void jtaghandle(unsigned char app,
210 //START handled by specific JTAG
220 cmddata[0]=jtag_ir_shift8(cmddata[0]);
224 cmddataword[0]=jtag_dr_shift16(cmddataword[0]);