Merge pull request #231 from rarengifoArthrex/add_cable_index

add means to set cable index from command line
This commit is contained in:
Gwenhael Goavec-Merou 2022-06-02 07:05:35 +02:00 committed by GitHub
commit 5d978b7105
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 3 deletions

View File

@ -29,7 +29,7 @@ using namespace std;
FTDIpp_MPSSE::FTDIpp_MPSSE(const mpsse_bit_config &cable, const string &dev,
const std::string &serial, uint32_t clkHZ, int8_t verbose):
_verbose(verbose > 2), _cable(cable), _vid(0),
_pid(0), _bus(-1), _addr(-1),
_pid(0), _index(0), _bus(-1), _addr(-1),
_interface(cable.interface),
_clkHZ(clkHZ), _buffer_size(2*32768), _num(0)
{
@ -45,6 +45,7 @@ FTDIpp_MPSSE::FTDIpp_MPSSE(const mpsse_bit_config &cable, const string &dev,
} else {
_vid = cable.vid;
_pid = cable.pid;
_index = cable.index;
}
open_device(serial, 115200);
@ -135,7 +136,7 @@ void FTDIpp_MPSSE::open_device(const std::string &serial, unsigned int baudrate)
}
if (_bus == -1 || _addr == -1)
ret = ftdi_usb_open_desc(_ftdi, _vid, _pid, NULL, serial.empty() ? NULL : serial.c_str());
ret = ftdi_usb_open_desc_index(_ftdi, _vid, _pid, NULL, serial.empty() ? NULL : serial.c_str(), _index);
else
#if (FTDI_VERSION < 104)
ret = ftdi_usb_open_desc(_ftdi, _vid, _pid, _product, NULL);

View File

@ -18,6 +18,7 @@ class FTDIpp_MPSSE {
int bit_low_dir;
int bit_high_val;
int bit_high_dir;
int index;
} mpsse_bit_config;
FTDIpp_MPSSE(const mpsse_bit_config &cable, const std::string &dev,
@ -71,6 +72,7 @@ class FTDIpp_MPSSE {
mpsse_bit_config _cable;
int _vid;
int _pid;
int _index;
private:
int _bus;
int _addr;

View File

@ -64,6 +64,7 @@ struct arguments {
int16_t altsetting;
uint16_t vid;
uint16_t pid;
uint16_t cable_index;
string ip_adr;
uint32_t protect_flash;
bool unprotect_flash;
@ -85,7 +86,7 @@ int main(int argc, char **argv)
/* command line args. */
struct arguments args = {0, false, false, false, 0, "", "", "-", "", -1,
0, false, "-", false, false, false, false, Device::PRG_NONE, false,
false, false, "", "", "", -1, 0, false, -1, 0, 0, "127.0.0.1",
false, false, "", "", "", -1, 0, false, -1, 0, 0, 0, "127.0.0.1",
0, false, "", false, false};
/* parse arguments */
try {
@ -198,6 +199,9 @@ int main(int argc, char **argv)
cable.config.pid = args.pid;
}
// always set this
cable.config.index = args.cable_index;
/* FLASH direct access */
if (args.spi || (board && board->mode == COMM_SPI)) {
/* if no instruction from user -> select flash mode */
@ -590,6 +594,7 @@ int parse_opt(int argc, char **argv, struct arguments *args, jtag_pins_conf_t *p
cxxopts::value<bool>(args->invert_read_edge))
("vid", "probe Vendor ID", cxxopts::value<uint16_t>(args->vid))
("pid", "probe Product ID", cxxopts::value<uint16_t>(args->pid))
("cable-index", "probe index", cxxopts::value<uint16_t>(args->cable_index))
("ftdi-serial", "FTDI chip serial number", cxxopts::value<string>(args->ftdi_serial))
("ftdi-channel", "FTDI chip channel number (channels 0-3 map to A-D)", cxxopts::value<int>(args->ftdi_channel))