FT_EE_ProgramEx函数的用法

介绍FT_EE_ProgramEx函数的用法、参数、返回值、注意事项、适用的操作系统环境、调用代码示例等。

null

支持的操作系统

Linux

Mac OS X 10.4 以上版本

Windows 2000 以上版本

Windows CE 4.2 以上版本

概述

FT_EE_ProgramEx 函数对 EEPROM 进行编程,各个项使用独立字符串参数传递,写入厂商、串号等信息。

定义

FT_STATUS FT_EE_ProgramEx (FT_HANDLE ftHandle, PFT_PROGRAM_DATA pData,char *Manufacturer, char *ManufacturerId,char *Description, char *SerialNumber)

参数说明

ftHandle — 设备句柄。

pData — FT_PROGRAM_DATA结构体指针。

Manufacturer — 字符串指针,对应生产厂家名称,NULL为结束字符。

ManufacturerId — 字符串指针,对应生产厂家编号,NULL为结束字符。

Description — 字符串指针,对应描述符,NULL为结束字符。

SerialNumber — 字符串指针,对应序列号,NULL为结束字符。

返回值

成功则返回FT_OK,如果失败则根据错误返回特定错误码(FT_*).

备注

FT_EE_ProgramEx 函数对类似 LabVIEW 之类的对于结构体中包含的字符串指针的处理存在问题的编程语言提供了接口支持。

FT_EE_Program 函数中的参数 pData 为指向 FT_PROGRAM_DATA 类型结构体变量的指针,该结构体存储要向EEPROM中写入的数据。数据被写入EEPROM,然后读取进行验证。

FT_PROGRAM_DATA 结构体中的字符串指针参数为 DWORD类型,以防止参数地址冲突与重叠。字符串参数分别独立传递。

如果FT_PROGRAM_DATA 结构体中的SerialNumber字段为空NULL,或者其指向一个空字符串,则序列号SerialNumber由ManufacturerId 和当前日期时间构成。

厂商字符串和描述符字符串长度之和必须不大于40个字符。

需要注意的是,使用的DLL必须确认其使用的 FT_PROGRAM_DATA 结构体定义的版本。其版本可以通过Signature1, Signature2 和 Version 成员变量来确定。

如果参数 pData 为空NULL, 结构体的版本默认为 0 (original BM series) ,设备使用默认数据进行信息写入。

代码示例

代码示例展示如何对EEPROM和FT232B设备进行编程。
// Version 4 structure for programming a BM device.
// Other elements would need non-zero values for FT2232, FT232R, FT245R, FT2232H or
// FT4232H devices.
FT_PROGRAM_DATA ftData = {
0x00000000, // Header – must be 0x00000000
0xFFFFFFFF, // Header – must be 0xffffffff
0x00000004, // Header – FT_PROGRAM_DATA version
0x0403, // VID
0x6001, // PID
“FTDI”, // Manufacturer
“FT”, // Manufacturer ID
“USB HS Serial Converter”, // Description
“FT000001”, // Serial Number
44, // MaxPower
1, // PnP
0, // SelfPowered
1, // RemoteWakeup
1, // non-zero if Rev4 chip, zero otherwise
0, // non-zero if in endpoint is isochronous
0, // non-zero if out endpoint is isochronous
0, // non-zero if pull down enabled
1, // non-zero if serial number to be used
0, // non-zero if chip uses USBVersion
0x0110 // BCD (0x0200 => USB2)
//
// FT2232C extensions (Enabled if Version = 1 or greater)
//
0, // non-zero if Rev5 chip, zero otherwise
0, // non-zero if in endpoint is isochronous
0, // non-zero if in endpoint is isochronous
0, // non-zero if out endpoint is isochronous
0, // non-zero if out endpoint is isochronous
0, // non-zero if pull down enabled
0, // non-zero if serial number to be used
0, // non-zero if chip uses USBVersion
0x0, // BCD (0x0200 => USB2)
0, // non-zero if interface is high current
0, // non-zero if interface is high current
0, // non-zero if interface is 245 FIFO
0, // non-zero if interface is 245 FIFO CPU target
0, // non-zero if interface is Fast serial
0, // non-zero if interface is to use VCP drivers
0, // non-zero if interface is 245 FIFO
0, // non-zero if interface is 245 FIFO CPU target
0, // non-zero if interface is Fast serial
0, // non-zero if interface is to use VCP drivers
//
// FT232R extensions (Enabled if Version = 2 or greater)
//
0, // Use External Oscillator
0, // High Drive I/Os
0, // Endpoint size
0, // non-zero if pull down enabled
0, // non-zero if serial number to be used
0, // non-zero if invert TXD
0, // non-zero if invert RXD
0, // non-zero if invert RTS
0, // non-zero if invert CTS
0, // non-zero if invert DTR
0, // non-zero if invert DSR
0, // non-zero if invert DCD
0, // non-zero if invert RI
0, // Cbus Mux control
0, // Cbus Mux control
0, // Cbus Mux control
0, // Cbus Mux control
0, // Cbus Mux control
0, // non-zero if using D2XX drivers
//
// Rev 7 (FT2232H) Extensions (Enabled if Version = 3 or greater)
//
0, // non-zero if pull down enabled
0, // non-zero if serial number to be used
0, // non-zero if AL pins have slow slew
0, // non-zero if AL pins are Schmitt input
0, // valid values are 4mA, 8mA, 12mA, 16mA
0, // non-zero if AH pins have slow slew
0, // non-zero if AH pins are Schmitt input
0, // valid values are 4mA, 8mA, 12mA, 16mA
0, // non-zero if BL pins have slow slew
0, // non-zero if BL pins are Schmitt input
0, // valid values are 4mA, 8mA, 12mA, 16mA
0, // non-zero if BH pins have slow slew
0, // non-zero if BH pins are Schmitt input
0, // valid values are 4mA, 8mA, 12mA, 16mA
0, // non-zero if interface is 245 FIFO
0, // non-zero if interface is 245 FIFO CPU target
0, // non-zero if interface is Fast serial
0, // non-zero if interface is to use VCP drivers
0, // non-zero if interface is 245 FIFO
0, // non-zero if interface is 245 FIFO CPU target
0, // non-zero if interface is Fast serial
0, // non-zero if interface is to use VCP drivers
0, // non-zero if using BCBUS7 to save power for self-// powered designs
//
// Rev 8 (FT4232H) Extensions (Enabled if Version = 4)
//
0, // non-zero if pull down enabled
0, // non-zero if serial number to be used
0, // non-zero if AL pins have slow slew
0, // non-zero if AL pins are Schmitt input
0, // valid values are 4mA, 8mA, 12mA, 16mA
0, // non-zero if AH pins have slow slew
0, // non-zero if AH pins are Schmitt input
0, // valid values are 4mA, 8mA, 12mA, 16mA
0, // non-zero if BL pins have slow slew
0, // non-zero if BL pins are Schmitt input
0, // valid values are 4mA, 8mA, 12mA, 16mA
0, // non-zero if BH pins have slow slew
0, // non-zero if BH pins are Schmitt input
0, // valid values are 4mA, 8mA, 12mA, 16mA
0, // non-zero if port A uses RI as RS485 TXDEN
0, // non-zero if port B uses RI as RS485 TXDEN
0, // non-zero if port C uses RI as RS485 TXDEN
0, // non-zero if port D uses RI as RS485 TXDEN
0, // non-zero if interface is to use VCP drivers
0, // non-zero if interface is to use VCP drivers
0, // non-zero if interface is to use VCP drivers
0, // non-zero if interface is to use VCP drivers
//
// Rev 9 (FT232H) Extensions (Enabled if Version = 5)
//
0, // non-zero if pull down enabled
0, // non-zero if serial number to be used
0, // non-zero if AC pins have slow slew
0, // non-zero if AC pins are Schmitt input
0, // valid values are 4mA, 8mA, 12mA, 16mA
0, // non-zero if AD pins have slow slew
0, // non-zero if AD pins are Schmitt input
0, // valid values are 4mA, 8mA, 12mA, 16mA
0, // Cbus Mux control
0, // Cbus Mux control
0, // Cbus Mux control
0, // Cbus Mux control
0, // Cbus Mux control
0, // Cbus Mux control
0, // Cbus Mux control
0, // Cbus Mux control
0, // Cbus Mux control
0, // Cbus Mux control
0, // non-zero if interface is 245 FIFO
0, // non-zero if interface is 245 FIFO CPU target
0, // non-zero if interface is Fast serial
0, // non-zero if interface is FT1248
0, // FT1248 clock polarity – clock idle high (1) or
// clock idle low (0)
0, // FT1248 data is LSB (1) or MSB (0)
0, // FT1248 flow control enable
0, // non-zero if interface is to use VCP drivers
0 // non-zero if using ACBUS7 to save power for
// self-powered designs
};
FT_HANDLE ftHandle;
FT_STATUS ftStatus = FT_Open(0, &ftHandle);
if (ftStatus == FT_OK) {
ftStatus = FT_EE_Program(ftHandle, &ftData);
if (ftStatus == FT_OK) {
// FT_EE_Program OK!
}
else {
// FT_EE_Program FAILED!
}
FT_Close(ftHandle);
}

© 版权声明
THE END
喜欢就支持一下吧
点赞0 分享
评论 抢沙发
头像
欢迎您留下宝贵的见解!
提交
头像

昵称

取消
昵称表情代码图片

    暂无评论内容