2 \author Travis Goodspeed <travis at radiantmachines.com>
12 //! Set up the pins for JTAG mode.
26 //! Shift 8 bits in and out.
27 unsigned char jtagtrans8(unsigned char byte){
30 for (bit = 0; bit < 8; bit++) {
31 /* write MOSI on trailing edge of previous clock */
39 SETTMS;//TMS high on last bit to exit.
42 /* read MISO on trailing edge */
56 //! Shift n bits in and out.
57 unsigned long jtagtransn(unsigned long word,
58 unsigned int bitcount){
61 unsigned long high=0x8000;
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.
82 /* read MISO on trailing edge */
87 word = ((word << 16) | (word >> 4)) & 0x000FFFFF;
102 //! Stop JTAG, release pins
108 unsigned int drwidth=16;
109 //! Shift all bits of the DR.
110 unsigned long jtag_dr_shift20(unsigned long in){
120 // shift DR, then idle
121 return(jtagtransn(in,20));
125 //! Shift 16 bits of the DR.
126 unsigned int jtag_dr_shift16(unsigned int in){
136 // shift DR, then idle
137 return(jtagtransn(in,16));
140 //! Shift native width of the DR
141 unsigned long jtag_dr_shiftadr(unsigned long in){
154 out=jtagtransn(in,drwidth);
156 // shift DR, then idle
161 //! Shift 8 bits of the IR.
162 unsigned char jtag_ir_shift8(unsigned char in){
174 // shift IR, then idle.
175 return(jtagtrans8(in));
178 //! Handles a monitor command.
179 void jtaghandle(unsigned char app,
183 //START handled by specific JTAG
193 cmddata[0]=jtag_ir_shift8(cmddata[0]);
197 cmddataword[0]=jtag_dr_shift16(cmddataword[0]);