/* ----------------------------------------------------------- */ /* DEMO 2 : D/I/O test by itself. */ /* Compiler: Borland C++ 3.1, Mode Large */ /* step 1 : connect a 20-pin flat cable between CON1 & CON2 */ /* step 2 : run DEMO2.EXE */ /* ----------------------------------------------------------- */ #include "P1002.H" WORD P1002_Do(WORD wDo); void P1002_Di(WORD *wDi); WORD wBaseAddr,wIrq,wPLX; void main() { int i,j,k; WORD wBoards,wRetVal; char c; clrscr(); wRetVal=P1002_DriverInit(&wBoards); printf("\n(1) Threr are %d PCI-1002 Cards in this PC",wBoards); if ( wBoards==0 ) { putch(0x07); putch(0x07); putch(0x07); printf("(1) There are no PCI-1002 card in this PC !!!\n"); exit(0); } printf("\n(2) Show the Configuration Space of all PCI-1002:"); for(i=0; i1) P1002_GetConfigAddressSpace(1,&wBaseAddr,&wIrq,&wPLX); /* card_1 */ else P1002_GetConfigAddressSpace(0,&wBaseAddr,&wIrq,&wPLX); /* card_0 */ printf("\n(3) *** D/I/O test , wBaseAddr=%x ***",wBaseAddr); j=1; for(i=0; i<16; i++) { P1002_Do(j); P1002_Di(&k); printf("\nTEST_%2d --> DO = %x , DI=%x",i,j,k); if (j!=k) printf(" <-- TEST ERROR"); else printf(" <-- TEST OK"); j=j<<1; if (j==0) j=1; } P1002_DriverClose(); } /* ----------------------------------------------------------- */ WORD P1002_Do(WORD wDo) { outpw(wBaseAddr+0x20,wDo); return(NoError); } /* ----------------------------------------------------------- */ void P1002_Di(WORD *wDi) { WORD wRetVal; (*wDi)=(inpw(wBaseAddr+0x20))&0xffff; }