mirror of
https://github.com/trabucayre/openFPGALoader.git
synced 2026-08-30 09:59:03 +02:00
always pass cable configuration. Check if /dev if empty or not
This commit is contained in:
+19
-9
@@ -18,14 +18,20 @@ using namespace std;
|
||||
#define display(...) \
|
||||
do { if (_verbose) fprintf(stdout, __VA_ARGS__);}while(0)
|
||||
|
||||
FTDIpp_MPSSE::FTDIpp_MPSSE(const string &dev, unsigned char interface,
|
||||
FTDIpp_MPSSE::FTDIpp_MPSSE(const mpsse_bit_config &cable, const string &dev,
|
||||
uint32_t clkHZ, bool verbose):_verbose(verbose), _vid(0),
|
||||
_pid(0), _bus(-1), _addr(-1), _product(""), _interface(interface),
|
||||
_pid(0), _bus(-1), _addr(-1), _product(""),
|
||||
_interface(cable.interface),
|
||||
_clkHZ(clkHZ), _buffer_size(2*32768), _num(0)
|
||||
{
|
||||
if (!search_with_dev(dev)) {
|
||||
cerr << "No cable found" << endl;
|
||||
throw std::exception();
|
||||
if (!dev.empty()) {
|
||||
if (!search_with_dev(dev)) {
|
||||
cerr << "No cable found" << endl;
|
||||
throw std::exception();
|
||||
}
|
||||
} else {
|
||||
_vid = cable.vid;
|
||||
_pid = cable.pid;
|
||||
}
|
||||
|
||||
open_device(115200);
|
||||
@@ -38,10 +44,10 @@ FTDIpp_MPSSE::FTDIpp_MPSSE(const string &dev, unsigned char interface,
|
||||
}
|
||||
}
|
||||
|
||||
FTDIpp_MPSSE::FTDIpp_MPSSE(int vid, int pid, unsigned char interface,
|
||||
uint32_t clkHZ, bool verbose):_verbose(verbose), _vid(vid),
|
||||
_pid(pid), _bus(-1),
|
||||
_addr(-1), _product(""), _interface(interface),
|
||||
FTDIpp_MPSSE::FTDIpp_MPSSE(const mpsse_bit_config &cable,
|
||||
uint32_t clkHZ, bool verbose):_verbose(verbose),
|
||||
_vid(cable.vid), _pid(cable.pid), _bus(-1),
|
||||
_addr(-1), _product(""), _interface(cable.interface),
|
||||
_clkHZ(clkHZ), _buffer_size(2*32768), _num(0)
|
||||
{
|
||||
open_device(115200);
|
||||
@@ -186,6 +192,9 @@ int FTDIpp_MPSSE::init(unsigned char latency, unsigned char bitmask_mode,
|
||||
mpsse_write();
|
||||
}
|
||||
|
||||
ftdi_read_data_set_chunksize(_ftdi, _buffer_size);
|
||||
ftdi_write_data_set_chunksize(_ftdi, _buffer_size);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -242,6 +251,7 @@ int FTDIpp_MPSSE::setClkFreq(uint32_t clkHZ, char use_divide_by_5)
|
||||
return -1;
|
||||
}
|
||||
ret = ftdi_read_data(_ftdi, buffer, 4);
|
||||
ftdi_usb_purge_buffers(_ftdi);
|
||||
|
||||
return real_freq;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user