Skip to content

Commit

Permalink
libftdi 1.2 -> 1.4, output libftdi version
Browse files Browse the repository at this point in the history
  • Loading branch information
lorf committed Mar 31, 2018
1 parent 08006a8 commit 1f342f2
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 7 deletions.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -406,14 +406,14 @@ Download [precompiled libusb for
windows](http://sourceforge.net/projects/libusb/files/) and extract it to the
libusb directory:

wget https://sourceforge.net/projects/libusb/files/libusb-1.0/libusb-1.0.20/libusb-1.0.20.7z
7z x -olibusb libusb-1.0.20.7z
wget https://sourceforge.net/projects/libusb/files/libusb-1.0/libusb-1.0.22/libusb-1.0.22.7z
7z x -olibusb libusb-1.0.22.7z

Build [libftdi](http://www.intra2net.com/en/developer/libftdi/) from source:

wget http://www.intra2net.com/en/developer/libftdi/download/libftdi1-1.2.tar.bz2
tar xjvf libftdi1-1.2.tar.bz2
cd libftdi1-1.2
wget http://www.intra2net.com/en/developer/libftdi/download/libftdi1-1.4.tar.bz2
tar xjvf libftdi1-1.4.tar.bz2
cd libftdi1-1.4
cmake -DCMAKE_TOOLCHAIN_FILE=cmake/Toolchain-i686-w64-mingw32.cmake \
-DLIBUSB_INCLUDE_DIR=../libusb/include/libusb-1.0 \
-DLIBUSB_LIBRARIES="-L../../libusb/MinGW32/static -lusb-1.0" \
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.5.3-a4
0.5.3-a5
12 changes: 11 additions & 1 deletion spi.c
Original file line number Diff line number Diff line change
Expand Up @@ -551,6 +551,8 @@ int spi_set_interface(const char *intf)

int spi_init(void)
{
struct ftdi_version_info fv;

LOG(DEBUG, "spi_nrefs=%d, spi_dev_open=%d", spi_nrefs, spi_dev_open);

spi_nrefs++;
Expand All @@ -560,7 +562,10 @@ int spi_init(void)
return 0;
}

LOG(ALL, "csr-spi-ftdi " VERSION ", git rev " GIT_REVISION);
fv = ftdi_get_library_version();
LOG(ALL, "csr-spi-ftdi " VERSION ", git rev " GIT_REVISION ", libftdi %s-%s",
fv.version_str, fv.snapshot_str);


if (ftdi_init(&ftdic) < 0) {
SPI_ERR("FTDI: init failed");
Expand Down Expand Up @@ -879,6 +884,7 @@ int spi_isopen(void)
#ifdef SPI_STATS
void spi_output_stats(void)
{
struct ftdi_version_info fv;
double xfer_pct = NAN, avg_read = NAN, avg_write = NAN, rate = NAN, iops = NAN;
double ftdi_rate = NAN, ftdi_xfers_per_io = NAN, avg_ftdi_xfer = NAN, ftdi_short_rate = NAN;
struct timeval tv;
Expand All @@ -889,6 +895,8 @@ void spi_output_stats(void)
if (!fp)
return;

fv = ftdi_get_library_version();

/* Calculate timeranges until now */
if (gettimeofday(&tv, NULL) < 0)
LOG(WARN, "gettimeofday failed: %s", strerror(errno));
Expand Down Expand Up @@ -936,6 +944,7 @@ void spi_output_stats(void)
fprintf(fp,
"*** FTDI Statistics ********************************************************\n"
"csr-spi-ftdi version: " VERSION " (git rev " GIT_REVISION ")\n"
"libftdi version: %s-%s\n"
"Time open: %ld.%02ld s\n"
"Time in xfer: %ld.%02ld s (%.2f%% of open time)\n"
"Reads: %ld (%ld bytes, %.2f bytes avg read size)\n"
Expand All @@ -948,6 +957,7 @@ void spi_output_stats(void)
" %.2f xfers/IO, %.2f bytes/xfer)\n"
"SPI max clock: %lu kHz, min clock: %lu kHz, slowdowns: %lu\n"
"****************************************************************************\n",
fv.version_str, fv.snapshot_str,
spi_stats.tv_open.tv_sec, spi_stats.tv_open.tv_usec / 10000,
spi_stats.tv_xfer.tv_sec, spi_stats.tv_xfer.tv_usec / 10000, xfer_pct,
spi_stats.reads, spi_stats.read_bytes, avg_read,
Expand Down

0 comments on commit 1f342f2

Please sign in to comment.