/**********************************************************************/ /* This program is developed by MicroSoft C 5.1 */ /***********************************************************************/ /* Demo 8: two P180X card M_FUN_2 demo. */ /***********************************************************************/ #define MYLIB #include "P180X.H" int iLine; float fAdBuf[510]; WORD wAdClk; WORD wDa[320],wAd[510]; WORD wPlot0[512]; // transformed into wave form int main() { int i,j; char cShow[80]; WORD wBoards,wRetVal; WORD wDIOdata; DWORD dwExact,dwOKs,dwErrors,dwScanCount,dwP1,dwP2,dwStatus; double dfAdFrequency; WORD wAddrTimer,wAddrCtrl,wAddrDio,wAddrAdda; clrscr(); // a clear screen function in P180XMC?.LIB gotoxy(1,1); // initiaing P180X card and detect how many P180X card in PC wRetVal=P180X_DriverInit(&wBoards); printf("Threr are %d P180X Cards in this PC\n",wBoards); if( wBoards<=1 ) { putch(0x07); putch(0x07); putch(0x07); printf("Please install two P180X cards in this PC !!!\n"); exit(0); } /* dump every P180X card's configuration address space */ printf("The Configuration Space -> Timer Control DIO AD/DA\n"); for(i=0; i 1234H | Digital Input -> %04xH\n",wDIOdata); printf("----------------------------------------------------------\n"); printf("The Second P180X Card...\n"); P180X_ActiveBoard( 1 ); P180X_Do(0x5678); // Digital output P180X_Di(&wDIOdata); // Digital input printf("Digital Output -> 5678H | Digital Input -> %04xH\n",wDIOdata); printf("\n\n"); /************** M2 Function ****************************/ for(i=0; i<64; i++) wDa[i]=0x800-i*16; for(i=0; i<64; i++) wDa[i+64]=0x800-(64-i)*16; for(i=0; i<64; i++) wDa[i+64*2]=0x800; for(i=0; i<64; i++) wDa[i+64*3]=0x800-64*8; for(i=0; i<64; i++) wDa[i+64*4]=0x800; //--------- To Active First P180X Card -------------------- P180X_ActiveBoard( 0 ); for (i=0; i<510; i++) wAd[i]=0; wRetVal=P180X_M_FUN_2(320,15,wDa,24,510,0,wAd); if(wRetVal==0) { printf("1st Card: P180X_M_FUN_2 OK.\n"); } else { putch(0x07); printf("1st: P180X_M_FUN_2 ERROR, return=%x\n\n",wRetVal); exit(0); } printf("[ 0]=%04xH, [ 1]=%04xH, [ 2]=%04xH, [ 3]=%04xH\n", wAd[0],wAd[1],wAd[2],wAd[3]); printf("[ 4]=%04xH, [ 5]=%04xH, [ 6]=%04xH, [ 7]=%04xH\n", wAd[4],wAd[5],wAd[6],wAd[7]); printf("[ 8]=%04xH, [ 9]=%04xH, [10]=%04xH, [11]=%04xH\n", wAd[8],wAd[9],wAd[10],wAd[11]); printf("[12]=%04xH, [13]=%04xH, [14]=%04xH, [15]=%04xH\n", wAd[12],wAd[13],wAd[14],wAd[15]); printf("[16]=%04xH, [17]=%04xH, [18]=%04xH, [19]=%04xH\n", wAd[16],wAd[17],wAd[18],wAd[19]); printf("\n"); //--------- To Active Second P180X Card -------------------- P180X_ActiveBoard( 1 ); for (i=0; i<510; i++) wAd[i]=0; wRetVal=P180X_M_FUN_2(320,15,wDa,24,510,0,wAd); if(wRetVal==0) { printf("2nd Card: P180X_M_FUN_2 OK.\n"); } else { putch(0x07); printf("2nd: P180X_M_FUN_2 ERROR, return=%x\n\n",wRetVal); exit(0); } printf("[ 0]=%04xH, [ 1]=%04xH, [ 2]=%04xH, [ 3]=%04xH\n", wAd[0],wAd[1],wAd[2],wAd[3]); printf("[ 4]=%04xH, [ 5]=%04xH, [ 6]=%04xH, [ 7]=%04xH\n", wAd[4],wAd[5],wAd[6],wAd[7]); printf("[ 8]=%04xH, [ 9]=%04xH, [10]=%04xH, [11]=%04xH\n", wAd[8],wAd[9],wAd[10],wAd[11]); printf("[12]=%04xH, [13]=%04xH, [14]=%04xH, [15]=%04xH\n", wAd[12],wAd[13],wAd[14],wAd[15]); printf("[16]=%04xH, [17]=%04xH, [18]=%04xH, [19]=%04xH\n", wAd[16],wAd[17],wAd[18],wAd[19]); P180X_DriverClose(); return 0; }