/* X106DO.c: The Demo program for X106 Compiler: BC++ 3.1, Turbo C ++ 1.01(3.01) (free from http://community.borland.com/museum) 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; Print("\r\n"); Print("****************************************\r\n"); Print("| Demo program for 7188XC + X106 |\r\n"); Print("| |\r\n"); Print("| [19,Nov,2002] |\r\n"); Print("****************************************\r\n"); while(iAction!=3) { Print("\r\n"); Print("1) Run Digital Input\r\n"); Print("2) Run Digital Output\n\r"); Print("\n\r"); Print("3) Quits Demo Program\r\n\r\n"); Print("Choose an option and press [Enter]:"); Scanf("%d", &iAction); Print("\r\n"); /***********************/ /* Digital Output */ /***********************/ if(iAction==2) { for(;;) { Print("\r\n"); Print("Please select outport channel( 0 and 1 ) or Press Q to quits\r\n"); Print("Channel Number:"); Scanf("%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\r\n"); Getch(); SetDio14Low(); /* Channel_0 Low */ Print("DO Channel_0 Low\r\n"); break; case '1': SetDio4Dir(0); /* Set DO ouptut */ SetDio4High(); /* Channel_0 High */ Print("DO Channel_1 High and press any key to Low\r\n"); Getch(); SetDio4Low(); /* Channel_0 Low */ Print("DO Channel_1 Low\r\n"); 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(); } } }