2 \author Travis Goodspeed <travis at radiantmachines.com>
4 This is an implementation of the low-level JTAG functions
5 for the GoodFET project at http://goodfet.sf.net/
7 See the license file for details of proper use.
16 //! Set up the pins for JTAG mode.
28 //! Shift 8 bits in and out.
29 unsigned char jtagtrans8(unsigned char byte){
32 for (bit = 0; bit < 8; bit++) {
33 /* write MOSI on trailing edge of previous clock */
41 SETTMS;//TMS high on last bit to exit.
45 /* read MISO on trailing edge */
61 //! Shift n bits in and out.
62 unsigned long jtagtransn(unsigned long word,
63 unsigned int bitcount){
75 for (bit = 0; bit < bitcount; bit++) {
76 /* write MOSI on trailing edge of previous clock */
84 SETTMS;//TMS high on last bit to exit.
88 /* read MISO on trailing edge */
93 word = ((word << 16) | (word >> 4)) & 0x000FFFFF;
110 //! Shift 16 bits in and out.
111 unsigned int jtagtrans16(unsigned int word){ //REMOVEME
115 for (bit = 0; bit < 16; bit++) {
116 // write MOSI on trailing edge of previous clock
124 SETTMS;//TMS high on last bit to exit.
128 // read MISO on trailing edge
144 //! Stop JTAG, release pins
150 unsigned int drwidth=20;
151 //! Shift all bits of the DR.
152 unsigned long jtag_dr_shift20(unsigned long in){
165 // shift DR, then idle
166 return(jtagtransn(in,20));
170 //! Shift 16 bits of the DR.
171 unsigned int jtag_dr_shift16(unsigned int in){
184 // shift DR, then idle
185 return(jtagtransn(in,16));
189 //! Shift 8 bits of the IR.
190 unsigned char jtag_ir_shift8(unsigned char in){
206 // shift IR, then idle.
207 return(jtagtrans8(in));
210 //! Handles a monitor command.
211 void jtaghandle(unsigned char app,
215 //START handled by specific JTAG
225 cmddata[0]=jtag_ir_shift8(cmddata[0]);
229 cmddataword[0]=jtag_dr_shift16(cmddataword[0]);