X-Git-Url: http://git.rot13.org/?p=goodfet;a=blobdiff_plain;f=firmware%2Fapps%2Fjtag%2Fjtag.c;h=14e87617edd1a48e57b32c658b9b345ff6870a79;hp=4dc7021c3cb7bb6ecbe83e9e5ee0e2a97613597f;hb=1283fdb830f9ecd0e27e10ef66927562aff674a7;hpb=0fb25630e9970a4e6d18e190c484f654490565b0 diff --git a/firmware/apps/jtag/jtag.c b/firmware/apps/jtag/jtag.c index 4dc7021..14e8761 100644 --- a/firmware/apps/jtag/jtag.c +++ b/firmware/apps/jtag/jtag.c @@ -13,8 +13,10 @@ void jtagsetup(){ P5DIR|=MOSI+SCK+TMS; P5DIR&=~MISO; P5OUT|=0xFFFF; + P5OUT=0; P4DIR|=TST; P2DIR|=RST; + msdelay(100); } int savedtclk=0; @@ -55,11 +57,19 @@ unsigned char jtagtrans8(unsigned char byte){ unsigned long jtagtransn(unsigned long word, unsigned int bitcount){ unsigned int bit; + //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;} @@ -73,6 +83,11 @@ unsigned long jtagtransn(unsigned long word, /* read MISO on trailing edge */ word |= READMISO; } + + if(bitcount==20){ + word = ((word << 16) | (word >> 4)) & 0x000FFFFF; + } + RESTORETCLK; // exit state @@ -129,7 +144,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; @@ -143,14 +158,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)); }