Appendix
CPC-1814CLD5NA-N
- 37 -
Appendix
GPIO Program Guide
The board provides 8-channel programmable digital I/O pins, four of which are for
input while the other four are for output.
The following provides digital I/O program in C language; please follow the steps
below to implement digital I/O programming:
(1)
Initialize digital I/O
#define INPUT1 0
#define INPUT2 1
#define INPUT3 2
#define INPUT4 3
#define OUTPUT1 0
#define OUTPUT2 1
#define OUTPUT3 2
#define OUTPUT4 3
int BAR=
0x500;
int input[]={
1,6,7,38
};
//PIN
defining
GPI
int output[]={
20,22,27,28
}; //PIN
defining
GPO
for
(i=0;i<=3;i++) //Initialize and organize GPIO
{
initializ_gpio(input[i]);
initializ_gpio(output[i]);
set_in_out(1,input[i]);
set_in_out(0,output[i]);
}