Created
June 17, 2020 12:20
-
-
Save krish-iyer/13a36029c8df7a888b4a83fdd05690a3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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