/* X103Demo.c: 7 channels of Isolation Digital Input. Compiler: BC++ 3.1, Turbo C ++ 1.01(3.01) (free from http://community.borland.com/museum) Compile mode: large Project: X103Demo.c ..\..\Lib\7188xcl.lib ..\..\LIB\Xboard\X103.lib Hardware: 7188XC + X103 [19/July/2005] by Liam */ #include #include "..\..\LIB\7188xc.h" #include "..\..\LIB\Xboard\X103.h" void main(void) { int iRet, iAction, quit, iInChannel, iDIValue; InitLib(); X103_Init(); //Initialize the X103 Print("\r\n"); Print("****************************************\r\n"); Print("| Demo program for 7188XC + X103 |\r\n"); Print("| |\r\n"); Print("| [19/July/2005] |\r\n"); Print("****************************************\r\n"); while(iAction!=3) { iAction=0; quit=0; Puts("\r\n"); Puts("1) Read DI (all channels)\r\n"); Puts("2) Read DI (one channel)\r\n"); Puts("\r\n"); Puts("3) Quits demo program\r\n\r\n"); Puts("Choose an option and press [Enter]:"); Scanf("%d", &iAction); Puts("\r\n"); switch(iAction) { // Read DI (all channels) case 1: iDIValue=X103_Read_All_DI(); Print("Input value=> 0x%02x\r\n\r\n", iDIValue); break; // Read DI (one channels) case 2: Print("Please select inport channel(0~6): "); Scanf("%d", &iInChannel); if(iInChannel>6) { Puts("Unknow Channel Number!!\r\n\r\n"); break; } iDIValue=X103_Read_One_DI(iInChannel); if(iDIValue) Print("Channel %d ==> OFF\r\n\r\n", iInChannel); else Print("Channel %d ==> ON\r\n\r\n", iInChannel); break; case 3: default: quit=1; break; } if(!quit) { Puts("Press any key to continue...\r\n"); Getch(); } } }