4.3Demo2: Use D/O of CN1~CN6

/* ------------------------------------------------------------

*/

/* demo 2 : D/O demo for CN1 ~ CN6

*/

/* step 1 : connect a OME-DB-24C to CN1 ~ CN6 of OME-PIO-D144

*/

/* step 2 : run DEMO2.EXE

*/

/* step 3 : check the LED's of OME-DB-24C 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 OME-PIO-D144 */ printf("\n(1) There are %d OME-PIO-D144 Cards in this PC",wBoards); if ( wBoards==0 )

{

putch(0x07); putch(0x07); putch(0x07);

printf("(1) There are no OME-PIO-D144 card in this PC !!!\n");

exit(0);

}

printf("\n(2) The Configuration Space -> wBase"); for(i=0; i<wBoards; i++)

{

PIO_GetConfigAddressSpace(i,&wBase,&wIrq,&wSubVendor,&wSubDevice, &wSubAux,&wSlotBus,&wSlotDevice);

printf("\nCard_%d: wBase=%x,wIrq=%x,subID=[%x,%x,%x],SlotID=[%x,%x]" ,i,wBase,wIrq,wSubVendor,wSubDevice,wSubAux,wSlotBus,wSlotDevice);

}

/* select card_0 */

PIO_GetConfigAddressSpace(0,&wBase,&wIrq,&wSubVendor,&wSubDevice,

 

&wSubAux,&wSlotBus,&wSlotDevice);

/* step 1: make sure which ports are D/O ports

 

*/

/* in this demo --> 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

*/

 

 

 

 

 

OME-PIO-D144 User’s Manual (Ver.2.1, Sep/2001)

 

----- 37

Page 39
Image 39
Omega OME-PIO-D144 manual Demo2 Use D/O of CN1~CN6