])
# Check for specific libusb features, now that we know the CFLAGS.
+# Also check for version dependent libftdi features.
AC_LANG([C])
sr_save_cflags=$CFLAGS
sr_save_libs=$LIBS
[sr_have_libusb_os_handle=yes], [sr_have_libusb_os_handle=no],
[[#include <libusb.h>]])
AC_CHECK_FUNCS([zip_discard])
+AC_CHECK_FUNCS([ftdi_tciflush ftdi_tcoflush ftdi_tcioflush])
LIBS=$sr_save_libs
CFLAGS=$sr_save_cflags
if (ret != SR_OK)
return ret;
g_usleep(10 * 1000);
- ftdi_usb_purge_buffers(&devc->ftdi.ctx);
+ PURGE_FTDI_BOTH(&devc->ftdi.ctx);
/*
* Wait until the FPGA asserts INIT_B. Check in a maximum number
ftdi_get_error_string(&devc->ftdi.ctx));
return SR_ERR;
}
- ftdi_usb_purge_buffers(&devc->ftdi.ctx);
+ PURGE_FTDI_BOTH(&devc->ftdi.ctx);
while (sigma_read_raw(devc, &pins, sizeof(pins)) > 0)
;
goto err_ftdi_free;
}
- if ((ret = ftdi_usb_purge_buffers(devc->ftdic)) < 0) {
+ if ((ret = PURGE_FTDI_BOTH(devc->ftdic)) < 0) {
sr_err("Failed to purge FTDI buffers (%d): %s.",
ret, ftdi_get_error_string(devc->ftdic));
goto err_ftdi_free;
sr_dbg("Purging buffers, resetting+closing FTDI device.");
/* Log errors, but ignore them (i.e., don't abort). */
- if ((ret = ftdi_usb_purge_buffers(devc->ftdic)) < 0)
+ if ((ret = PURGE_FTDI_BOTH(devc->ftdic)) < 0)
sr_err("Failed to purge FTDI buffers (%d): %s.",
ret, ftdi_get_error_string(devc->ftdic));
if ((ret = ftdi_usb_reset(devc->ftdic)) < 0)
goto err_ftdi_free;
}
- ret = ftdi_usb_purge_buffers(devc->ftdic);
+ ret = PURGE_FTDI_BOTH(devc->ftdic);
if (ret < 0) {
sr_err("Failed to purge FTDI RX/TX buffers (%d): %s.",
ret, ftdi_get_error_string(devc->ftdic));
return SR_ERR;
}
- if ((ret = ftdi_usb_purge_buffers(devc->ftdic)) < 0) {
+ if ((ret = PURGE_FTDI_BOTH(devc->ftdic)) < 0) {
sr_err("Failed to purge FTDI RX/TX buffers (%d): %s.",
ret, ftdi_get_error_string(devc->ftdic));
goto err_dev_open_close_ftdic;
return SR_ERR;
}
- if ((ret = ftdi_usb_purge_buffers(devc->ftdic)) < 0) {
+ if ((ret = PURGE_FTDI_BOTH(devc->ftdic)) < 0) {
sr_err("Failed to purge FTDI RX/TX buffers (%d): %s.",
ret, ftdi_get_error_string(devc->ftdic));
goto err_open_close_ftdic;
#ifdef HAVE_LIBUSB_1_0
#include <libusb.h>
#endif
+#ifdef HAVE_LIBFTDI
+#include <ftdi.h>
+#endif
#include <stdarg.h>
#include <stdint.h>
#include <stdio.h>
libusb_handle_events_timeout(ctx, tv)
#endif
+/*
+ * Convenience for FTDI library version dependency.
+ * - Version 1.5 introduced ftdi_tciflush(), ftdi_tcoflush(), and
+ * ftdi_tcioflush() all within the same commit, and deprecated
+ * ftdi_usb_purge_buffers() which suffered from inverse semantics.
+ * The API is drop-in compatible (arguments count and data types are
+ * identical). The libsigrok source code always flushes RX and TX at
+ * the same time, never individually.
+ */
+#if defined HAVE_FTDI_TCIOFLUSH && HAVE_FTDI_TCIOFLUSH
+# define PURGE_FTDI_BOTH ftdi_tcioflush
+#else
+# define PURGE_FTDI_BOTH ftdi_usb_purge_buffers
+#endif
+
/* Static definitions of structs ending with an all-zero entry are a
* problem when compiling with -Wmissing-field-initializers: GCC
* suppresses the warning only with { 0 }, clang wants { } */