//#include #include "ACCES.H" //#include "ACCESLIB.H" //extern far pascal uint CURCH; extern far pascal unsigned int MAXCH = 7; //returns TRUE if not in the middle of a conversion. #pragma argsused extern far pascal void STARTCONVERSION(unsigned int BASE) { outport(BASE + 16, 0x0001);//send START to chip } #pragma argsused extern far pascal void RESET(unsigned int BASE) { outport(BASE + 16, 0x0002); //send RESET to chip outport(BASE + 16, 0x0008); //calibrate } #pragma argsused extern far pascal void SETCHANNEL(unsigned int BASE, unsigned int FIRSTCH,unsigned int LASTCH) { //0--b+0,0 unsigned int i = 0; //1--b+2,4 unsigned int offset = 0; //2--b+4,8 unsigned int test = 0; for (i = FIRSTCH; i < LASTCH+1; i++){ test = 0x0000 | ( i << 2); //set channel offset=(i-FIRSTCH) * 2;//increment even base addresses outport(BASE + offset, test);//send pointlist } outport(BASE + offset, test|0x0001); //set loop bit on last instruction } // GETADDATA --- // Parameter list // 1 : Base address // 2 : First channel // 3 : Last channel // 4 : Number of times to scan channels // 5 : Buffer to store collected data #pragma argsused extern far pascal unsigned int GETADDATA(unsigned int BASE, unsigned int FIRSTCH, unsigned int LASTCH, unsigned int SCANS, unsigned int *BUFFER) { unsigned int i = 0, x = 0; unsigned int timeout=0; unsigned int conv = 0; if (FIRSTCH>MAXCH) return ERR_CHANNEL_RANGE; if (LASTCH>MAXCH) return ERR_CHANNEL_RANGE; if (FIRSTCH>LASTCH) return ERR_CHANNEL_ORDER; if (!(BUFFER)) return ERR_NULL_POINTER; RESET(BASE);//reset RAM pointer SETCHANNEL(BASE,FIRSTCH,LASTCH);//set channels in point list RESET(BASE); //send RESET to chip STARTCONVERSION(BASE); for (x = 0; x < SCANS; x++)// { timeout = 65535; while ((conv=inport(BASE+16 & 0x0001)==0x0001) && (timeout--));//while not done sampling for (i = 0; i<(LASTCH - FIRSTCH + 1); i++) BUFFER[x * (LASTCH - FIRSTCH + 1) + i] = inport(BASE + 24);//read data into buffer }//end x for loop return 0; }