/* X104DI.c: The demo program is input for X104 8 channels DI/O board. Compiler: BC++ 3.1, Turbo C ++ 1.01(3.01) (free from http://community.borland.com/museum) Compile mode: large Project: X104DI.c ..\..\Lib\7188xcl.lib ..\..\Lib\Xboard\X104.lib Hardware: 7188XC + X104 X104: 8 channels. Each channel can be program to DI/DO. Note: Please remove the external signal which connects to X104, before changing the status of channels from DI to DO mode [18/Dec/2002] [20/July/2005] by Liam */ #include #include "..\..\lib\7188xc.h" #include "..\..\lib\Xboard\X104.h" void main(void) { int iAction, iStatus, iOutChannel, iDOValue=0, iRet, quit; InitLib(); X104_Init(_DI_); //Initialize the X104, and set all channels to DI Print("\r\n"); Print("****************************************\n\r"); Print("| Demo program for 7188XC + X104 |\n\r"); Print("| |\n\r"); Print("| [20/July/2005] |\n\r"); Print("****************************************\n\r"); while(iAction!=3) { iAction=0; quit=0; Puts("\r\n"); Puts("1) Write DO (all channels)\r\n"); Puts("2) Write DO (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=X104_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~7): "); Scanf("%d", &iInChannel); if(iInChannel>7) { Puts("Unknow Channel Number!!\r\n\r\n"); break; } iDIValue=X104_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...\n\r"); Getch(); } } }