X-Git-Url: http://git.rot13.org/?p=goodfet;a=blobdiff_plain;f=firmware%2Fapps%2Fjtag%2Fjtag.c;h=af420c7095afd854aa7866dc8a082fdd24a5a4e2;hp=5abba15cb43d6cee14365179c5b8f38f1a01c690;hb=4b2f28239ea1c0f76117e813fc8838f8a368d2bf;hpb=3e4369fde16445c994da1b1efb332704aad0716d diff --git a/firmware/apps/jtag/jtag.c b/firmware/apps/jtag/jtag.c index 5abba15..af420c7 100644 --- a/firmware/apps/jtag/jtag.c +++ b/firmware/apps/jtag/jtag.c @@ -55,14 +55,19 @@ unsigned char jtagtrans8(unsigned char byte){ unsigned long jtagtransn(unsigned long word, unsigned int bitcount){ unsigned int bit; - unsigned int high=(word>>16); - SAVETCLK; + //0x8000 + unsigned long high; + if(bitcount==20) + high=0x80000; + if(bitcount==16) + high= 0x8000; + SAVETCLK; for (bit = 0; bit < bitcount; bit++) { /* write MOSI on trailing edge of previous clock */ - if (word & 0x8000) + if (word & high) {SETMOSI;} else {CLRMOSI;} @@ -137,7 +142,7 @@ void jtag_stop(){ unsigned int drwidth=20; //! Shift all bits of the DR. -unsigned long jtag_dr_shift(unsigned long in){ +unsigned long jtag_dr_shift20(unsigned long in){ // idle SETTMS; CLRTCK; @@ -151,14 +156,26 @@ unsigned long jtag_dr_shift(unsigned long in){ SETTCK; // shift DR, then idle - return(jtagtransn(in,drwidth)); + return(jtagtransn(in,20)); } //! Shift 16 bits of the DR. unsigned int jtag_dr_shift16(unsigned int in){ - //This name is deprecated, kept around to find 16-bit dependent code. - return jtag_dr_shift(in); + // idle + SETTMS; + CLRTCK; + SETTCK; + // select DR + CLRTMS; + CLRTCK; + SETTCK; + // capture IR + CLRTCK; + SETTCK; + + // shift DR, then idle + return(jtagtransn(in,16)); }