/* X100Demo.c: Demo program for X100 board. Compiler: BC++ 3.1, Turbo C ++ 1.01(3.01) (free from http://community.borland.com/museum) Compile mode: large Project: X100Demo.c ..\..\Lib\7188xcl.lib ..\..\LIB\Xboard\X100.lib Hardware: 7188XC + X100 X100: Digital Input: 8 Channels [11/July/2005] by Liam */ #include #include "..\..\LIB\7188xc.h" #include "..\..\LIB\Xboard\X100.h" void main(void) { int iAction, iDIValue, iInChannel, quit; InitLib(); X100_Init(); //Initialize the X100 Print("\r\n"); Print("***************************************\r\n"); Print("| Demo program for 7188XC + X100 |\r\n"); Print("| |\r\n"); Print("| [11/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 all DI ReadBack case 1: iDIValue=X100_Read_All_DI(); Print("Input value=> 0x%04x\r\n\r\n", iDIValue); break; //Read single DI ReadBack case 2: Print("Please select inport channel(0~7): "); Scanf("%d", &iInChannel); if(iInChannel>7) { Puts("Unknow Channel Number!!\r\n\r\n"); break; } iDIValue=X100_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(); } } }