已安装Ftdilib,但ftdi_enable_bitbang“未在此范围内声明”

时间:2014-03-10 23:59:15

标签: c++ compilation codeblocks

我安装了ftdilib,我正在尝试编译这段代码:

/* hello-ftdi.c: flash LED connected between CTS and GND.
  This example uses the libftdi API.
 Minimal error checking; written for brevity, not durability. */

#include <stdio.h>
#include <ftdi.h>

#define LED 0x08  /* CTS (brown wire on FTDI cable) */

int main()
 {
 unsigned char c = 0;
struct ftdi_context ftdic;

/* Initialize context for subsequent function calls */
ftdi_init(&ftdic);

/* Open FTDI device based on FT232R vendor & product IDs */
if(ftdi_usb_open(&ftdic, 0x0403, 0x6001) < 0) {
    puts("Can't open device");
    return 1;
}

/* Enable bitbang mode with a single output line */
ftdi_enable_bitbang(&ftdic, LED);

/* Endless loop: invert LED state, write output, pause 1 second */
for(;;) {
    c ^= LED;
    ftdi_write_data(&ftdic, &c, 1);
    sleep(1);
}
}

但是有错误:ftdi_enable_bitbang未在此范围内声明 这是唯一的错误。

为什么这会不断弹出?

1 个答案:

答案 0 :(得分:1)

快速查看当前版本的ftdi.h,显示ftdi_enable_bitbang没有声明。 ftdi_enable_bitbang在被弃用两年后被删除。改为使用ftdi_set_bitmode。