/* demo1 : D/O demo for PIO-D48 */ /* step 1 : connect a ADP-37/PCI to CN2 of PIO-D48 */ /* step 2 : connect CN1 of PIO-D48 to ADP-37/PCI in step 1 */ /* (by one DB-37 to DB-37 cable) */ /* step 3 : run DEMO3.EXE */ /* ----------------------------------------------------------- */ #include "PIO.H" WORD wBase,wIrq; WORD wBase2,wIrq2; int main() { int i,j,k,jj,dd; WORD wBoards,wRetVal,j1,j2,j3; WORD wSubVendor,wSubDevice,wSubAux,wSlotBus,wSlotDevice,t1,t2,t3,t4,t5; char c; /* step 1: find address-mapping of PIO/PISO cards */ clrscr(); wRetVal=PIO_DriverInit(&wBoards,0x80,0x01,0x30); /* for PIO-D48 */ printf("\nThrer are %d PIO_D48 Cards in this PC",wBoards); if (wBoards==0) exit(0); printf("\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); /* step 2: enable all D/I/O port */ outportb(wBase,1); /* enable D/I/O */ /* step 3: program 8255-1-PA-PB-PC as output port */ outportb(wBase+0xcc,0x80); /* 8255-1-PA,PB,PC are all output port */ outportb(wBase+0xc0,0); /* 8255-1-PA initial=0 */ outportb(wBase+0xc4,0); /* 8255-1-PB initial=0 */ outportb(wBase+0xc8,0); /* 8255-1-PB initial=0 */ /* step 4: program 8255-2-PA-PB-PC as input port */ outportb(wBase+0xdc,0x9B); /* 8255-2-PA,PB,PC are all input port */ /* step 5: read/write test pattern */ printf("\n----------- Test1: D/I/O CN1-CN2 ------------"); i=1; for (;;) { /* send test pattern to CN1 of PIO_D48 */ outportb(wBase+0xc0,i); outportb(wBase+0xc4,i); outportb(wBase+0xc8,i); printf("\nCN1=output, CN2=input, Output=%x",i); delay(1000); /* delay for D/O settle time */ /* read test pattern to CN2 of PIO_D48 */ j1=inportb(wBase+0xd0); j2=inportb(wBase+0xd4); j3=inportb(wBase+0xd8); printf(" , DI=[%2x,%2x,%2x]",j1,j2,j3); delay(1000); if (kbhit()!=0) { c=getch(); if ((c=='q') || (c=='Q')) break; } i=i<<1; /* next bit */ if (i>0x80) { i=1; c=getch(); if ((c=='Q') || (c=='q')) break; printf("\n----------- Test1: D/I/O CN1-CN2 ------------"); } } printf("\n----------- Test2: D/I/O CN1-CN2 ------------"); /* step 6: program 8255-1-PA-PB-PC as input port */ outportb(wBase+0xcc,0x9B); /* 8255-1-PA,PB,PC are all output port */ /* step 7: program 8255-2-PA-PB-PC as outport port */ outportb(wBase+0xdc,0x80); /* 8255-2-PA,PB,PC are all input port */ outportb(wBase+0xd0,0); /* 8255-1-PA initial=0 */ outportb(wBase+0xd4,0); /* 8255-1-PB initial=0 */ outportb(wBase+0xd8,0); /* 8255-1-PB initial=0 */ /* step 8: read/write test pattern */ i=1; for (;;) { /* send test pattern to CN2 of PIO_D48 */ outportb(wBase+0xd0,i); outportb(wBase+0xd4,i); printf("\nCN1=input, CN2=output, Output=%x",i); outportb(wBase+0xd8,i); delay(1000); /* delay for D/O settle time */ /* read test pattern to CN1 of PIO_D48 */ j1=inportb(wBase+0xc0); j2=inportb(wBase+0xc4); j3=inportb(wBase+0xc8); printf(" , DI=[%2x,%2x,%2x]",j1,j2,j3); delay(1000); if (kbhit()!=0) { c=getch(); if ((c=='q') || (c=='Q')) break; } i=i<<1; /* next bit */ if (i>0x80) { i=1; c=getch(); if ((c=='Q') || (c=='q')) return; printf("\n----------- Test2: D/I/O CN1-CN2 ------------"); } } PIO_DriverClose(); }