beautypg.com

Demo3: interrupt demo1, Nterrupt demo, 4 demo3: interrupt demo1 – Omega OME-PIO-D144 User Manual

Page 41

background image

4.4 Demo3: Interrupt demo1

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

/* demo 3 : count high pulse of CN1_PC0

*/

/* (initial Low & active High)

*/

/* step 1 : run demo3.exe

*/

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

#include "PIO.H"

#define A1_8259 0x20

#define A2_8259 0xA0

#define EOI 0x20

WORD init_low();

static void interrupt irq_service();

int COUNT,irqmask,now_int_state;

WORD wBase,wIrq;

int main()

{

int i,j;

WORD wBoards,wRetVal;

WORD wSubVendor,wSubDevice,wSubAux,wSlotBus,wSlotDevice;

char c;

DWORD dwVal;

clrscr();

PIO_DriverInit(&wBoards,0x80,0x01,0x00);

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) Show the Configuration Space of all OME-PIO-D144:");

for(i=0; 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, wBaseAddr=%x ***",wBaseAddr);

COUNT=0;

outp(wBase+0xc8,0xff); /* port_0 to port_5 are all input */

printf("\n(4) *** show the count of High_pulse **\n");

init_low();

for (;;)

{

printf("\nCOUNT=%d",COUNT);

if (kbhit()!=0) {getch(); break;}

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

----- 39

}