我刚刚购买了UM232R USB串行UART开发模块,该模块使用FT232RL芯片通过USB模拟类似UART的接口.
我实际上只是为了一个非常简单的目的而买了这个复杂的模块:触发一个我自己构建的非常简单的LED电路.所以我想要的是"咬一下"模块的第一个可以进位的引脚"CB0"(引脚23)[参见数据表中的第8/9页].使用C++或AHK(或者Python,即使我真的不知道它),它并不重要.它需要在Windows上运行.
到目前为止我所尝试的内容:
我找到了一个关于如何对FTDI设备进行bit-bang的精彩教程.
但首先,我安装了VCP驱动程序,或者更准确地说明了表格右侧的"设置可执行文件".这不仅安装了VCP驱动程序,还安装了D2XX驱动程序.然后我下载了D2XX驱动程序作为zip(一个用于Windows).
好吧:
我创建了一个新的Visual C++项目(带有预编译头的Win32控制台应用程序).
我在项目文件夹中解压缩了D2XX驱动程序.
我将ftd2xx.h头文件添加到项目中.
我从上面提到的教程中获取了这段代码并将其修改为:
(我实际上只是添加了windows.h,stdafx.h并修改为#include
#include "ftd2xx.h"
)
/* 8-bit PWM on 4 LEDs using FTDI cable or breakout. This example uses the D2XX API. Minimal error checking; written for brevity, not durability. */ #include "stdafx.h" #include#include #include #include #include "ftd2xx.h" #define LED1 0x08 /* CTS (brown wire on FTDI cable) */ #define LED2 0x01 /* TX (orange) */ #define LED3 0x02 /* RX (yellow) */ #define LED4 0x14 /* RTS (green on FTDI) + DTR (on SparkFun breakout) */ int _tmain(int argc, _TCHAR* argv[]) { int i,n; unsigned char data[255 * 256]; FT_HANDLE handle; DWORD bytes; /* Generate data for a single PWM 'throb' cycle */ memset(data, 0, sizeof(data)); for(i=1; i<128; i++) { /* Apply gamma correction to PWM brightness */ n = (int)(pow((double)i / 127.0, 2.5) * 255.0); memset(&data[i * 255], LED1, n); /* Ramp up */ memset(&data[(256 - i) * 255], LED1, n); /* Ramp down */ } /* Copy data from first LED to others, offset as appropriate */ n = sizeof(data) / 4; for(i=0; i (如果我没有弄错的话,这个示例程序应该触发我设备上的每个(或大部分)可位数的引脚.)但是当我尝试构建它时,我得到了一些奇怪的链接器错误:
1>------ Build started: Project: FTDI-Project, Configuration: Debug Win32 ------ 1> FTDI-Project.cpp 1>FTDI-Project.obj : error LNK2019: unresolved external symbol __imp__FT_Write@16 referenced in function _wmain 1>FTDI-Project.obj : error LNK2019: unresolved external symbol __imp__FT_SetBaudRate@8 referenced in function _wmain 1>FTDI-Project.obj : error LNK2019: unresolved external symbol __imp__FT_SetBitMode@12 referenced in function _wmain 1>FTDI-Project.obj : error LNK2019: unresolved external symbol __imp__FT_Open@8 referenced in function _wmain 1>C:\Users\username\Documents\Visual Studio 2010\Projects\FTDI-Project\Debug\FTDI-Project.exe : fatal error LNK1120: 4 unresolved externals ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========对我来说这一切看起来都非常复杂.我希望有人可以帮助我.我真的很感激!