X-Git-Url: http://git.rot13.org/?p=goodfet;a=blobdiff_plain;f=firmware%2Fapps%2Fjtag%2Fjtagarm7.c;h=015705f567d4fc3f0b3d1004fdefbbaafd9fb1a2;hp=5310d62b4f11c1787df060696c0bf549f7a75524;hb=103264307048648a5bdc36084493cac27471cb6b;hpb=e8fe7534c5f3ad2e281669bd0f869b8327761861 diff --git a/firmware/apps/jtag/jtagarm7.c b/firmware/apps/jtag/jtagarm7.c index 5310d62..015705f 100644 --- a/firmware/apps/jtag/jtagarm7.c +++ b/firmware/apps/jtag/jtagarm7.c @@ -460,7 +460,7 @@ uint8_t* jtag_trans_many(uint8_t *data, if (!in_state(SHIFT_IR | SHIFT_DR)) { - debugstr("jtag_trans_n from invalid TAP state"); + debugstr("jtag_trans_many from invalid TAP state"); return 0; } @@ -470,31 +470,15 @@ uint8_t* jtag_trans_many(uint8_t *data, { high = (1L << (min(bitcount,8) - 1)); mask = high - 1; - hmask = (high<<1) - 1; - debugstr(" starting shift:"); - //debughex(bit); - debughex(high); - //debughex(hmask); - debughex(mask); - debughex(*data); for (bit = bitcount; bit > 0; bit--,bitnum++) { if (bitnum == 8) { high = (1L << (min(bit,8) - 1)); - hmask = (high<<1) - 1; mask = high - 1; bitnum = 0; - - debugstr(""); - //debughex(bit); - debughex(high); - //debughex(hmask); - debughex(mask); - debughex(*data); data ++; - } /* write MOSI on trailing edge of previous clock */ if (*data & 1) @@ -518,17 +502,11 @@ uint8_t* jtag_trans_many(uint8_t *data, /* read MISO on trailing edge */ if (READMISO) { - debugstr("MISO: 1"); *data |= (high); } - else - { - debugstr("MISO: 0"); - } - debughex(*data); } - debughex(*data); + hmask = (high<<1) - 1; *data &= hmask; } else @@ -536,12 +514,25 @@ uint8_t* jtag_trans_many(uint8_t *data, // MSB... we need to start at the end of the byte array data += (bitcount/8); bitnum = bitcount % 8; - high = (1L << (max(bitnum,8) - 1)); + high = (1L << (min(bitnum,8) - 1)); mask = high - 1; hmask = (high<<1) - 1; for (bit = bitcount; bit > 0; bit--,bitnum--) { + if (bitnum == 0) + { + *data &= hmask; + debughex(*data); + + high = (1L << (min(bit,8) - 1)); + mask = high - 1; + hmask = (high<<1) - 1; + bitnum = 8; + + data --; + } + /* write MOSI on trailing edge of previous clock */ if (*data & high) { @@ -564,14 +555,6 @@ uint8_t* jtag_trans_many(uint8_t *data, /* read MISO on trailing edge */ *data |= (READMISO); - if (bitnum == 0) - { - high = (1L << (min(bit,8) - 1)); - mask = high - 1; - hmask = (high<<1) - 1; - bitnum = 8; - data --; - } } }