2 \author Travis Goodspeed <travis at radiantmachines.com>
12 //! Set up the pins for JTAG mode.
24 //! Shift 8 bits in and out.
25 unsigned char jtagtrans8(unsigned char byte){
28 for (bit = 0; bit < 8; bit++) {
29 /* write MOSI on trailing edge of previous clock */
37 SETTMS;//TMS high on last bit to exit.
41 /* read MISO on trailing edge */
57 //! Shift n bits in and out.
58 unsigned long jtagtransn(unsigned long word,
59 unsigned int bitcount){
71 for (bit = 0; bit < bitcount; bit++) {
72 /* write MOSI on trailing edge of previous clock */
80 SETTMS;//TMS high on last bit to exit.
84 /* read MISO on trailing edge */
89 word = ((word << 16) | (word >> 4)) & 0x000FFFFF;
106 //! Shift 16 bits in and out.
107 unsigned int jtagtrans16(unsigned int word){ //REMOVEME
111 for (bit = 0; bit < 16; bit++) {
112 // write MOSI on trailing edge of previous clock
120 SETTMS;//TMS high on last bit to exit.
124 // read MISO on trailing edge
140 //! Stop JTAG, release pins
146 unsigned int drwidth=20;
147 //! Shift all bits of the DR.
148 unsigned long jtag_dr_shift20(unsigned long in){
161 // shift DR, then idle
162 return(jtagtransn(in,20));
166 //! Shift 16 bits of the DR.
167 unsigned int jtag_dr_shift16(unsigned int in){
180 // shift DR, then idle
181 return(jtagtransn(in,16));
185 //! Shift 8 bits of the IR.
186 unsigned char jtag_ir_shift8(unsigned char in){
202 // shift IR, then idle.
203 return(jtagtrans8(in));
206 //! Handles a monitor command.
207 void jtaghandle(unsigned char app,
211 //START handled by specific JTAG
221 cmddata[0]=jtag_ir_shift8(cmddata[0]);
225 cmddataword[0]=jtag_dr_shift16(cmddataword[0]);