/* ----------------------------------------------------------- */ /* DEMO 3 : AdPolling */ /* Compiler: Borland C++ 3.1, Mode Large */ /* Output Code: HEX code */ /* ----------------------------------------------------------- */ #include "P1002.H" WORD wBaseAddr,wIrq; //------------------------------------------------------- WORD P1002_Delay(WORD wDownCount) { WORD h,l; int count; wDownCount &= 0x7fff; if (wDownCount<1) wDownCount=1; /* Clock in=4M --> count 4000 = 1 ms ,count 1 = 0.25 us */ l=wDownCount&0xff; wDownCount=wDownCount / 256; h=wDownCount&0xff; outp(wBaseAddr+3*4,0xB0); /* mode_0, counter_2 */ outp(wBaseAddr+2*4,l); /* counter_2 low byte first */ outp(wBaseAddr+2*4,h); /* counter_2 high byte ,0x07D0=2000 */ outp(wBaseAddr+3*4,0x80); /* latch counter_2 */ l=inp(wBaseAddr+2*4); /* delay starting two clks */ h=inp(wBaseAddr+2*4); for (count=32767;count>0;count--){ outp(wBaseAddr+12,0x80); /* latch counter_2 */ l=inp(wBaseAddr+8); h=inp(wBaseAddr+8); if (h>=0x80) return NoError; } return TimeOut; } //-------------------------------------------------------- void AdPolling(UCHAR channel, UCHAR gain, WORD delay) { outp(wBaseAddr+0x18,0); // Select Mode 0 outp(wBaseAddr+0x10,channel); outp(wBaseAddr+0x14,gain); P1002_Delay(delay); outp(wBaseAddr+0x1c,01); // A/D software tirgger } void SetupTimer(WORD wChannel, WORD wCoef) { WORD cmd; wChannel=wChannel&0x03; cmd=0x34+(wChannel<<6); outpw(wBaseAddr+3*4, cmd); outp(wBaseAddr+wChannel*4, (UCHAR)(wCoef&0xff)); outp(wBaseAddr+wChannel*4, (UCHAR)(wCoef>>8)); } //========================================================= void main() { int i,j; WORD wBoards,wRetVal,wPLX; WORD Drdy,wAdData=0; char c; clrscr(); P1002_DriverInit(&wBoards); printf("\n(1) Threr are %d PCI-1002 Cards in this PC",wBoards); if ( wBoards==0 ) { putch(0x07); putch(0x07); putch(0x07); printf("(1) There are no PCI-1002 card in this PC !!!\n"); exit(0); } printf("\n(2) Show the Configuration Space of all PCI-1002:"); for(i=0; i