Demo1: use d/o of cn1, 2 demo1: use d/o of cn1 – Omega OME-PIO-D144 User Manual

Page 37

Advertising
background image

4.2 Demo1: Use D/O of CN1

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

/* demo 1 : D/O demo */

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

/* step 2 : run DEMO1.EXE */

/* step 3 : check the LEDs of OME-DB-24C turn on sequentially */

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

#include "PIO.H"

int main()

{

int i;

WORD wBoards;

WORD wBase,wIrq,wSubVendor,wSubDevice,wSubAux,wSlotBus,wSlotDevice;

char c;

clrscr();

PIO_DriverInit(&wBoards,0x80,0x01,0x00); /* for OME-PIO-D144 */

printf("\n(1) Threr 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);

printf("\n(3) *** Card_0 D/O test, wBase=%x ***",wBase);

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

*/

/* in this demo --> only CN1_PA, CN1_PB, CN1_PC are D/O port */

/* step 2: enable all D/I/O port

*/

outp(wBase,1); /* enable D/I/O

*/

/* step 3: select the active port

*/

outp(wBase+0xc4,0); /* select CN1_PA

*/

/* step 4: send initial-value to D/O latch register of active port */

outp(wBase+0xc0,0); /* set CN1_PA0 to CN1_PA7 to 0 */

/* step 5: repeat for all D/O ports */

outp(wBase+0xc4,1); /* select CN1_PB

*/

outp(wBase+0xc0,0); /* set CN1_PB0 to CN1_PB7 to 0 */

outp(wBase+0xc4,2); /* select CN1_PC

*/

outp(wBase+0xc0,0); /* set CN1_PC0 to CN1_PC7 to 0 */

/* step 6: configure all I/O port */

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

----- 35

outp(wBase+0xc8,0x00); /* CN1 to CN2 port are all output */

Advertising