简体   繁体   English

无法在Centos的FT230X中设置GPIO引脚

[英]Cannot set GPIO pins in FT230X in Centos

I have LEDs connected to CBx pins of FT230X. 我有连接到FT230X的CBx引脚的LED。 I am using libftdi v1.2 to set FT230X CBx pins. 我正在使用libftdi v1.2设置FT230X CBx引脚。 I am tried both 2 bitbang modes: BITMODE_BITBANG and BITMODE_CBUS, but without any result. 我尝试了两种bitbang模式:BITMODE_BITBANG和BITMODE_CBUS,但是没有任何结果。 My code is somewhere about follow: 我的代码如下:

#include <ftdi.h>
#include <err.h>
int main(int argc, char *argv[])
{
  struct ftdi_context ftdi;
  unsigned char x;

  /* Initialize and find device */
  if (ftdi_init(&ftdi) < 0)
    err(1, "ftdi_init");

  if (ftdi_usb_open(&ftdi, 0x0403, 0x6015) < 0)
    err(2, "can't open device");

  /* Enable bitbang */
  if (ftdi_set_bitmode(&ftdi, 0xff, BITMODE_BITBANG) < 0)
    err(3, "can't enable bitbang mode");

  /* Write Yellow */
  x=0x00;
  if (ftdi_write_data(&ftdi, &x, 1) < 0)
    err(5, "can't write");
  sleep(3);
  /* Write Red */
  x=0x01;
  if (ftdi_write_data(&ftdi, &x, 1) < 0)
    err(5, "can't write");
  sleep(3);
  /* Write Green */
  x=0x02;
  if (ftdi_write_data(&ftdi, &x, 1) < 0)
    err(5, "can't write");
  sleep(3);

  /* Close device */
  ftdi_usb_close(&ftdi);
  ftdi_deinit(&ftdi);

  return 0;
}

It should be noted that the same code (exclude product id = 0x6013) works properly for FT4232H. 应该注意的是,相同的代码(不包括产品ID = 0x6013)适用于FT4232H。

I resolved my problem. 我解决了我的问题。 As I mentioned, I need to set CBx pins on FT230X. 如前所述,我需要在FT230X上设置CBx引脚。 For this case in the FT230X should be enabled BITMODE_CBUS mode in EEPROM. 对于这种情况,在FT230X中应在EEPROM中启用BITMODE_CBUS模式。 In BITMODE_CBUS mode, as it described in bitbang_cbus.c example of libftdi, to set these CBx pins should be used only ftdi_set_bitmode() function. 在BITMODE_CBUS模式下,如libftdi的bitbang_cbus.c示例中所述,设置这些CBx引脚仅应使用ftdi_set_bitmode()函数。 Wherein in the second parameter (bitmask) the top nibble controls input/output and the bottom nibble controls the state of the lines set to output. 在第二个参数(位掩码)中,顶部半字节控制输入/输出,底部半字节控制设置为输出的行的状态。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM