DuraCOR 310
Apendix B GPIO Configuration
Page 50 of 51
MNL-0666-01 Rev A3
ECO-5479
Effective: 26 Apr 18
GPIO Example Code
#include
<stdlib.h>
#include
<stdio.h>
#include
<mpsse.h>
static
const
int
FTDI_DID
=
0x6011;
static
const
int
FTDI_INTERFACE
=
INTERFACE_C;
int
main(int
argc,
char
**argv)
{
struct
mpsse_context
*ctx;
ctx
=
Open(0x0403,
FTDI_DID,
BITBANG,
0,
0,
FTDI_INTERFACE,
NULL,
NULL);
//
Set
direction
of
GPIO
SetDirection(ctx,
0x15);
//
Write
the
value
(all
outputs
high
in
this
case)
WritePins(ctx,
0x15);
usleep(100000);
printf("Read
%x\n",
ReadPins(ctx));
Close(ctx);
return
0;
}
Building Example Code
The above code depends on the following three libraries:
1. libUSB
2. libFTDI
3. libMPSSE
Once each of those are install to your system, but the application with:
gcc
–o
test
test.c
‐
lmpsse