/* demo 2 : DI/O demo of CN2 - CN3 */ /* step 1 : connect CN2 t0 CN3 of PIO-D96 */ /* step 2 : run DEMO2.EXE */ /* step 3 : check the information on screen D/I will same as D/O */ /* -------------------------------------------------------------- */ #include "PIO.H" WORD wBase,wIrq; int main() { int i1,i2,i3,j1,j2,j3; WORD wBoards,wRetVal,t1,t2,t3,t4,t5,t6; WORD wSubVendor,wSubDevice,wSubAux,wSlotBus,wSlotDevice; char c; long i; clrscr(); /* step1 : find address-mapping of PIO/PISO cards */ wRetVal=PIO_DriverInit(&wBoards,0x80,0x01,0x10); /* for PIO-D96 */ printf("\n(1) Threr are %d PIO-D96 Cards in this PC",wBoards); if ( wBoards==0 ) exit(0); printf("\n\n-------------- The Configuration Space --------------"); for(i=0;i "); ShowPioPiso(wSubVendor,wSubDevice,wSubAux); } /* select card_0 */ PIO_GetConfigAddressSpace(0,&wBase,&wIrq,&t1,&t2,&t3,&t4,&t5); /* step2 : enable all D/I/O port */ outportb(wBase,1); /* /RESET -> 1 */ /* step3 : configure I/O direction */ outportb(wBase+0xdc,0x07); /* set CN2 as D/O ports */ outportb(wBase+0xec,0x00); /* set CN3 as D/I ports */ i=1; for (;;) { gotoxy(1,6); i1=i&0xff; i2=(i>>8)&0xff; i3=(i>>16)&0xff; outportb(wBase+0xd0,i1); outportb(wBase+0xd4,i2); outportb(wBase+0xd8,i3); j1=inportb(wBase+0xe0); j2=inportb(wBase+0xe4); j3=inportb(wBase+0xe8); printf("\nD/O = [%2x,%2x,%2x] , D/I = [%2x,%2x,%2x] ",i1,i2,i3,j1,j2,j3); if ((j1!=i1)||(j2!=i2)||(j3!=i3)) { printf("\n\nError ......"); } else printf("\n\nO.K. ......"); i=i<<1; i=i&0x0ffffff; if (i==0) i=1; if (kbhit()!=0) return; } PIO_DriverClose(); }