/* X106DO.c: The Demo program for X106 Compiler: MSC 6.0 MSVC 1.52 Compile mode: large Project: X106DO.c ..\..\Lib\7188xcl.lib Hardware: 7188XC + X106 X106: Can be used as 2 channels DO or 3 channels DI Note: Used Jumper to select D/I or D/O function [02/Aug/2002] [20/July/2005] by Liam */ #include #include "..\..\lib\7188xc.h" void main(void) { int iAction=1,i; unsigned int data[4]; char iValue, c; char buf[100]; InitLib(); Print("\r\n"); Print("****************************************\n\r"); Print("| Demo program for 7188XC + X106 |\n\r"); Print("| |\n\r"); Print("| [19,Nov,2002] |\n\r"); Print("****************************************\n\r"); while(iAction!=3) { Print("\r\n"); Print("1) Run Digital Input \n\r"); Print("2) Run Digital Output \n\r"); Print("\n\r"); Print("3) Quits Demo Program\n\r\n\r"); Print("Choose an option and press [Enter]:"); LineInput(buf,99); sscanf(buf, "%d", &iAction); Print("\n\r"); /***********************/ /* Digital Output */ /***********************/ if(iAction==2) { for(;;) { Print("\n\r"); Print("Please select outport channel( 0 and 1 ) or Press Q to quits\n\r"); Print("Channel Number:"); LineInput(buf,99); sscanf(buf, "%c",&iValue); switch(iValue) { case '0': SetDio14Dir(0); /* Set DO ouptut */ SetDio14High(); /* Channel_0 High */ Print("DO Channel_0 High, and press any key to Low\n\r"); Getch(); SetDio14Low(); /* Channel_0 Low */ Print("DO Channel_0 Low\n\r"); break; case '1': SetDio4Dir(0); /* Set DO ouptut */ SetDio4High(); /* Channel_0 High */ Print("DO Channel_1 High and press any key to Low\n\r"); Getch(); SetDio4Low(); /* Channel_0 Low */ Print("DO Channel_1 Low\n\r"); break; } if (Kbhit()!=0) iValue=Getch(); if (iValue=='q'|| iValue=='Q') break; } } /***********************/ /* Digital Intput */ /***********************/ if(iAction==1) { SetTo1Dir(1); SetTo0Dir(1); SetDio9Dir(1); data[2]=GetTo0(); //channel 2 data[1]=GetTo1(); //channel 1 data[0]=GetDio9(); //channel 0 for (i=0; i<=2; i++) { Print("Channel[%d]=> %s\r\n", i, (data[i]==0)?"Low":"High"); } } if(iAction!=3) { Puts("\r\nPress any key to continue...\r\n"); Getch(); } } }