Ftdilib已安装,但ftdi_enable_bitbang "was not declared in this scope"

Ftdilib installed but ftdi_enable_bitbang "was not declared in this scope"

本文关键字:was not in scope this declared enable 安装 Ftdilib ftdi bitbang      更新时间:2023-10-16

我安装了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没有在这个范围内声明这是唯一的错误。

为什么这个总是跳出来?

快速查看一下当前版本的ftdi.h,就会发现ftdi_enable_bitbang没有声明。Ftdi_enable_bitbang在被弃用两年后已被删除。请使用ftdi_set_bitmode