X-Git-Url: http://developer.intra2net.com/git/?p=libftdi;a=blobdiff_plain;f=src%2Fftdi_stream.c;h=cf3acf57305124bab4ebcce74451ebf1ac1a4c89;hp=6c40327b93f3252e3f46a23d700e0e4f28dea824;hb=fec556672a91df346f79ab3727b556ace25dff0d;hpb=889d9bb6786a03dfcd881a793beeb35c70590434 diff --git a/src/ftdi_stream.c b/src/ftdi_stream.c index 6c40327..cf3acf5 100644 --- a/src/ftdi_stream.c +++ b/src/ftdi_stream.c @@ -41,6 +41,7 @@ #include #include +#include #include "ftdi.h" @@ -73,7 +74,7 @@ ftdi_readstream_cb(struct libusb_transfer *transfer) uint8_t *ptr = transfer->buffer; int length = transfer->actual_length; int numPackets = (length + packet_size - 1) / packet_size; - int res; + int res = 0; for (i = 0; i < numPackets; i++) { @@ -152,7 +153,28 @@ ftdi_readstream(struct ftdi_context *ftdi, int bufferSize = packetsPerTransfer * ftdi->max_packet_size; int xferIndex; int err = 0; + + /* Only FT2232H and FT232H know about the synchronous FIFO Mode*/ + if ((ftdi->type != TYPE_2232H) && (ftdi->type != TYPE_232H)) + { + fprintf(stderr,"Device doesn't support synchronous FIFO mode\n"); + return 1; + } + /* We don't know in what state we are, switch to reset*/ + if (ftdi_set_bitmode(ftdi, 0xff, BITMODE_RESET) < 0) + { + fprintf(stderr,"Can't reset mode\n"); + return 1; + } + + /* Purge anything remaining in the buffers*/ + if (ftdi_usb_purge_buffers(ftdi) < 0) + { + fprintf(stderr,"Can't Purge\n"); + return 1; + } + /* * Set up all transfers */