Future Technology Devices International Ltd. AN2232-02 Bit Mode Functions for the FT2232 Copyright © 2006 Future Technology Devices International Ltd. 2 AN2232C-02 Bit Mode Functions for the FT2232 1 Bit Mode Functions For the FT2232 1.1 Overview The D2XX functions FT_Set BitMode 3 and FT_GetBitMode 5 are used to enable several device IO modes for the FT2232. This document describes these functions in terms of the FT2232 and provides some examples. Copyright © 2006 Future Technology Devices International Ltd. Bit Mode Functions For the FT2232 1.2 3 FT_SetBitMode Set the device IO bit mode. FT_STATUS FT_SetBitMode (FT_HANDLE ftHandle, UCHAR ucMask, UCHAR ucMode) Parameters ftHandle Handle of the device. ucMask Required value for bit mode mask. This sets up which bits are input and which bits are output. The ucMask byte sets the direction. A '0' means that the corresponding bit is to be an input, while a '1' means that the corresponding bit is to be an output. ucMode Mode value as shown in the following table: Mode Value (hex) Reset the IO Bit Mode 0x0 Asynchronous Bit Bang Mode 0x1 MPSSE 0x2 Synchronous Bit Bang Mode 0x4 MCU Host Bus Emulation 0x8 Fast Serial For Opto-Isolation 0x10 Return Value FT_OK if successful, otherwise the return value is an FT error code. Copyright © 2006 Future Technology Devices International Ltd. 4 1.3 AN2232C-02 Bit Mode Functions for the FT2232 FT_SetBitMode Example 1) To enable MPSSE Mode: HANDLE ftHandle; // valid handle returned from FT_Open or FT_W32_CreateFile FT_STATUS ftStatus; UCHAR Mask = 0xff; // set all IOs to output UCHAR Mode = 2; // set MPSSE mode ftStatus = FT_SetBitMode(ftHandle,Mask,Mode); if (ftStatus == FT_OK) { // MPSSE Mode enabled } else { // FT_SetBitMode FAILED! } 2) To enable Asynchronous Bit Bang Mode (See AN232BM-01 7 ): HANDLE ftHandle; // valid handle returned from FT_Open or FT_W32_CreateFile FT_STATUS ftStatus; UCHAR Mask = 0x07; // set bits 0, 1 and 2 to output UCHAR Mode = 1; // set Asynchronous Bit Bang mode ftStatus = FT_SetBitMode(ftHandle,Mask,Mode); if (ftStatus == FT_OK) { // Asynchronous Bit bang Mode enabled } else { // FT_SetBitMode FAILED! } 3) To reset the IO bit mode: ftStatus = FT_SetBitMode(ftHandle,0,0); 4) To enable Synchrounous Bit Bang mode (using D2XXUnit.pas for Delphi): Set_USB_Device_BitMode($00,$04); to enable it Set_USB_Device_BitMode($00,$00); to reset it 5) To enable For MCU Host Bus Emulation mode (using D2XXUnit.pas for Delphi): Set_USB_Device_BitMode($00,$08); to enable it Set_USB_Device_BitMode($00,$00); to reset it Copyright © 2006 Future Technology Devices International Ltd. Bit Mode Functions For the FT2232 1.4 FT_GetBitMode Get the current value of the IO bit mode. FT_STATUS FT_GetBitMode (FT_HANDLE ftHandle, PUCHAR pucMode) Parameters ftHandle Handle of the device. pucMode Pointer to unsigned char to store bit mode value. Return Value FT_OK if successful, otherwise the return value is an FT error code. Copyright © 2006 Future Technology Devices International Ltd. 5 6 1.5 AN2232C-02 Bit Mode Functions for the FT2232 FT_GetBitMode Example To get the current bit mode value HANDLE ftHandle; // valid handle returned from FT_Open or FT_W32_CreateFile UCHAR BitMode; FT_STATUS ftStatus; ftStatus = FT_GetBitMode(ftHandle,&BitMode); if (ftStatus == FT_OK) { // BitMode contains current value } else { // FT_GetBitMode FAILED! } Copyright © 2006 Future Technology Devices International Ltd. Bit Mode Functions For the FT2232 1.6 References DS2232C - FT2232C Device datasheet AN232-01 - FT232BM/FT245BM Bit Bang Mode AN2232-01 - Command Processor for MPSSE and MCU Host Bus Emulation Modes Sample Projects - MPSSE Code Examples D2XX Programmer's Guide Copyright © 2006 Future Technology Devices International Ltd. 7 8 AN2232C-02 Bit Mode Functions for the FT2232 2 History, Disclaimer, Contact 2.1 Document Revision History Version Release Date Comments 1.0 April 2004 Initial release. 2.0 December 2005 New format. 2.1 October 2006 References to FT2232C changed to FT2232 after release of FT2232D. Copyright © 2006 Future Technology Devices International Ltd. History, Disclaimer, Contact 2.2 9 Disclaimer Copyright © 2006 Future Technology Devices International Ltd. Neither the whole nor any part of the information contained in, or the product described in this manual, may be adapted or reproduced in any material or electronic form without the prior written consent of the copyright holder. This product and its documentation are supplied on an as-is basis and no warranty as to their suitability for any particular purpose is either made or implied. Future Technology Devices International Ltd. will not accept any claim for damages howsoever arising as a result of use or failure of this product. Your statutory rights are not affected. This product or any variant of it is not intended for use in any medical appliance, device or system in which the failure of the product might reasonably be expected to result in personal injury. This document provides preliminary information that may be subject to change without notice. Copyright © 2006 Future Technology Devices International Ltd. 10 2.3 AN2232C-02 Bit Mode Functions for the FT2232 Contact Information Head Office - Glasgow, UK Future Technology Devices International Limited 373 Scotland Street Glasgow G5 8QB United Kingdom Tel: +44 (0) 141 429 2777 Fax: +44 (0) 141 429 2758 E-Mail (Sales): [email protected] E-Mail (Support): [email protected] E-Mail (General Enquiries): [email protected] Web Site URL: http://www.ftdichip.com Web Shop URL: http://apple.clickandbuild.com/cnb/shop/ftdichip Branch Office - Taiwan Future Technology Devices International Limited (Taiwan) 4F, No 16-1, Sec. 6 Mincyuan East Road Neihu District Taipei 114 Taiwan ROC Tel: +886 2 8791 3570 Fax: +886 2 8791 3576 E-Mail (Sales): [email protected] E-Mail (Support): [email protected] E-Mail (General Enquiries): [email protected] Web Site URL: http://www.ftdichip.com Branch Office - Hillsboro, Oregon, USA Future Technology Devices International Limited (USA) 5285 NE Elam Young Parkway Suite B800 Hillsboro, OR 97124-6499 USA Tel: +1 (503) 547-0988 Fax: +1 (503) 547-0987 E-Mail (Sales): [email protected] E-Mail (Support): [email protected] E-Mail (General Enquiries): [email protected] Web Site URL: http://www.ftdichip.com Agents and Sales Representatives Please visit the Sales Network page of the FTDI Web site for the contact details of our distributor(s) in your country. Copyright © 2006 Future Technology Devices International Ltd. Index Index -FFT_GetBitMode FT_SetBitMode 5, 6 3, 4 Copyright © 2006 Future Technology Devices International Ltd. 11