/* X105DI.c: The X105DI program is input for X105 8 channels DI/O board. (single channel programmable) Compiler: BC++ 3.1, Turbo C ++ 1.01(3.01) (free from http://community.borland.com/museum) Compile mode: large Project: X105DI.c ..\..\Lib\7188xcl.lib ..\..\lib\Xboard\X105.lib Hardware: 7188XC + X105 X105: 8 channels. Each channel can be program to DI/DO. Note: Please remove the external signal which connects to X105, before changing the status of channels from DI to DO mode [02/Aug/2002] [20/July/2005] by Liam */ #include #include "..\..\lib\7188xc.h" #include "..\..\lib\Xboard\X105.h" void main(void) { int iAction, iStatus, iInChannel, iDIValue, iRet, quit; InitLib(); X105_Init(_DI_); //Initialize the X105, and set all channels to DI Print("\r\n"); Print("*****************************************\r\n"); Print("| Demo program for 7188XC + X105 |\r\n"); Print("| |\r\n"); Print("| [20/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=X105_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); iDIValue=X105_Read_One_DI(iInChannel); if(iDIValue>=0) { if(iDIValue) Print("Channel %d ==> OFF\r\n\r\n", iInChannel); else Print("Channel %d ==> ON\r\n\r\n", iInChannel); } else Puts("Unknow Channel Number!!\r\n\r\n"); break; case 3: default: quit=1; break; } if(!quit) { Puts("Press any key to continue...\r\n"); Getch(); } } }