+
+
+static int ft2232_stableclocks(int num_cycles, jtag_command_t *cmd)
+{
+ int retval = 0;
+
+ while (num_cycles > 0)
+ {
+ /* the command 0x4b, "Clock Data to TMS/CS Pin (no Read)" handles
+ * at most 7 bits per invocation. Here we invoke it potentially
+ * several times.
+ */
+ int bitcount_per_command = (num_cycles > 7) ? 7 : num_cycles;
+
+ if (ft2232_buffer_size + 3 >= FT2232_BUFFER_SIZE)
+ {
+ if (ft2232_send_and_recv(first_unsent, cmd) != ERROR_OK)
+ retval = ERROR_JTAG_QUEUE_FAILED;
+
+ first_unsent = cmd;
+ }
+
+ /* command "Clock Data to TMS/CS Pin (no Read)" */
+ BUFFER_ADD = 0x4b;
+
+ /* scan 7 bit */
+ BUFFER_ADD = bitcount_per_command - 1;
+
+ /* TMS data bits are all zeros to stay in the current stable state */
+ BUFFER_ADD = 0x0;
+
+ require_send = 1;
+
+ num_cycles -= bitcount_per_command;
+ }
+
+ return retval;
+}
+