allow people to control the interface on the command line with ftdi cables (work by Ian)

git-svn-id: https://urjtag.svn.sourceforge.net/svnroot/urjtag/trunk@1872 b68d4a1b-bc3d-0410-92ed-d4ac073336b7
master
Mike Frysinger 13 years ago
parent 10fdc4be5d
commit f589c5e38c

@ -1,3 +1,14 @@
2011-02-09 Mike Frysinger <vapier@gentoo.org>
* include/urjtag/usbconn.h (urj_usbconn_cable_t): Add an "interface" member.
* include/urjtag/cable.h (URJ_CABLE_PARAM_KEY_INTERFACE): New key for ftdi.
* src/tap/cable.c (cable_param): Handle new "interface" key.
* src/tap/cable/generic_usbconn.c (urj_tap_cable_generic_usbconn_connect):
Parse new "interface" cable parameter.
* src/tap/usbconn/libftd2xx.c: Use new "interface" selection.
* src/tap/usbconn/libftdi.c: Likewise.
* sysdep.h: Auto undefine "interface" for Windows.
2011-02-06 Mike Frysinger <vapier@gentoo.org>
* src/tap/cable_list.h: Add usbjtagrs232.

@ -63,6 +63,7 @@ typedef enum URJ_CABLE_PARAM_KEY
URJ_CABLE_PARAM_KEY_TDO, /* lu gpio used as TDO */
URJ_CABLE_PARAM_KEY_TMS, /* lu gpio used as TMS */
URJ_CABLE_PARAM_KEY_TCK, /* lu gpio used as TCK */
URJ_CABLE_PARAM_KEY_INTERFACE, /* lu ftdi */
}
urj_cable_param_key_t;

@ -38,6 +38,7 @@ typedef struct
const char *driver;
int32_t vid;
int32_t pid;
int32_t interface;
}
urj_usbconn_cable_t;

@ -672,6 +672,7 @@ static const urj_param_descr_t cable_param[] =
{ URJ_CABLE_PARAM_KEY_TDO, URJ_PARAM_TYPE_LU, "tdo", },
{ URJ_CABLE_PARAM_KEY_TMS, URJ_PARAM_TYPE_LU, "tms", },
{ URJ_CABLE_PARAM_KEY_TCK, URJ_PARAM_TYPE_LU, "tck", },
{ URJ_CABLE_PARAM_KEY_INTERFACE, URJ_PARAM_TYPE_LU, "interface", },
};
const urj_param_list_t urj_cable_param_list =

@ -51,6 +51,7 @@ urj_tap_cable_generic_usbconn_connect (urj_cable_t *cable,
NULL, /* no specific driver */
-1, /* no VID */
-1, /* no PID */
0, /* default interface */
};
urj_tap_cable_generic_params_t *cable_params;
@ -80,6 +81,9 @@ urj_tap_cable_generic_usbconn_connect (urj_cable_t *cable,
case URJ_CABLE_PARAM_KEY_DRIVER:
user_specified.driver = params[i]->value.string;
break;
case URJ_CABLE_PARAM_KEY_INTERFACE:
user_specified.interface = params[i]->value.lu;
break;
default:
// hand these to the driver connect()
break;
@ -114,6 +118,8 @@ urj_tap_cable_generic_usbconn_connect (urj_cable_t *cable,
cable_try.pid = user_specified.pid;
if (user_specified.desc != 0)
cable_try.desc = user_specified.desc;
if (user_specified.interface != 0)
cable_try.interface = user_specified.interface;
conn = urj_tap_usbconn_drivers[i]->connect (&cable_try,
params);

@ -36,6 +36,7 @@
#include <urjtag/error.h>
#include <urjtag/log.h>
#include <urjtag/usbconn.h>
#include <urjtag/cable.h>
#include "libftdx.h"
#include "../usbconn.h"
@ -50,6 +51,7 @@ typedef struct
unsigned int pid;
FT_HANDLE fc;
char *serial;
unsigned int interface;
/* send and receive buffer handling */
uint32_t send_buf_len;
uint32_t send_buffered;
@ -331,6 +333,7 @@ usbconn_ftd2xx_connect (urj_usbconn_cable_t *template,
p->fc = NULL;
p->pid = template->pid;
p->vid = template->vid;
p->interface = template->interface;
/* @@@@ RFHH check strdup result */
p->serial = template->desc ? strdup (template->desc) : NULL;
@ -395,7 +398,7 @@ usbconn_ftd2xx_common_open (urj_usbconn_t *conn, urj_log_level_t ll)
}
else
/* give it a plain try */
status = FT_Open (0, &p->fc);
status = FT_Open (p->interface, &p->fc);
if (status != FT_OK)
{

@ -36,6 +36,7 @@
#include <urjtag/error.h>
#include <urjtag/log.h>
#include <urjtag/usbconn.h>
#include <urjtag/cable.h>
#include "libftdx.h"
#include "../usbconn.h"
@ -46,6 +47,8 @@ typedef struct
unsigned int pid;
struct ftdi_context *fc;
char *serial;
/* ftdi interface selection */
unsigned int interface;
/* send and receive buffer handling */
uint32_t send_buf_len;
uint32_t send_buffered;
@ -310,6 +313,7 @@ usbconn_ftdi_connect (urj_usbconn_cable_t *template,
p->fc = fc;
p->pid = template->pid;
p->vid = template->vid;
p->interface = template->interface;
/* @@@@ RFHH check strdup result */
p->serial = template->desc ? strdup (template->desc) : NULL;

@ -56,6 +56,11 @@
#define mkdir(path, mode) mkdir(path)
#endif
/* Some Windows code likes to define this, so undo it here */
#ifdef interface
#undef interface
#endif
#ifndef HAVE_GETEUID
#define geteuid() 0
#endif

Loading…
Cancel
Save