/* ------------------------------------------------------------ */ /* demo 2 : D/O demo for CN1 ~ CN6 */ /* step 1 : connect a DB-24C to CN1 ~ CN6 of PIO-D144 */ /* step 2 : run DEMO2.EXE */ /* step 3 : check the LED's of DB-24C will turn on sequentially */ /* ------------------------------------------------------------ */ #include "PIO.H" int main() { int i,j,k,jj; WORD wBoards,wRetVal; WORD wBase,wIrq,wSubVendor,wSubDevice,wSubAux,wSlotBus,wSlotDevice; char c; clrscr(); PIO_DriverInit(&wBoards,0x80,0x01,0x00); /* for PIO-D144 */ printf("\n(1) Threr are %d PIO-D144 Cards in this PC",wBoards); if ( wBoards==0 ) { putch(0x07); putch(0x07); putch(0x07); printf("(1) There are no PIO-D144 card in this PC !!!\n"); exit(0); } printf("\n(2) The Configuration Space -> wBase"); for(i=0; i all D/O ports are output port */ /* step 2: enable all D/I/O port */ outp(wBase,1); /* enable D/I/O */ /* step 3: select the active port */ /* step 4: send initial-value to D/O latch register of active port */ /* step 5: repeat for all D/O ports */ for (i=0; i<18; i++) { outp(wBase+0xc4,i); /* select CN1 to CN6 port */ outp(wBase+0xc0,0); /* set 8-bit D/O latch register */ } /* step 6: configure all I/O port */ outp(wBase+0xc8,0x00); /* CN1 to CN2 port are all output */ outp(wBase+0xcc,0x00); /* CN3 to CN4 port are all output */ outp(wBase+0xd0,0x00); /* CN5 to CN6 port are all output */ /* K=PA/PB/PC */ /* CN1 : K=0/1/2 --> key in 0 */ /* CN2 : K=3/4/5 --> key in 3 */ /* CN3 : K=6/7/8 --> key in 6 */ /* CN4 : K=9/10/11 --> key in 9 */ /* CN5 : K=12/13/14 --> key in 12 */ /* CN6 : K=15/16/17 --> key in 15 */ printf("\nk="); scanf("%d",&k); for (jj=k; jj<(3+k); jj++) /* PA/PB/PC */ { outp(wBase+0xc4,jj); /* select the active port */ printf("\nSelect Port-%d",jj); outp(wBase+0xc0,0x55); /* D/O=0x55 */ printf(", D/O=0x55"); getch(); outp(wBase+0xc0,0xAA); /* D/O=0xAA */ printf(", D/O=0xAA"); getch(); outp(wBase+0xc0,0x1); getch(); /* PA0/PB0/PC0 */ outp(wBase+0xc0,0x2); getch(); /* PA1/PB1/PC1 */ outp(wBase+0xc0,0x4); getch(); /* PA2/PB2/PC2 */ outp(wBase+0xc0,0x8); getch(); /* PA3/PB3/PC3 */ outp(wBase+0xc0,0x10); getch(); /* PA4/PB4/PC4 */ outp(wBase+0xc0,0x20); getch(); /* PA5/PB5/PC5 */ outp(wBase+0xc0,0x40); getch(); /* PA6/PB6/PC6 */ outp(wBase+0xc0,0x80); getch(); /* PA7/PB7/PC7 */ } PIO_DriverClose(); }