From 14ba5b7666dd349b24b6ac1040101431357d6cb1 Mon Sep 17 00:00:00 2001 From: Rene Liebscher Date: Wed, 15 Aug 2012 17:31:11 +0000 Subject: [PATCH] bug #30559 Ft232 bit-bang support, see comment #30 * ft245r.c: added semaphore workaround for MacOS X, added pthread_testcancel in reader thread * configure.ac: added check for TYPE_232H in libftdi (not in libftdi < 0.20) * avrftdi.c: do not use TYPE_232H if not declared git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@1101 81a1dc3b-b13d-400b-aceb-764788c761c2 --- avrdude/ChangeLog | 9 +++++++++ avrdude/avrftdi.c | 2 ++ avrdude/configure.ac | 6 ++++++ avrdude/ft245r.c | 13 +++++++++++++ 4 files changed, 30 insertions(+) diff --git a/avrdude/ChangeLog b/avrdude/ChangeLog index d9b66c44..29cba157 100644 --- a/avrdude/ChangeLog +++ b/avrdude/ChangeLog @@ -1,3 +1,12 @@ +2012-08-15 Rene Liebscher + + bug #30559 Ft232 bit-bang support, see comment #30 + * ft245r.c: added semaphore workaround for MacOS X, + added pthread_testcancel in reader thread + + * configure.ac: added check for TYPE_232H in libftdi (not in libftdi < 0.20) + * avrftdi.c: do not use TYPE_232H if not declared + 2012-08-13 Hannes Weisbach * avrftdi.c: fixes pin_limit for different FTDI devices (there was a mixup diff --git a/avrdude/avrftdi.c b/avrdude/avrftdi.c index 67f06f98..7546ed85 100644 --- a/avrdude/avrftdi.c +++ b/avrdude/avrftdi.c @@ -774,7 +774,9 @@ static int avrftdi_open(PROGRAMMER * pgm, char *port) pdata->pin_limit = 11; break; case TYPE_2232H: +#ifdef HAVE_LIBFTDI_TYPE_232H case TYPE_232H: +#endif pdata->pin_limit = 15; break; case TYPE_4232H: diff --git a/avrdude/configure.ac b/avrdude/configure.ac index 7d7c96ab..43f6dcd8 100644 --- a/avrdude/configure.ac +++ b/avrdude/configure.ac @@ -147,10 +147,16 @@ fi AC_SUBST(LIBUSB_1_0, $LIBUSB_1_0) AH_TEMPLATE([HAVE_LIBFTDI], [Define if FTDI support is enabled via libftdi]) +AH_TEMPLATE([HAVE_LIBFTDI_TYPE_232H], + [Define if libftdi supports FT232H, libftdi version >= 0.20]) AC_CHECK_LIB([ftdi], [ftdi_usb_get_strings], [have_libftdi=yes], [], [-lusb]) if test x$have_libftdi = xyes; then LIBFTDI="-lftdi -lusb" AC_DEFINE([HAVE_LIBFTDI]) + AC_CHECK_DECL(TYPE_232H,[have_libftdi_FT232H=yes], [], [[#include ]]) + if test x$have_libftdi_FT232H = xyes; then + AC_DEFINE([HAVE_LIBFTDI_TYPE_232H]) + fi fi AC_SUBST(LIBFTDI, $LIBFTDI) AC_CHECK_HEADERS([pthread.h]) diff --git a/avrdude/ft245r.c b/avrdude/ft245r.c index fa4f8f32..e6033a18 100644 --- a/avrdude/ft245r.c +++ b/avrdude/ft245r.c @@ -73,7 +73,19 @@ #ifdef HAVE_PTHREAD_H #include + +#ifdef __APPLE__ +/* Mac OS X defines sem_init but actually does not implement them */ +#include + +typedef dispatch_semaphore_t sem_t; + +#define sem_init(psem,x,val) *psem = dispatch_semaphore_create(val) +#define sem_post(psem) dispatch_semaphore_signal(*psem) +#define sem_wait(psem) dispatch_semaphore_wait(*psem, DISPATCH_TIME_FOREVER) +#else #include +#endif #ifdef HAVE_LIBFTDI @@ -130,6 +142,7 @@ static void *reader (void *arg) { int br, i; while (1) { + pthread_testcancel(); br = ftdi_read_data (handle, buf, sizeof(buf)); for (i=0; i