Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <time.h>
#include <string.h>
#include <ctype.h>
#include <stdbool.h>
#include <unistd.h>
#include <math.h>
#include "ftd2xx.h"
#include "libft4222.h"
void FT_init(void);
FT_HANDLE ftHandle = NULL;
FT_STATUS ftStatus;
FT4222_STATUS ft4222Status;
GPIO_Dir gpioDir[4];
int main(){
FT_init();
while(1){
BOOL value;
if(FT4222_GPIO_Read(ftHandle, (GPIO_Port)GPIO_PORT3, &value) == FT4222_OK)
{
if(value == true)
printf("int pin high %d\n",value);
}
}
FT4222_UnInitialize(ftHandle);
FT_Close(ftHandle);
return 0;
}
void FT_init(){
ftStatus = FT_Open(0, &ftHandle);
if (FT_OK != ftStatus)
{
// open failed
printf("failed to open the device\n");
return;
}
gpioDir[0] = GPIO_INPUT;
gpioDir[1] = GPIO_INPUT;
gpioDir[2] = GPIO_INPUT;
gpioDir[3] = GPIO_INPUT;
ft4222Status = FT4222_GPIO_Init(ftHandle, gpioDir);
//disable suspend out , enable gpio 2
if(ft4222Status != FT4222_OK){
printf("GPIO init failed ftstatus = %d\n",ft4222Status);
}
FT4222_SetSuspendOut(ftHandle, false);
//disable interrupt , enable gpio 3
if(ft4222Status != FT4222_OK){
printf("GPIO init failed");
}
FT4222_SetWakeUpInterrupt(ftHandle, false);
//FT4222_GPIO_Write(ftHandle, GPIO_PORT3, 1);
if(ft4222Status != FT4222_OK){
printf("GPIO init failed");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment