FTDI Community

Please login or register.

Login with username, password and session length.
Advanced Search  

News:

Welcome to the FTDI Community!

Please read our Welcome Note

Technical Support enquires
please contact the team
@ FTDI Support


New Bridgetek Community is now open

Please note that we have created the Bridgetek Community to discuss all Bridgetek products e.g. EVE, MCU.

Please follow this link and create a new user account to get started.

Bridgetek Community

Author Topic: FT4232H I2C Library recommendations  (Read 7580 times)

dania

  • Newbie
  • *
  • Posts: 11
    • View Profile
FT4232H I2C Library recommendations
« on: August 02, 2021, 08:42:19 AM »

Hello,
for I2C are two libraryes: FTCI2C.dll and LibMPSSE.dll. Which library do you recommend? I didn't find how to work with GPIOL lines in libmpsse.

I2C and GPIOs at Port A:
ADBUS0 = SCL, ADBUS1 and ADBUS2 wired together = SDA, ADBUS4 - ADBUS6 = inputs, ADBUS7 = output (drive relay via transistor)
Logged

FTDI Community

  • Administrator
  • Hero Member
  • *****
  • Posts: 892
    • View Profile
Re: FT4232H I2C Library recommendations
« Reply #1 on: August 02, 2021, 11:47:16 AM »

Hello,

The FTCI2C.dll is no longer supported so we would recommend using the LibMPSSE.dll for new projects. however unfortunately the LibMPSSE helper library only supports GPIO functionality on the GPIOH pins.

There are two options for programming the MPSSE on the device to act as a SPI/I2C bridge, the first being to utilise LibMPSSE
The second option is to use raw D2XX commands to issue opcodes and data to the device, please see the following for a list of MPSSE opcodes:
https://www.ftdichip.com/Support/Documents/AppNotes/AN_108_Command_Processor_for_MPSSE_and_MCU_Host_Bus_Emulation_Modes.pdf

You will need to utilise a D2XX approach if you wish to utilise the GPIOL pins in your application.

Please see the following for an example of using raw D2XX commands in an I2C MPSSE application:
https://ftdichip.com/wp-content/uploads/2020/08/AN_113_FTDI_Hi_Speed_USB_To_I2C_Example.pdf

The MPSSE Basics application note may also be useful to you:
https://www.ftdichip.com/Support/Documents/AppNotes/AN_135_MPSSE_Basics.pdf

Best Regards,
FTDI Community
Logged

dania

  • Newbie
  • *
  • Posts: 11
    • View Profile
Re: FT4232H I2C Library recommendations
« Reply #2 on: August 02, 2021, 02:07:35 PM »

I want to add to ftdi_mid.c:
Code: [Select]
FTDI_API FT_STATUS FT_WriteGPIOL(FT_HANDLE handle, uint8 dir, uint8 value)
{
FT_STATUS status;
uint8 buffer[3];
DWORD bytesWritten = 0;
uint32 bufIdx = 0;

FN_ENTER;
buffer[bufIdx++] = MPSSE_CMD_SET_DATA_BITS_LOWBYTE;
buffer[bufIdx++] = value;
buffer[bufIdx++] = dir;

status = varFunctionPtrLst.p_FT_Write(handle,buffer,bufIdx,&bytesWritten);
FN_EXIT;
return status;
}

FTDI_API FT_STATUS FT_ReadGPIO(FT_HANDLE handle,uint8 *value)
{
FT_STATUS status;
uint8 buffer[2];
DWORD bytesTransfered = 0;
DWORD bytesToTransfer = 0;
UCHAR readBuffer[10];

FN_ENTER;
buffer[bytesToTransfer++] = MPSSE_CMD_GET_DATA_BITS_LOWBYTE;
buffer[bytesToTransfer++] = MPSSE_CMD_SEND_IMMEDIATE;

status = varFunctionPtrLst.p_FT_Write(handle,buffer,bytesToTransfer,\
&bytesTransfered);
CHECK_STATUS(status);
DBG(MSG_DEBUG,"bytesToTransfer=0x%x bytesTransfered=0x%x\n",\
(unsigned)bytesToTransfer,(unsigned)bytesTransfered);
bytesToTransfer = 1;
bytesTransfered = 0;
status = varFunctionPtrLst.p_FT_Read(handle,readBuffer,bytesToTransfer,\
&bytesTransfered);
CHECK_STATUS(status);
DBG(MSG_DEBUG,"bytesToTransfer=0x%x bytesTransfered=0x%x\n",\
(unsigned)bytesToTransfer,(unsigned)bytesTransfered);
if(bytesToTransfer != bytesTransfered)
status = FT_IO_ERROR;
*value = readBuffer[0];

FN_EXIT;
return status;
}


and compile a new dll.
Logged

FTDI Community

  • Administrator
  • Hero Member
  • *****
  • Posts: 892
    • View Profile
Re: FT4232H I2C Library recommendations
« Reply #3 on: August 02, 2021, 03:41:20 PM »

Hello,

The LibMPPSE library is essentially a wrapper library for standard D2XX API calls, the source is available is required, and it appears you already have access to this.
Please fell free to modify the LibMPSSE source code as required for your given application and produce a custom DLL.

Best Regards,
FTDI Community
Logged