1 //GoodFET JTAG Application
4 //Higher level left to client application.
11 //! Set up the pins for JTAG mode.
21 //! Shift 8 bits in and out.
22 unsigned char jtagtrans8(unsigned char byte){
25 for (bit = 0; bit < 8; bit++) {
26 /* write MOSI on trailing edge of previous clock */
34 SETTMS;//TMS high on last bit to exit.
38 /* read MISO on trailing edge */
54 //! Shift n bits in and out.
55 unsigned long jtagtransn(unsigned long word,
56 unsigned int bitcount){
60 for (bit = 0; bit < bitcount; bit++) {
61 /* write MOSI on trailing edge of previous clock */
69 SETTMS;//TMS high on last bit to exit.
73 /* read MISO on trailing edge */
90 //! Shift 16 bits in and out.
91 unsigned int jtagtrans16(unsigned int word){ //REMOVEME
95 for (bit = 0; bit < 16; bit++) {
96 // write MOSI on trailing edge of previous clock
104 SETTMS;//TMS high on last bit to exit.
108 // read MISO on trailing edge
124 //! Stop JTAG, release pins
130 unsigned int drwidth=20;
131 //! Shift all bits of the DR.
132 unsigned long jtag_dr_shift(unsigned long in){
145 // shift DR, then idle
146 return(jtagtransn(in,drwidth));
150 //! Shift 16 bits of the DR.
151 unsigned int jtag_dr_shift16(unsigned int in){
152 //This name is deprecated, kept around to find 16-bit dependent code.
153 return jtag_dr_shift(in);
157 //! Shift 8 bits of the IR.
158 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]);