openocd/src/jtag/drivers/libftdi_helper.h
Antonio Borneo 5bb0f6befb openocd: add support for libftdi 1.5
The new libftdi 1.5 (2020-07-07) changes some API, deprecating the
old ones. This cause a warning at compile time.

Detect in configure the version of libftdi.
Use the new API in the driver's code.
Add an helper include file 'libftdi_helper.h' that wraps the old
API for backward compatibility with old libftdi.

Change-Id: I7800fbebe17dd0ce62e55b3598d8c08be8875bb7
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Fixes: https://sourceforge.net/p/openocd/tickets/286/
Reviewed-on: http://openocd.zylin.com/5891
Tested-by: jenkins
2020-11-04 17:38:45 +00:00

28 lines
612 B
C

/* SPDX-License-Identifier: GPL-2.0-or-later */
#ifndef OPENOCD_JTAG_DRIVERS_LIBFTDI_HELPER_H
#define OPENOCD_JTAG_DRIVERS_LIBFTDI_HELPER_H
#include <ftdi.h>
#ifndef HAVE_LIBFTDI_TCIOFLUSH
/* Backward compatibility with libftdi pre 1.5 */
static inline int ftdi_tciflush(struct ftdi_context *ftdi)
{
return ftdi_usb_purge_rx_buffer(ftdi);
}
static inline int ftdi_tcoflush(struct ftdi_context *ftdi)
{
return ftdi_usb_purge_tx_buffer(ftdi);
}
static inline int ftdi_tcioflush(struct ftdi_context *ftdi)
{
return ftdi_usb_purge_buffers(ftdi);
}
#endif
#endif /* OPENOCD_JTAG_DRIVERS_LIBFTDI_HELPER_H */