Application Note
AN_329 User Guide For LibFT4222
Version 1.5
Document Reference No.: FT_001060 Clearance No.: FTDI#406
16
Product Page
Document Feedback Copyright © Future Technology Devices International Limited
Parameters:
Trigger condition. One of the following:
GPIO_TRIGGER_RISING
GPIO_TRIGGER_FALLING
GPIO_TRIGGER_LEVEL_HIGH
GPIO_TRIGGER_LEVEL_LOW
Return Value:
FT4222_OK if successful, otherwise the return value is an FT error code.
Error code:
FT4222_DEVICE_NOT_SUPPORTED: This device is not a FT4222 chip.
FT4222_DEVICE_NOT_OPENED: The initialization API is not called.
FT4222_INTERRUPT_NOT_SUPPORTED: interrupt/wakeup is disabled.
FT4222_INVALID_PARAMETER: parameter trigger is invalid
Example:
// example 1: This test code is running in Mode 0.
// sending notification while there is an interrupt happen.
FT_HANDLE ftHandle = NULL;
FT_STATUS ftStatus;
FT4222_STATUS ft4222Status;
ftStatus = FT_OpenEx("FT4222 B",FT_OPEN_BY_DESCRIPTION, &ftHandle);
if (FT_OK != ftStatus)
{
// open failed
return;
}
HANDLE hRxEvent;
hRxEvent = CreateEvent(
NULL,
false, // auto-reset event
false, // non-signalled state
NULL ); ftStatus = FT_SetEventNotification(ftHandle, FT_EVENT_RXCHAR,
hRxEvent);
if (FT_OK != ftStatus)
{
// FT_SetEventNotification failed
return ;
}
GPIO_Dir gpioDir[4];
gpioDir[0] = GPIO_OUTPUT;
gpioDir[1] = GPIO_OUTPUT;
gpioDir[2] = GPIO_OUTPUT;
gpioDir[3] = GPIO_INPUT;
// we must initialize gpio before FT4222_SetInterruptTrigger, because interrupt data is transmitted
by gpio interface.
FT4222_GPIO_Init(ftHandle, gpioDir);
// enable interrupt
FT4222_SetWakeUpInterrupt(ftHandle, true);
// setup interrupt trigger level
FT4222_SetInterruptTrigger(ftHandle, GPIO_TRIGGER_RISING);
while(1)