/* X102Demo.c: The X102Demo program is 2 channel outputs with Relay for X102 board. Compiler: BC++ 3.1, Turbo C ++ 1.01(3.01) (free from http://community.borland.com/museum) Compile mode: large Project: X102Demo.c ..\..\lib\7188xcl.lib ..\..\lib\XBoard\X102.lib Hardware: 7188XC + X102 X102: 2 channels outputs with Relay [13/July/2005] by Liam */ #include #include #include "..\..\lib\7188xc.h" #include "..\..\lib\XBoard\X102.h" void main(void) { int iAction, iStatus, iOutChannel, iDOValue=0, iRet, quit; InitLib(); X102_Init(); //Initialize the X102 Print("\r\n"); Print("****************************************\r\n"); Print("| Demo program for 7188XC + X102 |\r\n"); Print("| |\r\n"); Print("| [13/July/2005] |\r\n"); Print("****************************************\r\n"); while(iAction!=5) { iAction=0; quit=0; Puts("\r\n"); Puts("1) Write Realy Output (all channels)\r\n"); Puts("2) Write Realy Output (one channel)\r\n"); Puts("3) Realy Output Readback (all channels)\r\n"); Puts("4) Realy Output Readback (one channel)\r\n"); Puts("\r\n"); Puts("5) Quits demo program\r\n\r\n"); Puts("Choose an option and press [Enter]:"); Scanf("%d", &iAction); Puts("\r\n"); switch(iAction) { // Write Realy Output (all channels) case 1: Print("Please input Output value(0 ~ 0x03): "); Scanf("%x", &iDOValue); X102_Write_All_DO(iDOValue); Print("Output value=> 0x%02x\r\n\r\n", iDOValue); break; // Write Realy Output (one channels) case 2: Print("Please select outport channel(0~1) and status(0:OFF, 1:ON)\r\n"); Print("Channel number and status:"); Scanf("%d %d", &iOutChannel, &iStatus); if(iOutChannel>1) { Puts("Unknow Channel Number!!\r\n\r\n"); break; } X102_Write_One_DO(iOutChannel, iStatus); Print("Channel %d ==> %s\r\n\r\n", iOutChannel, (iStatus>=1)?"ON":"OFF"); break; // Realy Output Readback (all channels) case 3: iDOValue=X102_Read_All_DO(); Print("Digital Output ReadBack=> 0x%02x\r\n\r\n", iDOValue); break; // Realy Output Readback (one channels) case 4: Print("Please select outport channel(0~1): "); Scanf("%d", &iOutChannel); if(iOutChannel>1) { Puts("Unknow Channel Number!!\r\n\r\n"); break; } iRet=X102_Read_One_DO(iOutChannel); if(iRet) Print("Channel %d ==> ON\r\n\r\n", iOutChannel); else Print("Channel %d ==> OFF\r\n\r\n", iOutChannel); break; case 5: default: quit=1; break; } if(!quit) { Puts("Press any key to continue...\r\n"); Getch(); } } }