#include "config.h"
#endif
-#include "jtag.h"
+#include "interface.h"
+#include "commands.h"
#include <usb.h>
#define TCK_BIT 2
#define TMS_BIT 1
-static int usbprog_execute_queue(void);
-static int usbprog_speed(int speed);
-static int usbprog_register_commands(struct command_context_s *cmd_ctx);
-static int usbprog_init(void);
-static int usbprog_quit(void);
-
static void usbprog_end_state(tap_state_t state);
static void usbprog_state_move(void);
-static void usbprog_path_move(pathmove_command_t *cmd);
+static void usbprog_path_move(struct pathmove_command *cmd);
static void usbprog_runtest(int num_cycles);
-static void usbprog_scan(bool ir_scan, enum scan_type type, u8 *buffer, int scan_size);
-
-jtag_interface_t usbprog_interface =
-{
- .name = "usbprog",
- .execute_queue = usbprog_execute_queue,
- .speed = usbprog_speed,
- .register_commands = usbprog_register_commands,
- .init = usbprog_init,
- .quit = usbprog_quit
-};
+static void usbprog_scan(bool ir_scan, enum scan_type type, uint8_t *buffer, int scan_size);
#define UNKOWN_COMMAND 0x00
#define PORT_DIRECTION 0x01
return ERROR_OK;
}
-static int usbprog_register_commands(struct command_context_s *cmd_ctx)
-{
- return ERROR_OK;
-}
-
static int usbprog_execute_queue(void)
{
- jtag_command_t *cmd = jtag_command_queue; /* currently processed command */
+ struct jtag_command *cmd = jtag_command_queue; /* currently processed command */
int scan_size;
enum scan_type type;
- u8 *buffer;
+ uint8_t *buffer;
while (cmd)
{
#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 != TAP_INVALID)
- usbprog_end_state(cmd->cmd.runtest->end_state);
+ usbprog_end_state(cmd->cmd.runtest->end_state);
usbprog_runtest(cmd->cmd.runtest->num_cycles);
break;
case JTAG_STATEMOVE:
#ifdef _DEBUG_JTAG_IO_
LOG_DEBUG("statemove end in %i", cmd->cmd.statemove->end_state);
#endif
- if (cmd->cmd.statemove->end_state != TAP_INVALID)
- usbprog_end_state(cmd->cmd.statemove->end_state);
+ usbprog_end_state(cmd->cmd.statemove->end_state);
usbprog_state_move();
break;
case JTAG_PATHMOVE:
#ifdef _DEBUG_JTAG_IO_
LOG_DEBUG("scan end in %i", cmd->cmd.scan->end_state);
#endif
- if (cmd->cmd.scan->end_state != TAP_INVALID)
- usbprog_end_state(cmd->cmd.scan->end_state);
+ usbprog_end_state(cmd->cmd.scan->end_state);
scan_size = jtag_build_buffer(cmd->cmd.scan, &buffer);
type = jtag_scan_type(cmd->cmd.scan);
usbprog_scan(cmd->cmd.scan->ir_scan, type, buffer, scan_size);
static void usbprog_state_move(void)
{
int i = 0, tms = 0;
- u8 tms_scan = tap_get_tms_path(tap_get_state(), tap_get_end_state());
+ uint8_t tms_scan = tap_get_tms_path(tap_get_state(), tap_get_end_state());
int tms_count = tap_get_tms_path_len(tap_get_state(), tap_get_end_state());
usbprog_jtag_write_tms(usbprog_jtag_handle, (char)tms_scan);
tap_set_state(tap_get_end_state());
}
-static void usbprog_path_move(pathmove_command_t *cmd)
+static void usbprog_path_move(struct pathmove_command *cmd)
{
int num_states = cmd->num_states;
int state_count;
*/
}
-static void usbprog_scan(bool ir_scan, enum scan_type type, u8 *buffer, int scan_size)
+static void usbprog_scan(bool ir_scan, enum scan_type type, uint8_t *buffer, int scan_size)
{
tap_state_t saved_end_state = tap_get_end_state();
static void usbprog_write(int tck, int tms, int tdi)
{
- unsigned char output_value=0x00;
+ unsigned char output_value = 0x00;
if (tms)
- output_value |= (1<<TMS_BIT);
+ output_value |= (1 << TMS_BIT);
if (tdi)
- output_value |= (1<<TDI_BIT);
+ output_value |= (1 << TDI_BIT);
if (tck)
- output_value |= (1<<TCK_BIT);
+ output_value |= (1 << TCK_BIT);
usbprog_jtag_write_slice(usbprog_jtag_handle,output_value);
}
}
}
}
+ free(tmp);
return 0;
}
{
send_bits = size;
loops = size/8;
- /* if(loops==0) */
+ /* if (loops == 0) */
loops++;
size = 0;
}
tms_chain_index = 0;
}
}
+
+struct jtag_interface usbprog_interface = {
+ .name = "usbprog",
+ .execute_queue = &usbprog_execute_queue,
+ .speed = &usbprog_speed,
+ .init = &usbprog_init,
+ .quit = &usbprog_quit
+ };