ftdipp_mpsse: store cable configuration

This commit is contained in:
Gwenhael Goavec-Merou 2020-10-27 20:27:02 +01:00
parent 4dde89e082
commit b3a67f896f
5 changed files with 13 additions and 14 deletions

View File

@ -68,8 +68,7 @@ void FtdiJtagBitBang::init_internal(const FTDIpp_MPSSE::mpsse_bit_config &cable,
_in_buf = (unsigned char *)malloc(sizeof(unsigned char) * _buffer_size); _in_buf = (unsigned char *)malloc(sizeof(unsigned char) * _buffer_size);
memset(_in_buf, 0, _buffer_size); memset(_in_buf, 0, _buffer_size);
init(1, _tck_pin | _tms_pin | _tdi_pin, BITMODE_BITBANG, init(1, _tck_pin | _tms_pin | _tdi_pin, BITMODE_BITBANG);
(FTDIpp_MPSSE::mpsse_bit_config &)cable);
setBitmode(BITMODE_BITBANG); setBitmode(BITMODE_BITBANG);
} }

View File

@ -94,7 +94,7 @@ void FtdiJtagMPSSE::init_internal(const FTDIpp_MPSSE::mpsse_bit_config &cable)
display("%x\n", cable.bit_high_val); display("%x\n", cable.bit_high_val);
display("%x\n", cable.bit_high_dir); display("%x\n", cable.bit_high_dir);
init(5, 0xfb, BITMODE_MPSSE, (FTDIpp_MPSSE::mpsse_bit_config &)cable); init(5, 0xfb, BITMODE_MPSSE);
} }
int FtdiJtagMPSSE::writeTMS(uint8_t *tms, int len, bool flush_buffer) int FtdiJtagMPSSE::writeTMS(uint8_t *tms, int len, bool flush_buffer)

View File

@ -21,7 +21,7 @@ using namespace std;
FTDIpp_MPSSE::FTDIpp_MPSSE(const mpsse_bit_config &cable, const string &dev, FTDIpp_MPSSE::FTDIpp_MPSSE(const mpsse_bit_config &cable, const string &dev,
const std::string &serial, uint32_t clkHZ, bool verbose): const std::string &serial, uint32_t clkHZ, bool verbose):
_verbose(verbose), _vid(0), _verbose(verbose), _cable(cable), _vid(0),
_pid(0), _bus(-1), _addr(-1), _pid(0), _bus(-1), _addr(-1),
_interface(cable.interface), _interface(cable.interface),
_clkHZ(clkHZ), _buffer_size(2*32768), _num(0) _clkHZ(clkHZ), _buffer_size(2*32768), _num(0)
@ -134,8 +134,7 @@ int FTDIpp_MPSSE::close_device()
int FTDIpp_MPSSE::init(unsigned char latency, unsigned char bitmask_mode, int FTDIpp_MPSSE::init(unsigned char latency, unsigned char bitmask_mode,
unsigned char mode, unsigned char mode)
mpsse_bit_config & bit_conf)
{ {
unsigned char buf_cmd[6] = { SET_BITS_LOW, 0, 0, unsigned char buf_cmd[6] = { SET_BITS_LOW, 0, 0,
SET_BITS_HIGH, 0, 0 SET_BITS_HIGH, 0, 0
@ -172,11 +171,11 @@ int FTDIpp_MPSSE::init(unsigned char latency, unsigned char bitmask_mode,
if (setClkFreq(_clkHZ, 0) < 0) if (setClkFreq(_clkHZ, 0) < 0)
return -1; return -1;
buf_cmd[1] = bit_conf.bit_low_val; // 0xe8; buf_cmd[1] = _cable.bit_low_val; // 0xe8;
buf_cmd[2] = bit_conf.bit_low_dir; // 0xeb; buf_cmd[2] = _cable.bit_low_dir; // 0xeb;
buf_cmd[4] = bit_conf.bit_high_val; // 0x00; buf_cmd[4] = _cable.bit_high_val; // 0x00;
buf_cmd[5] = bit_conf.bit_high_dir; // 0x60; buf_cmd[5] = _cable.bit_high_dir; // 0x60;
mpsse_store(buf_cmd, 6); mpsse_store(buf_cmd, 6);
mpsse_write(); mpsse_write();
} }

View File

@ -19,8 +19,8 @@ class FTDIpp_MPSSE {
const std::string &serial, uint32_t clkHZ, bool verbose = false); const std::string &serial, uint32_t clkHZ, bool verbose = false);
~FTDIpp_MPSSE(); ~FTDIpp_MPSSE();
int init(unsigned char latency, unsigned char bitmask_mode, unsigned char mode, int init(unsigned char latency, unsigned char bitmask_mode,
mpsse_bit_config &bit_conf); unsigned char mode);
int setClkFreq(uint32_t clkHZ); int setClkFreq(uint32_t clkHZ);
int setClkFreq(uint32_t clkHZ, char use_divide_by_5); int setClkFreq(uint32_t clkHZ, char use_divide_by_5);
@ -39,6 +39,7 @@ class FTDIpp_MPSSE {
unsigned int udevstufftoint(const char *udevstring, int base); unsigned int udevstufftoint(const char *udevstring, int base);
bool search_with_dev(const std::string &device); bool search_with_dev(const std::string &device);
bool _verbose; bool _verbose;
mpsse_bit_config _cable;
private: private:
int _vid; int _vid;
int _pid; int _pid;

View File

@ -72,7 +72,7 @@ FtdiSpi::FtdiSpi(int vid, int pid, unsigned char interface, uint32_t clkHZ,
setCSmode(SPI_CS_AUTO); setCSmode(SPI_CS_AUTO);
setEndianness(SPI_MSB_FIRST); setEndianness(SPI_MSB_FIRST);
init(1, 0x00, BITMODE_MPSSE, bit_conf); init(1, 0x00, BITMODE_MPSSE);
} }
FtdiSpi::FtdiSpi(const FTDIpp_MPSSE::mpsse_bit_config &conf, uint32_t clkHZ, FtdiSpi::FtdiSpi(const FTDIpp_MPSSE::mpsse_bit_config &conf, uint32_t clkHZ,
@ -83,7 +83,7 @@ FtdiSpi::FtdiSpi(const FTDIpp_MPSSE::mpsse_bit_config &conf, uint32_t clkHZ,
setCSmode(SPI_CS_AUTO); setCSmode(SPI_CS_AUTO);
setEndianness(SPI_MSB_FIRST); setEndianness(SPI_MSB_FIRST);
init(1, 0x00, BITMODE_MPSSE, bit_conf); init(1, 0x00, BITMODE_MPSSE);
} }
FtdiSpi::~FtdiSpi() FtdiSpi::~FtdiSpi()