- // need a new VSLLINK_CMDJTAGSEQ_TMSBYTE command
- // if vsllink_tms_data_len > 0, length of VSLLINK_CMDJTAGSEQ_TMSBYTE MUST be > 1(tms_len > 2)
- *vsllink_tms_cmd_pos--;
- vsllink_add_path(vsllink_tms_data_len, 8 - vsllink_tms_data_len, path);
- vsllink_usb_out_buffer_idx++;
- vsllink_tap_ensure_space(0, 3);
- vsllink_usb_out_buffer[vsllink_usb_out_buffer_idx++] = VSLLINK_CMDJTAGSEQ_TMSBYTE | 1;
- vsllink_tms_cmd_pos = vsllink_usb_out_buffer + vsllink_usb_out_buffer_idx;
- vsllink_add_path(vsllink_tms_data_len, num_states + vsllink_tms_data_len - 8, path + 8 - vsllink_tms_data_len);
+ // end last tms shift command
+ (*vsllink_tms_cmd_pos)--;
+ vsllink_add_path(vsllink_tms_data_len, num_states, path);
+ }
+ else if (tms_len < 16)
+ {
+ if ((*vsllink_tms_cmd_pos & VSLLINK_CMDJTAGSEQ_LENMSK) < VSLLINK_CMDJTAGSEQ_LENMSK)
+ {
+ // every tms shift command can contain VSLLINK_CMDJTAGSEQ_LENMSK + 1 bytes in most
+ // there is enought tms length in the current tms shift command
+ (*vsllink_tms_cmd_pos)++;
+ vsllink_add_path(vsllink_tms_data_len, num_states, path);
+ }
+ else
+ {
+ // every tms shift command can contain VSLLINK_CMDJTAGSEQ_LENMSK + 1 bytes in most
+ // not enough tms length in the current tms shift command
+ // so a new command should be added
+ // first decrease byte length of last tms shift command
+ (*vsllink_tms_cmd_pos)--;
+ // append tms data to the last tms byte
+ vsllink_add_path(vsllink_tms_data_len, 8 - vsllink_tms_data_len, path);
+ path += 8 - vsllink_tms_data_len;
+ // add new command(3 bytes)
+ vsllink_tap_ensure_space(0, 3);
+ vsllink_tms_cmd_pos = &vsllink_usb_out_buffer[vsllink_usb_out_buffer_idx];
+ vsllink_usb_out_buffer[vsllink_usb_out_buffer_idx++] = VSLLINK_CMDJTAGSEQ_TMSBYTE | 1;
+ vsllink_add_path(0, num_states - (8 - vsllink_tms_data_len), path);
+ }
+ }
+ else if (tms_len == 16)
+ {
+ // end last tms shift command
+ vsllink_add_path(vsllink_tms_data_len, num_states, path);