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){
62 unsigned long high=0x8000;
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 //! Stop JTAG, release pins
112 unsigned int drwidth=20;
113 //! Shift all bits of the DR.
114 unsigned long jtag_dr_shift20(unsigned long in){
127 // shift DR, then idle
128 return(jtagtransn(in,20));
132 //! Shift 16 bits of the DR.
133 unsigned int jtag_dr_shift16(unsigned int in){
146 // shift DR, then idle
147 return(jtagtransn(in,16));
151 //! Shift 8 bits of the IR.
152 unsigned char jtag_ir_shift8(unsigned char in){
168 // shift IR, then idle.
169 return(jtagtrans8(in));
172 //! Handles a monitor command.
173 void jtaghandle(unsigned char app,
177 //START handled by specific JTAG
187 cmddata[0]=jtag_ir_shift8(cmddata[0]);
191 cmddataword[0]=jtag_dr_shift16(cmddataword[0]);