libftdi Archives

Subject: Strange behaviour of ftdi_set_bitmode

From: ivan <mcvanili@xxxxxxxxx>
To: libftdi@xxxxxxxxxxxxxxxxxxxxxxx
Date: Wed, 12 Jul 2017 20:18:20 +0300
Hi,

I'm trying to configure FT2232D device for SPI mode. The strange thing is that after configuration with

ftdi_set_bitmode(ftdi,0, BITMODE_MPSSE);

the device accepts any commands, even if they are not used in FTDI datasheets. For example, in datasheet it is proposed to use 0xAB opcode to get "Bad Command" (0xFA) response, however, device doesn't reply meaning that it accepts the command. I tried to check if the device works with classical BITMODE_BITBANG, here everything was fine and I was able to receive the byte on the output. Then I tried just to send a random bitmode pattern (like 0xAF) with the ftdi_set_bitmode and device still accepted it (return value of the command is 0). Is it a feature of the libftdi that wrong commands are ignored (or substituted with correct one), or it is just something weird in my code?

  ftdi = ftdi_new();
  versionFTDI = ftdi_get_library_version();
printf("Initialized libftdi %s (major: %d, minor: %d, micro: %d, snapshot ver: %s)\n", versionFTDI.version_str, versionFTDI.major, versionFTDI.minor, versionFTDI.micro, versionFTDI.snapshot_str); //Output:Initialized libftdi 1.4rc1 (major: 1, minor: 4, micro: 0, snapshot ver: v1.4rc1-6-g7c2a685)
  exit_code = ftdi_usb_open(ftdi, FT2232D_vendor, FT2232D_product);
//works as expected, i.e. fails if device is not connected or not enough rights to access it
  exit_code = ftdi_usb_reset(ftdi);
     //works as expected
  exit_code = ftdi_set_error_char(ftdi, 0, 0);
  exit_code = ftdi_set_event_char(ftdi, 0, 0);
  exit_code = ftdi_set_latency_timer(ftdi, 255);
  exit_code = ftdi_setflowctrl(ftdi, SIO_RTS_CTS_HS);
  exit_code = ftdi_set_bitmode(ftdi,0, BITMODE_MPSSE);
//ftdi_set_bitmode accepts any mode even if it is not defined in ftdi_mpsse_mode; exit_code is always 0
  buffer[0] = 0xAB;
  exit_code = ftdi_write_data(ftdi, buffer, 1);
     //exit_code == 1
  msleep(200);
  exit_code = ftdi_read_data(ftdi, buffer, 1);
     //exit_code==0; buffer is empty

Thank you in advance

Best regards,
Ivan

--
libftdi - see http://www.intra2net.com/en/developer/libftdi for details.
To unsubscribe send a mail to libftdi+unsubscribe@xxxxxxxxxxxxxxxxxxxxxxx
Current Thread
  • Strange behaviour of ftdi_set_bitmode, ivan <=