Rev Author Line No. Line
3090 miho 1 /*++
2  
3 Copyright (c) 2001-2011 Future Technology Devices International Limited
4  
5 THIS SOFTWARE IS PROVIDED BY FUTURE TECHNOLOGY DEVICES INTERNATIONAL LIMITED "AS IS"
6 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
7 OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
8 FUTURE TECHNOLOGY DEVICES INTERNATIONAL LIMITED BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
9 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
10 OF SUBSTITUTE GOODS OR SERVICES LOSS OF USE, DATA, OR PROFITS OR BUSINESS INTERRUPTION)
11 HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
12 TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
13 EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
14  
15 FTDI DRIVERS MAY BE USED ONLY IN CONJUNCTION WITH PRODUCTS BASED ON FTDI PARTS.
16  
17 FTDI DRIVERS MAY BE DISTRIBUTED IN ANY FORM AS LONG AS LICENSE INFORMATION IS NOT MODIFIED.
18  
19 IF A CUSTOM VENDOR ID AND/OR PRODUCT ID OR DESCRIPTION STRING ARE USED, IT IS THE
20 RESPONSIBILITY OF THE PRODUCT MANUFACTURER TO MAINTAIN ANY CHANGES AND SUBSEQUENT WHQL
21 RE-CERTIFICATION AS A RESULT OF MAKING THESE CHANGES.
22  
23  
24 Module Name:
25  
26 ftd2xx.h
27  
28 Abstract:
29  
30 Native USB device driver for FTDI FT232x, FT245x, FT2232x and FT4232x devices
31 FTD2XX library definitions
32  
33 Environment:
34  
35 user mode
36  
37  
38 --*/
39  
40  
41 #ifndef FTD2XX_H
42 #define FTD2XX_H
43  
44 #ifndef _WINDOWS
45 #include <pthread.h>
46 #define WINAPI
47 #endif
48  
49 // The following ifdef block is the standard way of creating macros
50 // which make exporting from a DLL simpler. All files within this DLL
51 // are compiled with the FTD2XX_EXPORTS symbol defined on the command line.
52 // This symbol should not be defined on any project that uses this DLL.
53 // This way any other project whose source files include this file see
54 // FTD2XX_API functions as being imported from a DLL, whereas this DLL
55 // sees symbols defined with this macro as being exported.
56  
57 #ifdef FTD2XX_EXPORTS
58 #define FTD2XX_API __declspec(dllexport)
59 #else
60 #define FTD2XX_API __declspec(dllimport)
61 #endif
62  
63 #ifndef _WINDOWS
64 #include "WinTypes.h"
65  
66 #ifdef FTD2XX_API
67 #undef FTD2XX_API
68 #define FTD2XX_API
69 #endif
70 #endif
71 typedef struct _EVENT_HANDLE{
72 pthread_cond_t eCondVar;
73 pthread_mutex_t eMutex;
74 int iVar;
75 } EVENT_HANDLE;
76  
77 typedef PVOID FT_HANDLE;
78 typedef ULONG FT_STATUS;
79  
80 //
81 // Device status
82 //
83 enum {
84 FT_OK,
85 FT_INVALID_HANDLE,
86 FT_DEVICE_NOT_FOUND,
87 FT_DEVICE_NOT_OPENED,
88 FT_IO_ERROR,
89 FT_INSUFFICIENT_RESOURCES,
90 FT_INVALID_PARAMETER,
91 FT_INVALID_BAUD_RATE, //7
92  
93 FT_DEVICE_NOT_OPENED_FOR_ERASE,
94 FT_DEVICE_NOT_OPENED_FOR_WRITE,
95 FT_FAILED_TO_WRITE_DEVICE,
96 FT_EEPROM_READ_FAILED,
97 FT_EEPROM_WRITE_FAILED,
98 FT_EEPROM_ERASE_FAILED,
99 FT_EEPROM_NOT_PRESENT,
100 FT_EEPROM_NOT_PROGRAMMED,
101 FT_INVALID_ARGS,
102 FT_NOT_SUPPORTED,
103 FT_OTHER_ERROR
104 };
105  
106  
107 #define FT_SUCCESS(status) ((status) == FT_OK)
108  
109 //
110 // FT_OpenEx Flags
111 //
112  
113 #define FT_OPEN_BY_SERIAL_NUMBER 1
114 #define FT_OPEN_BY_DESCRIPTION 2
115 #define FT_OPEN_BY_LOCATION 4
116  
117 //
118 // FT_ListDevices Flags (used in conjunction with FT_OpenEx Flags
119 //
120  
121 #define FT_LIST_NUMBER_ONLY 0x80000000
122 #define FT_LIST_BY_INDEX 0x40000000
123 #define FT_LIST_ALL 0x20000000
124  
125 #define FT_LIST_MASK (FT_LIST_NUMBER_ONLY|FT_LIST_BY_INDEX|FT_LIST_ALL)
126  
127 //
128 // Baud Rates
129 //
130  
131 #define FT_BAUD_300 300
132 #define FT_BAUD_600 600
133 #define FT_BAUD_1200 1200
134 #define FT_BAUD_2400 2400
135 #define FT_BAUD_4800 4800
136 #define FT_BAUD_9600 9600
137 #define FT_BAUD_14400 14400
138 #define FT_BAUD_19200 19200
139 #define FT_BAUD_38400 38400
140 #define FT_BAUD_57600 57600
141 #define FT_BAUD_115200 115200
142 #define FT_BAUD_230400 230400
143 #define FT_BAUD_460800 460800
144 #define FT_BAUD_921600 921600
145  
146 //
147 // Word Lengths
148 //
149  
150 #define FT_BITS_8 (UCHAR) 8
151 #define FT_BITS_7 (UCHAR) 7
152  
153 //
154 // Stop Bits
155 //
156  
157 #define FT_STOP_BITS_1 (UCHAR) 0
158 #define FT_STOP_BITS_2 (UCHAR) 2
159  
160 //
161 // Parity
162 //
163  
164 #define FT_PARITY_NONE (UCHAR) 0
165 #define FT_PARITY_ODD (UCHAR) 1
166 #define FT_PARITY_EVEN (UCHAR) 2
167 #define FT_PARITY_MARK (UCHAR) 3
168 #define FT_PARITY_SPACE (UCHAR) 4
169  
170 //
171 // Flow Control
172 //
173  
174 #define FT_FLOW_NONE 0x0000
175 #define FT_FLOW_RTS_CTS 0x0100
176 #define FT_FLOW_DTR_DSR 0x0200
177 #define FT_FLOW_XON_XOFF 0x0400
178  
179 //
180 // Purge rx and tx buffers
181 //
182 #define FT_PURGE_RX 1
183 #define FT_PURGE_TX 2
184  
185 //
186 // Events
187 //
188  
189 typedef void (*PFT_EVENT_HANDLER)(DWORD,DWORD);
190  
191 #define FT_EVENT_RXCHAR 1
192 #define FT_EVENT_MODEM_STATUS 2
193 #define FT_EVENT_LINE_STATUS 4
194  
195 //
196 // Timeouts
197 //
198  
199 #define FT_DEFAULT_RX_TIMEOUT 300
200 #define FT_DEFAULT_TX_TIMEOUT 300
201  
202 //
203 // Device types
204 //
205  
206 typedef ULONG FT_DEVICE;
207  
208 enum {
209 FT_DEVICE_BM,
210 FT_DEVICE_AM,
211 FT_DEVICE_100AX,
212 FT_DEVICE_UNKNOWN,
213 FT_DEVICE_2232C,
214 FT_DEVICE_232R,
215 FT_DEVICE_2232H,
216 FT_DEVICE_4232H,
217 FT_DEVICE_232H
218 };
219  
220 //
221 // Bit Modes
222 //
223  
224 #define FT_BITMODE_RESET 0x00
225 #define FT_BITMODE_ASYNC_BITBANG 0x01
226 #define FT_BITMODE_MPSSE 0x02
227 #define FT_BITMODE_SYNC_BITBANG 0x04
228 #define FT_BITMODE_MCU_HOST 0x08
229 #define FT_BITMODE_FAST_SERIAL 0x10
230 #define FT_BITMODE_CBUS_BITBANG 0x20
231 #define FT_BITMODE_SYNC_FIFO 0x40
232  
233  
234 //
235 // FT232R CBUS Options EEPROM values
236 //
237  
238 #define FT_232R_CBUS_TXDEN 0x00 // Tx Data Enable
239 #define FT_232R_CBUS_PWRON 0x01 // Power On
240 #define FT_232R_CBUS_RXLED 0x02 // Rx LED
241 #define FT_232R_CBUS_TXLED 0x03 // Tx LED
242 #define FT_232R_CBUS_TXRXLED 0x04 // Tx and Rx LED
243 #define FT_232R_CBUS_SLEEP 0x05 // Sleep
244 #define FT_232R_CBUS_CLK48 0x06 // 48MHz clock
245 #define FT_232R_CBUS_CLK24 0x07 // 24MHz clock
246 #define FT_232R_CBUS_CLK12 0x08 // 12MHz clock
247 #define FT_232R_CBUS_CLK6 0x09 // 6MHz clock
248 #define FT_232R_CBUS_IOMODE 0x0A // IO Mode for CBUS bit-bang
249 #define FT_232R_CBUS_BITBANG_WR 0x0B // Bit-bang write strobe
250 #define FT_232R_CBUS_BITBANG_RD 0x0C // Bit-bang read strobe
251  
252 //
253 // FT232H CBUS Options EEPROM values
254 //
255  
256 #define FT_232H_CBUS_TRISTATE 0x00 // Tristate
257 #define FT_232H_CBUS_TXLED 0x01 // Tx LED
258 #define FT_232H_CBUS_RXLED 0x02 // Rx LED
259 #define FT_232H_CBUS_TXRXLED 0x03 // Tx and Rx LED
260 #define FT_232H_CBUS_PWREN 0x04 // Power Enable
261 #define FT_232H_CBUS_SLEEP 0x05 // Sleep
262 #define FT_232H_CBUS_DRIVE_0 0x06 // Drive pin to logic 0
263 #define FT_232H_CBUS_DRIVE_1 0x07 // Drive pin to logic 1
264 #define FT_232H_CBUS_IOMODE 0x08 // IO Mode for CBUS bit-bang
265 #define FT_232H_CBUS_TXDEN 0x09 // Tx Data Enable
266 #define FT_232H_CBUS_CLK30 0x0A // 30MHz clock
267 #define FT_232H_CBUS_CLK15 0x0B // 15MHz clock
268 #define FT_232H_CBUS_CLK7_5 0x0C // 7.5MHz clock
269  
270  
271 #ifdef __cplusplus
272 extern "C" {
273 #endif
274  
275 FTD2XX_API
276 FT_STATUS WINAPI FT_Open(
277 int deviceNumber,
278 FT_HANDLE *pHandle
279 );
280  
281 FTD2XX_API
282 FT_STATUS WINAPI FT_OpenEx(
283 PVOID pArg1,
284 DWORD Flags,
285 FT_HANDLE *pHandle
286 );
287  
288 FTD2XX_API
289 FT_STATUS WINAPI FT_ListDevices(
290 PVOID pArg1,
291 PVOID pArg2,
292 DWORD Flags
293 );
294  
295 FTD2XX_API
296 FT_STATUS FT_SetVIDPID(
297 DWORD dwVID,
298 DWORD dwPID
299 );
300  
301 FTD2XX_API
302 FT_STATUS FT_GetVIDPID(
303 DWORD * pdwVID,
304 DWORD * pdwPID
305 );
306  
307 FTD2XX_API
308 FT_STATUS WINAPI FT_Close(
309 FT_HANDLE ftHandle
310 );
311  
312 FTD2XX_API
313 FT_STATUS WINAPI FT_Read(
314 FT_HANDLE ftHandle,
315 LPVOID lpBuffer,
316 DWORD nBufferSize,
317 LPDWORD lpBytesReturned
318 );
319  
320 FTD2XX_API
321 FT_STATUS WINAPI FT_Write(
322 FT_HANDLE ftHandle,
323 LPVOID lpBuffer,
324 DWORD nBufferSize,
325 LPDWORD lpBytesWritten
326 );
327  
328 FTD2XX_API
329 FT_STATUS WINAPI FT_IoCtl(
330 FT_HANDLE ftHandle,
331 DWORD dwIoControlCode,
332 LPVOID lpInBuf,
333 DWORD nInBufSize,
334 LPVOID lpOutBuf,
335 DWORD nOutBufSize,
336 LPDWORD lpBytesReturned,
337 LPOVERLAPPED lpOverlapped
338 );
339  
340 FTD2XX_API
341 FT_STATUS WINAPI FT_SetBaudRate(
342 FT_HANDLE ftHandle,
343 ULONG BaudRate
344 );
345  
346 FTD2XX_API
347 FT_STATUS WINAPI FT_SetDivisor(
348 FT_HANDLE ftHandle,
349 USHORT Divisor
350 );
351  
352 FTD2XX_API
353 FT_STATUS WINAPI FT_SetDataCharacteristics(
354 FT_HANDLE ftHandle,
355 UCHAR WordLength,
356 UCHAR StopBits,
357 UCHAR Parity
358 );
359  
360 FTD2XX_API
361 FT_STATUS WINAPI FT_SetFlowControl(
362 FT_HANDLE ftHandle,
363 USHORT FlowControl,
364 UCHAR XonChar,
365 UCHAR XoffChar
366 );
367  
368 FTD2XX_API
369 FT_STATUS WINAPI FT_ResetDevice(
370 FT_HANDLE ftHandle
371 );
372  
373 FTD2XX_API
374 FT_STATUS WINAPI FT_SetDtr(
375 FT_HANDLE ftHandle
376 );
377  
378 FTD2XX_API
379 FT_STATUS WINAPI FT_ClrDtr(
380 FT_HANDLE ftHandle
381 );
382  
383 FTD2XX_API
384 FT_STATUS WINAPI FT_SetRts(
385 FT_HANDLE ftHandle
386 );
387  
388 FTD2XX_API
389 FT_STATUS WINAPI FT_ClrRts(
390 FT_HANDLE ftHandle
391 );
392  
393 FTD2XX_API
394 FT_STATUS WINAPI FT_GetModemStatus(
395 FT_HANDLE ftHandle,
396 ULONG *pModemStatus
397 );
398  
399 FTD2XX_API
400 FT_STATUS WINAPI FT_SetChars(
401 FT_HANDLE ftHandle,
402 UCHAR EventChar,
403 UCHAR EventCharEnabled,
404 UCHAR ErrorChar,
405 UCHAR ErrorCharEnabled
406 );
407  
408 FTD2XX_API
409 FT_STATUS WINAPI FT_Purge(
410 FT_HANDLE ftHandle,
411 ULONG Mask
412 );
413  
414 FTD2XX_API
415 FT_STATUS WINAPI FT_SetTimeouts(
416 FT_HANDLE ftHandle,
417 ULONG ReadTimeout,
418 ULONG WriteTimeout
419 );
420  
421 FTD2XX_API
422 FT_STATUS WINAPI FT_GetQueueStatus(
423 FT_HANDLE ftHandle,
424 DWORD *dwRxBytes
425 );
426  
427 FTD2XX_API
428 FT_STATUS WINAPI FT_GetQueueStatusEx(
429 FT_HANDLE ftHandle,
430 DWORD *dwRxBytes
431 );
432  
433 FTD2XX_API
434 FT_STATUS WINAPI FT_SetEventNotification(
435 FT_HANDLE ftHandle,
436 DWORD Mask,
437 PVOID Param
438 );
439  
440 FTD2XX_API
441 FT_STATUS WINAPI FT_GetStatus(
442 FT_HANDLE ftHandle,
443 DWORD *dwRxBytes,
444 DWORD *dwTxBytes,
445 DWORD *dwEventDWord
446 );
447  
448 FTD2XX_API
449 FT_STATUS WINAPI FT_SetBreakOn(
450 FT_HANDLE ftHandle
451 );
452  
453 FTD2XX_API
454 FT_STATUS WINAPI FT_SetBreakOff(
455 FT_HANDLE ftHandle
456 );
457  
458 FTD2XX_API
459 FT_STATUS WINAPI FT_SetWaitMask(
460 FT_HANDLE ftHandle,
461 DWORD Mask
462 );
463  
464 FTD2XX_API
465 FT_STATUS WINAPI FT_WaitOnMask(
466 FT_HANDLE ftHandle,
467 DWORD *Mask
468 );
469  
470 FTD2XX_API
471 FT_STATUS WINAPI FT_GetEventStatus(
472 FT_HANDLE ftHandle,
473 DWORD *dwEventDWord
474 );
475  
476 FTD2XX_API
477 FT_STATUS WINAPI FT_ReadEE(
478 FT_HANDLE ftHandle,
479 DWORD dwWordOffset,
480 LPWORD lpwValue
481 );
482  
483 FTD2XX_API
484 FT_STATUS WINAPI FT_WriteEE(
485 FT_HANDLE ftHandle,
486 DWORD dwWordOffset,
487 WORD wValue
488 );
489  
490 FTD2XX_API
491 FT_STATUS WINAPI FT_EraseEE(
492 FT_HANDLE ftHandle
493 );
494  
495 //
496 // structure to hold program data for FT_Program function
497 //
498 typedef struct ft_program_data {
499  
500 DWORD Signature1; // Header - must be 0x00000000
501 DWORD Signature2; // Header - must be 0xffffffff
502 DWORD Version; // Header - FT_PROGRAM_DATA version
503 // 0 = original
504 // 1 = FT2232C extensions
505 // 2 = FT232R extensions
506 // 3 = FT2232H extensions
507 // 4 = FT4232H extensions
508 // 5 = FT232H extensions
509 WORD VendorId; // 0x0403
510 WORD ProductId; // 0x6001
511 char *Manufacturer; // "FTDI"
512 char *ManufacturerId; // "FT"
513 char *Description; // "USB HS Serial Converter"
514 char *SerialNumber; // "FT000001" if fixed, or NULL
515 WORD MaxPower; // 0 < MaxPower <= 500
516 WORD PnP; // 0 = disabled, 1 = enabled
517 WORD SelfPowered; // 0 = bus powered, 1 = self powered
518 WORD RemoteWakeup; // 0 = not capable, 1 = capable
519 //
520 // Rev4 (FT232B) extensions
521 //
522 UCHAR Rev4; // non-zero if Rev4 chip, zero otherwise
523 UCHAR IsoIn; // non-zero if in endpoint is isochronous
524 UCHAR IsoOut; // non-zero if out endpoint is isochronous
525 UCHAR PullDownEnable; // non-zero if pull down enabled
526 UCHAR SerNumEnable; // non-zero if serial number to be used
527 UCHAR USBVersionEnable; // non-zero if chip uses USBVersion
528 WORD USBVersion; // BCD (0x0200 => USB2)
529 //
530 // Rev 5 (FT2232) extensions
531 //
532 UCHAR Rev5; // non-zero if Rev5 chip, zero otherwise
533 UCHAR IsoInA; // non-zero if in endpoint is isochronous
534 UCHAR IsoInB; // non-zero if in endpoint is isochronous
535 UCHAR IsoOutA; // non-zero if out endpoint is isochronous
536 UCHAR IsoOutB; // non-zero if out endpoint is isochronous
537 UCHAR PullDownEnable5; // non-zero if pull down enabled
538 UCHAR SerNumEnable5; // non-zero if serial number to be used
539 UCHAR USBVersionEnable5; // non-zero if chip uses USBVersion
540 WORD USBVersion5; // BCD (0x0200 => USB2)
541 UCHAR AIsHighCurrent; // non-zero if interface is high current
542 UCHAR BIsHighCurrent; // non-zero if interface is high current
543 UCHAR IFAIsFifo; // non-zero if interface is 245 FIFO
544 UCHAR IFAIsFifoTar; // non-zero if interface is 245 FIFO CPU target
545 UCHAR IFAIsFastSer; // non-zero if interface is Fast serial
546 UCHAR AIsVCP; // non-zero if interface is to use VCP drivers
547 UCHAR IFBIsFifo; // non-zero if interface is 245 FIFO
548 UCHAR IFBIsFifoTar; // non-zero if interface is 245 FIFO CPU target
549 UCHAR IFBIsFastSer; // non-zero if interface is Fast serial
550 UCHAR BIsVCP; // non-zero if interface is to use VCP drivers
551 //
552 // Rev 6 (FT232R) extensions
553 //
554 UCHAR UseExtOsc; // Use External Oscillator
555 UCHAR HighDriveIOs; // High Drive I/Os
556 UCHAR EndpointSize; // Endpoint size
557 UCHAR PullDownEnableR; // non-zero if pull down enabled
558 UCHAR SerNumEnableR; // non-zero if serial number to be used
559 UCHAR InvertTXD; // non-zero if invert TXD
560 UCHAR InvertRXD; // non-zero if invert RXD
561 UCHAR InvertRTS; // non-zero if invert RTS
562 UCHAR InvertCTS; // non-zero if invert CTS
563 UCHAR InvertDTR; // non-zero if invert DTR
564 UCHAR InvertDSR; // non-zero if invert DSR
565 UCHAR InvertDCD; // non-zero if invert DCD
566 UCHAR InvertRI; // non-zero if invert RI
567 UCHAR Cbus0; // Cbus Mux control
568 UCHAR Cbus1; // Cbus Mux control
569 UCHAR Cbus2; // Cbus Mux control
570 UCHAR Cbus3; // Cbus Mux control
571 UCHAR Cbus4; // Cbus Mux control
572 UCHAR RIsD2XX; // non-zero if using D2XX drivers
573 //
574 // Rev 7 (FT2232H) Extensions
575 //
576 UCHAR PullDownEnable7; // non-zero if pull down enabled
577 UCHAR SerNumEnable7; // non-zero if serial number to be used
578 UCHAR ALSlowSlew; // non-zero if AL pins have slow slew
579 UCHAR ALSchmittInput; // non-zero if AL pins are Schmitt input
580 UCHAR ALDriveCurrent; // valid values are 4mA, 8mA, 12mA, 16mA
581 UCHAR AHSlowSlew; // non-zero if AH pins have slow slew
582 UCHAR AHSchmittInput; // non-zero if AH pins are Schmitt input
583 UCHAR AHDriveCurrent; // valid values are 4mA, 8mA, 12mA, 16mA
584 UCHAR BLSlowSlew; // non-zero if BL pins have slow slew
585 UCHAR BLSchmittInput; // non-zero if BL pins are Schmitt input
586 UCHAR BLDriveCurrent; // valid values are 4mA, 8mA, 12mA, 16mA
587 UCHAR BHSlowSlew; // non-zero if BH pins have slow slew
588 UCHAR BHSchmittInput; // non-zero if BH pins are Schmitt input
589 UCHAR BHDriveCurrent; // valid values are 4mA, 8mA, 12mA, 16mA
590 UCHAR IFAIsFifo7; // non-zero if interface is 245 FIFO
591 UCHAR IFAIsFifoTar7; // non-zero if interface is 245 FIFO CPU target
592 UCHAR IFAIsFastSer7; // non-zero if interface is Fast serial
593 UCHAR AIsVCP7; // non-zero if interface is to use VCP drivers
594 UCHAR IFBIsFifo7; // non-zero if interface is 245 FIFO
595 UCHAR IFBIsFifoTar7; // non-zero if interface is 245 FIFO CPU target
596 UCHAR IFBIsFastSer7; // non-zero if interface is Fast serial
597 UCHAR BIsVCP7; // non-zero if interface is to use VCP drivers
598 UCHAR PowerSaveEnable; // non-zero if using BCBUS7 to save power for self-powered designs
599 //
600 // Rev 8 (FT4232H) Extensions
601 //
602 UCHAR PullDownEnable8; // non-zero if pull down enabled
603 UCHAR SerNumEnable8; // non-zero if serial number to be used
604 UCHAR ASlowSlew; // non-zero if AL pins have slow slew
605 UCHAR ASchmittInput; // non-zero if AL pins are Schmitt input
606 UCHAR ADriveCurrent; // valid values are 4mA, 8mA, 12mA, 16mA
607 UCHAR BSlowSlew; // non-zero if AH pins have slow slew
608 UCHAR BSchmittInput; // non-zero if AH pins are Schmitt input
609 UCHAR BDriveCurrent; // valid values are 4mA, 8mA, 12mA, 16mA
610 UCHAR CSlowSlew; // non-zero if BL pins have slow slew
611 UCHAR CSchmittInput; // non-zero if BL pins are Schmitt input
612 UCHAR CDriveCurrent; // valid values are 4mA, 8mA, 12mA, 16mA
613 UCHAR DSlowSlew; // non-zero if BH pins have slow slew
614 UCHAR DSchmittInput; // non-zero if BH pins are Schmitt input
615 UCHAR DDriveCurrent; // valid values are 4mA, 8mA, 12mA, 16mA
616 UCHAR ARIIsTXDEN; // non-zero if port A uses RI as RS485 TXDEN
617 UCHAR BRIIsTXDEN; // non-zero if port B uses RI as RS485 TXDEN
618 UCHAR CRIIsTXDEN; // non-zero if port C uses RI as RS485 TXDEN
619 UCHAR DRIIsTXDEN; // non-zero if port D uses RI as RS485 TXDEN
620 UCHAR AIsVCP8; // non-zero if interface is to use VCP drivers
621 UCHAR BIsVCP8; // non-zero if interface is to use VCP drivers
622 UCHAR CIsVCP8; // non-zero if interface is to use VCP drivers
623 UCHAR DIsVCP8; // non-zero if interface is to use VCP drivers
624 //
625 // Rev 9 (FT232H) Extensions
626 //
627 UCHAR PullDownEnableH; // non-zero if pull down enabled
628 UCHAR SerNumEnableH; // non-zero if serial number to be used
629 UCHAR ACSlowSlewH; // non-zero if AC pins have slow slew
630 UCHAR ACSchmittInputH; // non-zero if AC pins are Schmitt input
631 UCHAR ACDriveCurrentH; // valid values are 4mA, 8mA, 12mA, 16mA
632 UCHAR ADSlowSlewH; // non-zero if AD pins have slow slew
633 UCHAR ADSchmittInputH; // non-zero if AD pins are Schmitt input
634 UCHAR ADDriveCurrentH; // valid values are 4mA, 8mA, 12mA, 16mA
635 UCHAR Cbus0H; // Cbus Mux control
636 UCHAR Cbus1H; // Cbus Mux control
637 UCHAR Cbus2H; // Cbus Mux control
638 UCHAR Cbus3H; // Cbus Mux control
639 UCHAR Cbus4H; // Cbus Mux control
640 UCHAR Cbus5H; // Cbus Mux control
641 UCHAR Cbus6H; // Cbus Mux control
642 UCHAR Cbus7H; // Cbus Mux control
643 UCHAR Cbus8H; // Cbus Mux control
644 UCHAR Cbus9H; // Cbus Mux control
645 UCHAR IsFifoH; // non-zero if interface is 245 FIFO
646 UCHAR IsFifoTarH; // non-zero if interface is 245 FIFO CPU target
647 UCHAR IsFastSerH; // non-zero if interface is Fast serial
648 UCHAR IsFT1248H; // non-zero if interface is FT1248
649 UCHAR FT1248CpolH; // FT1248 clock polarity - clock idle high (1) or clock idle low (0)
650 UCHAR FT1248LsbH; // FT1248 data is LSB (1) or MSB (0)
651 UCHAR FT1248FlowControlH; // FT1248 flow control enable
652 UCHAR IsVCPH; // non-zero if interface is to use VCP drivers
653 UCHAR PowerSaveEnableH; // non-zero if using ACBUS7 to save power for self-powered designs
654  
655 } FT_PROGRAM_DATA, *PFT_PROGRAM_DATA;
656  
657  
658 FTD2XX_API
659 FT_STATUS WINAPI FT_EE_Program(
660 FT_HANDLE ftHandle,
661 PFT_PROGRAM_DATA pData
662 );
663  
664 FTD2XX_API
665 FT_STATUS WINAPI FT_EE_ProgramEx(
666 FT_HANDLE ftHandle,
667 PFT_PROGRAM_DATA lpData,
668 char *Manufacturer,
669 char *ManufacturerId,
670 char *Description,
671 char *SerialNumber
672 );
673  
674 FTD2XX_API
675 FT_STATUS WINAPI FT_EE_Read(
676 FT_HANDLE ftHandle,
677 PFT_PROGRAM_DATA pData
678 );
679  
680 FTD2XX_API
681 FT_STATUS WINAPI FT_EE_ReadEx(
682 FT_HANDLE ftHandle,
683 PFT_PROGRAM_DATA lpData,
684 char *Manufacturer,
685 char *ManufacturerId,
686 char *Description,
687 char *SerialNumber
688 );
689  
690 FTD2XX_API
691 FT_STATUS WINAPI FT_EE_UASize(
692 FT_HANDLE ftHandle,
693 LPDWORD lpdwSize
694 );
695  
696 FTD2XX_API
697 FT_STATUS WINAPI FT_EE_UAWrite(
698 FT_HANDLE ftHandle,
699 PUCHAR pucData,
700 DWORD dwDataLen
701 );
702  
703 FTD2XX_API
704 FT_STATUS WINAPI FT_EE_UARead(
705 FT_HANDLE ftHandle,
706 PUCHAR pucData,
707 DWORD dwDataLen,
708 LPDWORD lpdwBytesRead
709 );
710  
711 FTD2XX_API
712 FT_STATUS WINAPI FT_SetLatencyTimer(
713 FT_HANDLE ftHandle,
714 UCHAR ucLatency
715 );
716  
717 FTD2XX_API
718 FT_STATUS WINAPI FT_GetLatencyTimer(
719 FT_HANDLE ftHandle,
720 PUCHAR pucLatency
721 );
722  
723 FTD2XX_API
724 FT_STATUS WINAPI FT_SetBitMode(
725 FT_HANDLE ftHandle,
726 UCHAR ucMask,
727 UCHAR ucEnable
728 );
729  
730 FTD2XX_API
731 FT_STATUS WINAPI FT_GetBitMode(
732 FT_HANDLE ftHandle,
733 PUCHAR pucMode
734 );
735  
736 FTD2XX_API
737 FT_STATUS WINAPI FT_SetUSBParameters(
738 FT_HANDLE ftHandle,
739 ULONG ulInTransferSize,
740 ULONG ulOutTransferSize
741 );
742  
743 FTD2XX_API
744 FT_STATUS WINAPI FT_GetDeviceInfo(
745 FT_HANDLE ftHandle,
746 FT_DEVICE *lpftDevice,
747 LPDWORD lpdwID,
748 PCHAR SerialNumber,
749 PCHAR Description,
750 LPVOID Dummy
751 );
752  
753 FTD2XX_API
754 FT_STATUS WINAPI FT_GetDeviceLocId(
755 FT_HANDLE ftHandle,
756 LPDWORD lpdwLocId
757 );
758  
759 FTD2XX_API
760 FT_STATUS WINAPI FT_StopInTask(
761 FT_HANDLE ftHandle
762 );
763  
764 FTD2XX_API
765 FT_STATUS WINAPI FT_RestartInTask(
766 FT_HANDLE ftHandle
767 );
768  
769 FTD2XX_API
770 FT_STATUS WINAPI FT_SetResetPipeRetryCount(
771 FT_HANDLE ftHandle,
772 DWORD dwCount
773 );
774  
775 FTD2XX_API
776 FT_STATUS WINAPI FT_ResetPort(
777 FT_HANDLE ftHandle
778 );
779  
780 FTD2XX_API
781 FT_STATUS WINAPI FT_CyclePort(
782 FT_HANDLE ftHandle
783 );
784  
785 //
786 // Win32-type functions
787 //
788  
789 FTD2XX_API
790 FT_HANDLE WINAPI FT_W32_CreateFile(
791 LPCSTR lpszName,
792 DWORD dwAccess,
793 DWORD dwShareMode,
794 LPSECURITY_ATTRIBUTES lpSecurityAttributes,
795 DWORD dwCreate,
796 DWORD dwAttrsAndFlags,
797 HANDLE hTemplate
798 );
799  
800 FTD2XX_API
801 BOOL WINAPI FT_W32_CloseHandle(
802 FT_HANDLE ftHandle
803 );
804  
805 FTD2XX_API
806 BOOL WINAPI FT_W32_ReadFile(
807 FT_HANDLE ftHandle,
808 LPVOID lpBuffer,
809 DWORD nBufferSize,
810 LPDWORD lpBytesReturned,
811 LPOVERLAPPED lpOverlapped
812 );
813  
814 FTD2XX_API
815 BOOL WINAPI FT_W32_WriteFile(
816 FT_HANDLE ftHandle,
817 LPVOID lpBuffer,
818 DWORD nBufferSize,
819 LPDWORD lpBytesWritten,
820 LPOVERLAPPED lpOverlapped
821 );
822  
823 FTD2XX_API
824 DWORD WINAPI FT_W32_GetLastError(
825 FT_HANDLE ftHandle
826 );
827  
828 FTD2XX_API
829 BOOL WINAPI FT_W32_GetOverlappedResult(
830 FT_HANDLE ftHandle,
831 LPOVERLAPPED lpOverlapped,
832 LPDWORD lpdwBytesTransferred,
833 BOOL bWait
834 );
835  
836 FTD2XX_API
837 BOOL WINAPI FT_W32_CancelIo(
838 FT_HANDLE ftHandle
839 );
840  
841  
842 //
843 // Win32 COMM API type functions
844 //
845 typedef struct _FTCOMSTAT {
846 DWORD fCtsHold : 1;
847 DWORD fDsrHold : 1;
848 DWORD fRlsdHold : 1;
849 DWORD fXoffHold : 1;
850 DWORD fXoffSent : 1;
851 DWORD fEof : 1;
852 DWORD fTxim : 1;
853 DWORD fReserved : 25;
854 DWORD cbInQue;
855 DWORD cbOutQue;
856 } FTCOMSTAT, *LPFTCOMSTAT;
857  
858 typedef struct _FTDCB {
859 DWORD DCBlength; /* sizeof(FTDCB) */
860 DWORD BaudRate; /* Baudrate at which running */
861 DWORD fBinary: 1; /* Binary Mode (skip EOF check) */
862 DWORD fParity: 1; /* Enable parity checking */
863 DWORD fOutxCtsFlow:1; /* CTS handshaking on output */
864 DWORD fOutxDsrFlow:1; /* DSR handshaking on output */
865 DWORD fDtrControl:2; /* DTR Flow control */
866 DWORD fDsrSensitivity:1; /* DSR Sensitivity */
867 DWORD fTXContinueOnXoff: 1; /* Continue TX when Xoff sent */
868 DWORD fOutX: 1; /* Enable output X-ON/X-OFF */
869 DWORD fInX: 1; /* Enable input X-ON/X-OFF */
870 DWORD fErrorChar: 1; /* Enable Err Replacement */
871 DWORD fNull: 1; /* Enable Null stripping */
872 DWORD fRtsControl:2; /* Rts Flow control */
873 DWORD fAbortOnError:1; /* Abort all reads and writes on Error */
874 DWORD fDummy2:17; /* Reserved */
875 WORD wReserved; /* Not currently used */
876 WORD XonLim; /* Transmit X-ON threshold */
877 WORD XoffLim; /* Transmit X-OFF threshold */
878 BYTE ByteSize; /* Number of bits/byte, 4-8 */
879 BYTE Parity; /* 0-4=None,Odd,Even,Mark,Space */
880 BYTE StopBits; /* 0,1,2 = 1, 1.5, 2 */
881 char XonChar; /* Tx and Rx X-ON character */
882 char XoffChar; /* Tx and Rx X-OFF character */
883 char ErrorChar; /* Error replacement char */
884 char EofChar; /* End of Input character */
885 char EvtChar; /* Received Event character */
886 WORD wReserved1; /* Fill for now. */
887 } FTDCB, *LPFTDCB;
888  
889 typedef struct _FTTIMEOUTS {
890 DWORD ReadIntervalTimeout; /* Maximum time between read chars. */
891 DWORD ReadTotalTimeoutMultiplier; /* Multiplier of characters. */
892 DWORD ReadTotalTimeoutConstant; /* Constant in milliseconds. */
893 DWORD WriteTotalTimeoutMultiplier; /* Multiplier of characters. */
894 DWORD WriteTotalTimeoutConstant; /* Constant in milliseconds. */
895 } FTTIMEOUTS,*LPFTTIMEOUTS;
896  
897  
898 FTD2XX_API
899 BOOL WINAPI FT_W32_ClearCommBreak(
900 FT_HANDLE ftHandle
901 );
902  
903 FTD2XX_API
904 BOOL WINAPI FT_W32_ClearCommError(
905 FT_HANDLE ftHandle,
906 LPDWORD lpdwErrors,
907 LPFTCOMSTAT lpftComstat
908 );
909  
910 FTD2XX_API
911 BOOL WINAPI FT_W32_EscapeCommFunction(
912 FT_HANDLE ftHandle,
913 DWORD dwFunc
914 );
915  
916 FTD2XX_API
917 BOOL WINAPI FT_W32_GetCommModemStatus(
918 FT_HANDLE ftHandle,
919 LPDWORD lpdwModemStatus
920 );
921  
922 FTD2XX_API
923 BOOL WINAPI FT_W32_GetCommState(
924 FT_HANDLE ftHandle,
925 LPFTDCB lpftDcb
926 );
927  
928 FTD2XX_API
929 BOOL WINAPI FT_W32_GetCommTimeouts(
930 FT_HANDLE ftHandle,
931 FTTIMEOUTS *pTimeouts
932 );
933  
934 FTD2XX_API
935 BOOL WINAPI FT_W32_PurgeComm(
936 FT_HANDLE ftHandle,
937 DWORD dwMask
938 );
939  
940 FTD2XX_API
941 BOOL WINAPI FT_W32_SetCommBreak(
942 FT_HANDLE ftHandle
943 );
944  
945 FTD2XX_API
946 BOOL WINAPI FT_W32_SetCommMask(
947 FT_HANDLE ftHandle,
948 ULONG ulEventMask
949 );
950  
951 FTD2XX_API
952 BOOL WINAPI FT_W32_SetCommState(
953 FT_HANDLE ftHandle,
954 LPFTDCB lpftDcb
955 );
956  
957 FTD2XX_API
958 BOOL WINAPI FT_W32_SetCommTimeouts(
959 FT_HANDLE ftHandle,
960 FTTIMEOUTS *pTimeouts
961 );
962  
963 FTD2XX_API
964 BOOL WINAPI FT_W32_SetupComm(
965 FT_HANDLE ftHandle,
966 DWORD dwReadBufferSize,
967 DWORD dwWriteBufferSize
968 );
969  
970 FTD2XX_API
971 BOOL WINAPI FT_W32_WaitCommEvent(
972 FT_HANDLE ftHandle,
973 PULONG pulEvent,
974 LPOVERLAPPED lpOverlapped
975 );
976  
977 //
978 // Device information
979 //
980  
981 typedef struct _ft_device_list_info_node {
982 ULONG Flags;
983 ULONG Type;
984 ULONG ID;
985 DWORD LocId;
986 char SerialNumber[16];
987 char Description[64];
988 FT_HANDLE ftHandle;
989 } FT_DEVICE_LIST_INFO_NODE;
990  
991 // Device information flags
992 enum {
993 FT_FLAGS_OPENED = 1,
994 FT_FLAGS_HISPEED = 2
995 };
996  
997 FTD2XX_API
998 FT_STATUS WINAPI FT_CreateDeviceInfoList(
999 LPDWORD lpdwNumDevs
1000 );
1001  
1002 FTD2XX_API
1003 FT_STATUS WINAPI FT_GetDeviceInfoList(
1004 FT_DEVICE_LIST_INFO_NODE *pDest,
1005 LPDWORD lpdwNumDevs
1006 );
1007  
1008 FTD2XX_API
1009 FT_STATUS WINAPI FT_GetDeviceInfoDetail(
1010 DWORD dwIndex,
1011 LPDWORD lpdwFlags,
1012 LPDWORD lpdwType,
1013 LPDWORD lpdwID,
1014 LPDWORD lpdwLocId,
1015 LPVOID lpSerialNumber,
1016 LPVOID lpDescription,
1017 FT_HANDLE *pftHandle
1018 );
1019  
1020  
1021 //
1022 // Version information
1023 //
1024  
1025 FTD2XX_API
1026 FT_STATUS WINAPI FT_GetDriverVersion(
1027 FT_HANDLE ftHandle,
1028 LPDWORD lpdwVersion
1029 );
1030  
1031 FTD2XX_API
1032 FT_STATUS WINAPI FT_GetLibraryVersion(
1033 LPDWORD lpdwVersion
1034 );
1035  
1036 //
1037 // Events
1038 //
1039  
1040 #define EV_RXCHAR 0x0001 // Any Character received
1041 #define EV_RXFLAG 0x0002 // Received certain character
1042 #define EV_TXEMPTY 0x0004 // Transmitt Queue Empty
1043 #define EV_CTS 0x0008 // CTS changed state
1044 #define EV_DSR 0x0010 // DSR changed state
1045 #define EV_RLSD 0x0020 // RLSD changed state
1046 #define EV_BREAK 0x0040 // BREAK received
1047 #define EV_ERR 0x0080 // Line status error occurred
1048 #define EV_RING 0x0100 // Ring signal detected
1049 #define EV_PERR 0x0200 // Printer error occured
1050 #define EV_RX80FULL 0x0400 // Receive buffer is 80 percent full
1051 #define EV_EVENT1 0x0800 // Provider specific event 1
1052 #define EV_EVENT2 0x1000 // Provider specific event 2
1053  
1054 //
1055 // Escape Functions
1056 //
1057  
1058 #define SETXOFF 1 // Simulate XOFF received
1059 #define SETXON 2 // Simulate XON received
1060 #define SETRTS 3 // Set RTS high
1061 #define CLRRTS 4 // Set RTS low
1062 #define SETDTR 5 // Set DTR high
1063 #define CLRDTR 6 // Set DTR low
1064 #define RESETDEV 7 // Reset device if possible
1065 #define SETBREAK 8 // Set the device break line.
1066 #define CLRBREAK 9 // Clear the device break line.
1067  
1068 //
1069 // PURGE function flags.
1070 //
1071 #define PURGE_TXABORT 0x0001 // Kill the pending/current writes to the comm port.
1072 #define PURGE_RXABORT 0x0002 // Kill the pending/current reads to the comm port.
1073 #define PURGE_TXCLEAR 0x0004 // Kill the transmit queue if there.
1074 #define PURGE_RXCLEAR 0x0008 // Kill the typeahead buffer if there.
1075  
1076 #ifdef __cplusplus
1077 }
1078 #endif
1079  
1080  
1081 #endif /* FTD2XX_H */
1082  
1083  
1084  
1085  
1086  
1087