#ifdef _DEBUG_JTAG_IO_
LOG_DEBUG("end_state: %i", cmd->cmd.end_state->end_state);
#endif
- if (cmd->cmd.end_state->end_state != -1)
+ if (cmd->cmd.end_state->end_state != TAP_INVALID)
usbprog_end_state(cmd->cmd.end_state->end_state);
break;
case JTAG_RESET:
#ifdef _DEBUG_JTAG_IO_
LOG_DEBUG("runtest %i cycles, end in %i", cmd->cmd.runtest->num_cycles, cmd->cmd.runtest->end_state);
#endif
- if (cmd->cmd.runtest->end_state != -1)
+ if (cmd->cmd.runtest->end_state != TAP_INVALID)
usbprog_end_state(cmd->cmd.runtest->end_state);
usbprog_runtest(cmd->cmd.runtest->num_cycles);
break;
#ifdef _DEBUG_JTAG_IO_
LOG_DEBUG("statemove end in %i", cmd->cmd.statemove->end_state);
#endif
- if (cmd->cmd.statemove->end_state != -1)
+ if (cmd->cmd.statemove->end_state != TAP_INVALID)
usbprog_end_state(cmd->cmd.statemove->end_state);
usbprog_state_move();
break;
#ifdef _DEBUG_JTAG_IO_
LOG_DEBUG("scan end in %i", cmd->cmd.scan->end_state);
#endif
- if (cmd->cmd.scan->end_state != -1)
+ if (cmd->cmd.scan->end_state != TAP_INVALID)
usbprog_end_state(cmd->cmd.scan->end_state);
scan_size = jtag_build_buffer(cmd->cmd.scan, &buffer);
type = jtag_scan_type(cmd->cmd.scan);
int num_states = cmd->num_states;
int state_count;
+ /* There may be queued transitions, and before following a specified
+ path, we must flush those queued transitions */
+ usbprog_jtag_tms_send(usbprog_jtag_handle);
+
state_count = 0;
while (num_states)
{
- if (tap_state_transition(tap_get_state(), FALSE) == cmd->path[state_count])
+ if (tap_state_transition(tap_get_state(), false) == cmd->path[state_count])
{
/* LOG_INFO("1"); */
usbprog_write(0, 0, 0);
usbprog_write(1, 0, 0);
}
- else if (tap_state_transition(tap_get_state(), TRUE) == cmd->path[state_count])
+ else if (tap_state_transition(tap_get_state(), true) == cmd->path[state_count])
{
/* LOG_INFO("2"); */
usbprog_write(0, 1, 0);
usbprog_write(0, 0, 0);
}
+#ifdef _DEBUG_JTAG_IO_
+ LOG_DEBUG("runtest: cur_state %s end_state %s", tap_state_name(tap_get_state()), tap_state_name(tap_get_end_state()));
+#endif
+
/* finish in end_state */
/*
usbprog_end_state(saved_end_state);
else
usbprog_end_state(TAP_DRSHIFT);
- /* usbprog_jtag_tms_send(usbprog_jtag_handle); */
+ /* Only move if we're not already there */
+ if (tap_get_state() != tap_get_end_state())
+ usbprog_state_move();
- usbprog_state_move();
usbprog_end_state(saved_end_state);
usbprog_jtag_tms_send(usbprog_jtag_handle);
- if (type == SCAN_OUT)
- {
- usbprog_jtag_write_tdi(usbprog_jtag_handle,buffer, scan_size);
- }
- if (type == SCAN_IN)
- {
- usbprog_jtag_read_tdo(usbprog_jtag_handle,buffer, scan_size);
- }
- if (type == SCAN_IO)
- {
- usbprog_jtag_write_and_read(usbprog_jtag_handle,buffer, scan_size);
+ void (*f)(struct usbprog_jtag *usbprog_jtag, char * buffer, int size);
+ switch (type) {
+ case SCAN_OUT: f = &usbprog_jtag_write_tdi; break;
+ case SCAN_IN: f = &usbprog_jtag_read_tdo; break;
+ case SCAN_IO: f = &usbprog_jtag_write_and_read; break;
+ default:
+ LOG_ERROR("unknown scan type: %i", type);
+ exit(-1);
}
+ f(usbprog_jtag_handle, (char *)buffer, scan_size);
+ /* The adapter does the transition to PAUSE internally */
if (ir_scan)
tap_set_state(TAP_IRPAUSE);
else