/* ----------------------------------------------------------- */ /* Find all PIO_PISO series cards in this PC system */ /* This program is developed by Turbo C 3.0 */ /* Compiler mode: Large mode */ /* step 1 : plug all PIO_PISO cards into PC */ /* step 2 : run PIO_PISO.EXE */ /* ----------------------------------------------------------- */ #include "PIO.H" WORD wBase, wIrq; void FRB_200_DIO(WORD CH,WORD IO,WORD Group,WORD *Data); WORD wBase; WORD SubVendorID, SubDeviceID, SubAuxID; int main() { WORD wBoards, wRetVal; WORD wSubVendor, wSubDevice, wSubAux, wSlotBus, wSlotDevice; char c; WORD i,r2,r3,r4,r5,r6,r7,r8; WORD r1=1,Dodata,*Didata; int jj=0; WORD kk,dd,l,h,n,m,o,p,q; clrscr(); // clrscr(); // printf("*** PIO_PISO.EXE Rev. 2.33, Mar.10, 2006 ***\n"); // if ( argc > 1) { // if ( 0 == strcmp(argv[1], "/debug") || 0 == strcmp(argv[1], "/DEBUG") // || 0 == strcmp(argv[1], "/Debug") ) // PIO_SetDebugMode( 1 ); // } wRetVal=PIO_DriverInit(&wBoards,0x80,0x01,0xFF); /* for FRB-200 */ printf("\n(1) There are %d FRB-200 Cards in this PC",wBoards); if ( wBoards==0 ) { putch(0x07); putch(0x07); putch(0x07); printf("\n(1) There are no FRB-200 card in this PC !!!"); exit(0); } printf("\n----------------------------------------------------------"); for(i=0; i "); ShowPioPiso(wSubVendor,wSubDevice,wSubAux); } // Step 1: enable all D/I/O port outportb(wBase,1); // enable D/I/O outportb(wBase+0x02,0x0f); // Set AUX 0-7=DO outportb(wBase+0x03,0xff); // Set AUX 2=1 //CH => channel number,range from 0 to 1; //IO => Input=1 or Output=0; //Group =>Module address from 0 to 7;each group = 16bit; //*Data => Output or input Data; Dodata=0; for(;;) { FRB_200_DIO(0,0,0,&Dodata); /* CH,IO,Group,Data */ delay(8); FRB_200_DIO(0,1,0,Didata); gotoxy(10,10); printf("\nDOdata= %4x,Didata=%4x ",Dodata,*Didata); if((*Didata) != Dodata) { gotoxy(25,11); printf("\nDOdata= %4x,Didata=%4x ",Dodata,*Didata); printf(" ==>Error happen!!"); getch(); break; } Dodata++; if(kbhit()) break; } PIO_DriverClose(); return 0; } void FRB_200_DIO(WORD CH,WORD IO,WORD Group,WORD *Data) { //CH => channel number,range from 0 to 1; //IO => Input=1 or Output=0; //Group =>Module address from 0 to 7;each group = 16bit; //*Data => Output or input Data; WORD addr,MSB,LSB; addr = wBase+0xc0; addr = addr + (Group*8); LSB=*Data%256; MSB=*Data/256; outportb(wBase+0x03,0xff); if(IO==0) { switch(CH) { case 0://channel 0 outportb(wBase+0x03,0xfe); // Set AUX 0=0 ,Select /CSM0 outportb(addr,LSB); // Send Data to Address 3 outportb(wBase+0x03,0xfe); // Set AUX 0=0 ,Select /CSM0 outportb(wBase+0x03,0xff); // Set AUX 0=1 outportb(wBase+0x03,0xfe); // Set AUX 0=0 ,Select /CSM0 outportb(addr+4,MSB); // Send Data to Address 3 outportb(wBase+0x03,0xfe); // Set AUX 0=0 ,Select /CSM0 break; case 1://channel 1 outportb(wBase+0x03,0xfb); // Set AUX 2=0 ,Select /CSM1 outportb(addr,LSB); // Send Data to Address 1 outportb(wBase+0x03,0xfb); // Set AUX 2=0 ,Select /CSM1 outportb(wBase+0x03,0xff); // Set AUX 2=1 outportb(wBase+0x03,0xfb); // Set AUX 2=0 ,Select /CSM1 outportb(addr+4,MSB); // Send Data to Address 1 outportb(wBase+0x03,0xfb); // Set AUX 2=0 ,Select /CSM1 break; default: break; } } else //Input { switch(CH) { case 0://channel 0 outportb(wBase+0x03,0xfe); // Set AUX 2=0 ,Select /CSM0 LSB=inportb(addr); // Send Data to Address 3 outportb(wBase+0x03,0xfe); // Set AUX 2=0 ,Select /CSM0 outportb(wBase+0x03,0xff); // Set AUX 2=1 outportb(wBase+0x03,0xfe); // Set AUX 2=0 ,Select /CSM0 MSB=inportb(addr+4); // Send Data to Address 3 outportb(wBase+0x03,0xfe); // Set AUX 2=0 ,Select /CSM0 *Data=(MSB*256)+LSB; break; case 1://channel 1 outportb(wBase+0x03,0xfb); // Set AUX 2=0 ,Select /CSM1 LSB=inportb(addr); // Send Data to Address 1 outportb(wBase+0x03,0xfb); // Set AUX 2=0 ,Select /CSM1 outportb(wBase+0x03,0xff); // Set AUX 2=1 outportb(wBase+0x03,0xfb); // Set AUX 2=0 ,Select /CSM1 MSB=inportb(addr+4); // Send Data to Address 1 outportb(wBase+0x03,0xfb); // Set AUX 2=0 ,Select /CSM1 *Data=(MSB*256)+LSB; break; default: break; } } outportb(wBase+0x03,0xff); }