jtagarm: jtag_trans_many tested and working. this will allow us to abstract out...
authordodge-this <dodge-this@12e2690d-a6be-4b82-a7b7-67c4a43b65c8>
Thu, 7 Feb 2013 12:53:22 +0000 (12:53 +0000)
committerdodge-this <dodge-this@12e2690d-a6be-4b82-a7b7-67c4a43b65c8>
Thu, 7 Feb 2013 12:53:22 +0000 (12:53 +0000)
git-svn-id: https://svn.code.sf.net/p/goodfet/code/trunk@1466 12e2690d-a6be-4b82-a7b7-67c4a43b65c8

firmware/apps/jtag/jtagarm7.c

index 5310d62..015705f 100644 (file)
@@ -460,7 +460,7 @@ uint8_t* jtag_trans_many(uint8_t *data,
 
        if (!in_state(SHIFT_IR | SHIFT_DR))
        {
 
        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;
        }
 
                return 0;
        }
 
@@ -470,31 +470,15 @@ uint8_t* jtag_trans_many(uint8_t *data,
        {
         high = (1L << (min(bitcount,8) - 1));
         mask = high - 1;
        {
         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));
 
                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;
                 mask = high - 1;
                 bitnum = 0;
-
-                debugstr("");
-                //debughex(bit);
-                debughex(high);
-                //debughex(hmask);
-                debughex(mask);
-                debughex(*data);
                 data ++;
                 data ++;
-
             }
                        /* write MOSI on trailing edge of previous clock */
                        if (*data & 1)
             }
                        /* 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)
                        {
                        /* read MISO on trailing edge */
                        if (READMISO)
                        {
-                debugstr("MISO: 1");
                                *data |= (high);
                        }
                                *data |= (high);
                        }
-            else
-            {
-                debugstr("MISO: 0");
-            }
-            debughex(*data);
 
                }
 
                }
-        debughex(*data);
+        hmask = (high<<1) - 1;
         *data &= hmask;
        } 
        else 
         *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;
         // 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--) 
                {
         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)
                        {
                        /* 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);
 
                        /* 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 --;
-            }
                }
        }
        
                }
        }