/************************************************************************************ * convertParams_sct.c * * synopsis: This file contains routines which convert input parameters for SCT * specific primitives and tasks; this creates a greater degree of * flexibility when introducing a new primitive format, as the host * code can be updated later. Update as needed. * ************************************************************************************/ #include #include #include #include #include #include "resources.h" extern char genStr[]; extern far unsigned char heap[]; extern TIMER_Handle timer1; /* general purpose timer, started in main() */ #pragma CODE_SECTION(histoCtrl_convert, "xcode"); /************************************************************************************ * histoCtrl_convert * * synopsis: Converts between the old histogram scan task format (107) & the * updated one (108). Both are members of the TaskInput union for * convenience & transparency in the rest of the code. The new structure is * held in a temporary location in external memory before being copied into * internal memory by the inserttask routine. * * author: Douglas Ferguson ************************************************************************************/ INT32 histoCtrl_convert(TaskInput *tsi_v107, TaskInput *tsi) { INT32 returnCode= SUCCESS, i, j, k; ScanControl *scan; struct HISTOGRAM_CTRL_TASK_IN *v107; FLOAT32 x0, delta_x, epsilon= 0.01, *xptr; UINT32 *ptr[2]; //struct MSG_LIST_HEAD *header; scan= (ScanControl *) tsi; setMem(scan, SIZEOF(HistoCtrlTaskIn), 0); //Clear away the old structure. v107= &tsi_v107->histoCtrlTaskIn; //General parameters: scan->general.cfgSet= v107->configSctSet; scan->general.globalCtrl= v107->globalCtrl; scan->general.chip= ALL_CHIPS; scan->general.scanParameter[0]= v107->configRegister[0]; scan->general.scanParameter[1]= NO_SCAN; //1D scans only. scan->general.nBins[0]= v107->nBins; scan->general.nBins[1]= 0; scan->general.repetitions= v107->repetitions; scan->general.maskMode= !(v107->calLineLoop); scan->general.stageAdvanceFirst= TRUE; scan->general.maskStages= 4; for (i=0; i<2; ++i) { scan->general.uniformPoints[i]= FALSE; //Must use custom lists. scan->general.scanStart[i]= 0.0; scan->general.scanEnd[i]= 0.0; scan->general.dataPtr[i]= v107->dataPtr[i]; } //Reset parameters: scan->reset.moduleInit= FALSE; scan->reset.binReset= TRUE; scan->reset.triggerReset= FALSE; scan->reset.ECR= TRUE; scan->reset.BCR= TRUE; //FE parameters: scan->fe.useScanSettings= FALSE; scan->fe.trimRange= 0; scan->fe.readoutMode= 0; scan->fe.accumulate= FALSE; scan->fe.edgeDetect= FALSE; scan->fe.digitalInject= FALSE; //Fitting parameters: scan->fitting.sCurves= FALSE; scan->fitting.calibrationOption= 0; scan->fitting.chi2Cut= 0.0; scan->fitting.customScale= 0.0; scan->fitting.customOffset= 0.0; //Rod Setup parameters: scan->rodSetup.base= v107->histoBase; scan->rodSetup.binSize= v107->binSize; scan->rodSetup.routineType= HISTO_ROUTINE_ASM; scan->rodSetup.opt[0]= v107->doChipOcc; scan->rodSetup.opt[1]= v107->dataFormat; scan->rodSetup.opt[2]= FALSE; scan->rodSetup.opt[3]= 0; scan->rodSetup.errors= FALSE; scan->rodSetup.extSetup= v107->extSetup; scan->rodSetup.dataPath= v107->dataPath; //DSP Distribution parameters: scan->dspDist.definedGroups= v107->genData[0]; scan->dspDist.nDspPairs= v107->genData[1]; scan->dspDist.slvBits= v107->slvBits; scan->dspDist.mirroredRanges= FALSE; scan->dspDist.dspPair[0][0]= (v107->genData[2]>>0) & 0x3; scan->dspDist.dspPair[0][1]= (v107->genData[2]>>8) & 0x3; scan->dspDist.dspPair[1][0]= (v107->genData[2]>>16) & 0x3; scan->dspDist.dspPair[1][1]= (v107->genData[2]>>24) & 0x3; for (i=0; i<2; ++i) { scan->dspDist.groupRangeMap[i]= v107->groupRangeMap[i]; scan->dspDist.groupSPMap[i]= v107->groupSPMap[i]; } for (i=0; idspDist.groupDSPMap[i]= v107->groupDSPMap[i]; } //Serial Data parameters: for (i=0; i<2; ++i) { scan->serial.triggerSequence[i]= v107->triggerSequence[i]; } scan->serial.calcFromStruct= FALSE; scan->serial.calL1ADelay= 0; scan->serial.port= v107->port; //Handle the conversion of the older range-lists: if (v107->useRangeList) { /* check that list is uniformly increasing or decreasing: (use delta[0] *delta[i] > 0 for all i>0 */ for (i= 0; i < 2; ++i) { k= 0; x0= v107->rangeList[i].xPair[k].x0; delta_x= v107->rangeList[i].xPair[k].delta_x; xptr= (FLOAT32 *) tsi +SIZEOF(TaskInput) +i*v107->nBins; *xptr++= x0; for (j= 1; jnBins; ++j,++xptr) { *xptr= *(xptr-1) +delta_x; if (k == 4) continue; if (delta_x > 0) { if (*xptr > (v107->rangeList[i].xPair[k+1].x0 -epsilon)) { ++k; x0= v107->rangeList[i].xPair[k].x0; delta_x= v107->rangeList[i].xPair[k].delta_x; *xptr= x0; } } else { if (*xptr < (v107->rangeList[i].xPair[k+1].x0 +epsilon)) { ++k; x0= v107->rangeList[i].xPair[k].x0; delta_x= v107->rangeList[i].xPair[k].delta_x; *xptr= x0; } } } scan->general.dataPtr[i]= (FLOAT32 *) DEFAULT; //now it's in the (heap) 'list' //Modify the new primitive's header: //header= (struct MSG_LIST_HEAD *) scan -SIZEOF(struct MSG_LIST_HEAD); //header->length= SIZEOF(struct MSG_LIST_HEAD) // +SIZEOF(TaskInput) +2*v107->nBins; } } /* build the variable ranges from the range-list constructors provided */ else { if ( (v107->dataPtr[0] == (FLOAT32 *) DEFAULT) ||(v107->dataPtr[1] == (FLOAT32 *) DEFAULT) ) { /* Both must be set to the default position (in list), or neither. */ if ( (v107->dataPtr[0] != (FLOAT32 *) DEFAULT) ||(v107->dataPtr[1] != (FLOAT32 *) DEFAULT) ) { newError(&returnCode, PRIM_PARAMETER_ERROR, FATAL_ERR, "startTask", "Both data pointers must be included in the list, if one is.\n", __FILE__, __LINE__); return returnCode; } ptr[0]= (UINT32 *) v107 +SIZEOF(TaskInput); ptr[1]= (UINT32 *) tsi +SIZEOF(TaskInput); copyMem(ptr[0], ptr[1], 2*v107->nBins); } } return returnCode; }