ft2232: simplify ft2232_read_scan
authorMarc Pignat <marc.pignat@hevs.ch>
Thu, 17 Jun 2010 08:07:22 +0000 (10:07 +0200)
committerØyvind Harboe <oyvind.harboe@zylin.com>
Thu, 1 Jul 2010 07:32:56 +0000 (09:32 +0200)
src/jtag/drivers/ft2232.c

index bc8463e6e5affefb9fa57732a81214fa3f28a880..9d40b1c040f5790ccef5e3a1fa7eaca2404b45dc 100644 (file)
@@ -714,23 +714,24 @@ static void ft2232_end_state(tap_state_t state)
 
 static void ft2232_read_scan(enum scan_type type, uint8_t* buffer, int scan_size)
 {
-       int num_bytes = (scan_size + 7) / 8;
-       int bits_left = scan_size;
-       int cur_byte  = 0;
+       int num_bytes = scan_size / 8;
+       int bits_left = scan_size % 8;
+       int cur_byte;
 
-       while (num_bytes-- > 1)
+       for (cur_byte = 0; cur_byte < num_bytes; cur_byte++)
        {
-               buffer[cur_byte++] = buffer_read();
-               bits_left -= 8;
+               buffer[cur_byte] = buffer_read();
        }
 
-       buffer[cur_byte] = 0x0;
-
-       /* There is one more partial byte left from the clock data in/out instructions */
+       /* Manage partial byte left from the clock data in/out instructions, if any */
        if (bits_left > 1)
        {
                buffer[cur_byte] = buffer_read() >> 1;
        }
+       else
+       {
+               buffer[cur_byte] = 0x0;
+       }
        /* This shift depends on the length of the clock data to tms instruction, insterted at end of the scan, now fixed to a two step transition in ft2232_add_scan */
        buffer[cur_byte] = (buffer[cur_byte] | (((buffer_read()) << 1) & 0x80)) >> (8 - bits_left);
 }

Linking to existing account procedure

If you already have an account and want to add another login method you MUST first sign in with your existing account and then change URL to read https://review.openocd.org/login/?link to get to this page again but this time it'll work for linking. Thank you.

SSH host keys fingerprints

1024 SHA256:YKx8b7u5ZWdcbp7/4AeXNaqElP49m6QrwfXaqQGJAOk gerrit-code-review@openocd.zylin.com (DSA)
384 SHA256:jHIbSQa4REvwCFG4cq5LBlBLxmxSqelQPem/EXIrxjk gerrit-code-review@openocd.org (ECDSA)
521 SHA256:UAOPYkU9Fjtcao0Ul/Rrlnj/OsQvt+pgdYSZ4jOYdgs gerrit-code-review@openocd.org (ECDSA)
256 SHA256:A13M5QlnozFOvTllybRZH6vm7iSt0XLxbA48yfc2yfY gerrit-code-review@openocd.org (ECDSA)
256 SHA256:spYMBqEYoAOtK7yZBrcwE8ZpYt6b68Cfh9yEVetvbXg gerrit-code-review@openocd.org (ED25519)
+--[ED25519 256]--+
|=..              |
|+o..   .         |
|*.o   . .        |
|+B . . .         |
|Bo. = o S        |
|Oo.+ + =         |
|oB=.* = . o      |
| =+=.+   + E     |
|. .=o   . o      |
+----[SHA256]-----+
2048 SHA256:0Onrb7/PHjpo6iVZ7xQX2riKN83FJ3KGU0TvI0TaFG4 gerrit-code-review@openocd.zylin.com (RSA)