介绍 FT_SetBitMode 函数的用法、参数、返回值、注意事项、适用的操作系统环境、调用代码示例等。
支持的操作系统
Linux
Mac OS X 10.4 以上版本
Windows 2000 以上版本
Windows CE 4.2 以上版本
概述
FT_SetBitMode 函数设置不同的芯片模式。
定义
FT_STATUS FT_SetBitmode (FT_HANDLE ftHandle, UCHAR ucMask, UCHAR ucMode)
参数说明
ftHandle — 设备句柄。
ucMask— bit位模式码。指定哪些bit位为输入位和输出位。位的值为0,代表对应针脚为输入位,若值为1,代表对应针脚为输出位。对于 CBUS Bit Bang,该参数高四位控制哪些针脚为输入输出位,低四位控制输出输出的高低位的位置。
ucMode— 模式值。可能的取值如下:
0x0 = Reset
0x1 = Asynchronous Bit Bang
0x2 = MPSSE (FT2232, FT2232H, FT4232H and FT232H devices only)
0x4 = Synchronous Bit Bang (FT232R, FT245R, FT2232, FT2232H, FT4232H and FT232H devices only)
0x8 = MCU Host Bus Emulation Mode (FT2232, FT2232H, FT4232H and FT232H devices only)
0x10 = Fast Opto-Isolated Serial Mode (FT2232, FT2232H, FT4232H and FT232H devices only)
0x20 = CBUS Bit Bang Mode (FT232R and FT232H devices only)
0x40 = Single Channel Synchronous 245 FIFO Mode (FT2232H and FT232H devices only)。
返回值
成功则返回FT_OK,如果失败则根据错误返回特定错误码(FT_*).
备注
For a description of available bit modes for the FT232R, see the application note “Bit Bang Modes for the
FT232R and FT245R”.
For a description of available bit modes for the FT2232, see the application note “Bit Mode Functions for
the FT2232”.
For a description of Bit Bang Mode for the FT232B and FT245B, see the application note “FT232B/FT245B
Bit Bang Mode”.
Application notes are available for download from the FTDI website.
Note that to use CBUS Bit Bang for the FT232R, the CBUS must be configured for CBUS Bit Bang in the
EEPROM.
Note that to use Single Channel Synchronous 245 FIFO mode for the FT2232H, channel A must be
configured for FT245 FIFO mode in the EEPROM.
代码示例
FT_HANDLE ftHandle;
FT_STATUS ftStatus;
UCHAR Mask = 0xff;
UCHAR Mode = 1; // Set asynchronous bit-bang mode
ftStatus = FT_Open(0, &ftHandle);
if(ftStatus != FT_OK) {
// FT_Open failed
return;
}
ftStatus = FT_SetBitMode(ftHandle, Mask, Mode);
if (ftStatus == FT_OK) {
// 0xff written to device
}
else {
// FT_SetBitMode FAILED!
}
FT_Close(ftHandle);
暂无评论内容