⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 maui_cal.c

📁 Atheros AP Test with Agilent N4010A source code
💻 C
📖 第 1 页 / 共 5 页
字号:
				if(tmpVal == 1) {					NEED_GAIN_OPT_FOR_MODE[MODE_11b] = TRUE;				}			}			if(NEED_GAIN_OPT_FOR_MODE[MODE_11b] && CalSetup.Bmode && CalSetup.useInstruments) {				uiPrintf("\noptimum fixed gain for mode 11b found to be ... ");				timestart = milliTime();				strcpy(testname[testnum],"Optimum fixed gain for 11b");				configSetup.eepromLoad = 0;				art_setResetParams(devNumArr[MODE_11b], configSetup.pCfgFile, (A_BOOL)configSetup.eepromLoad,						(A_BOOL)configSetup.eepromHeaderLoad, MODE_11B, configSetup.use_init);				optGainLadderIndex[MODE_11b] = optimal_fixed_gain(devNumArr[MODE_11b], pCurrGainLadder, MODE_11b);				uiPrintf(" : %d  dB\n", pCurrGainLadder->optStep[optGainLadderIndex[MODE_11b]].stepGain);				testtime[testnum++] = milliTime() - timestart;			} else {				optGainLadderIndex[MODE_11b] = pCurrGainLadder->defaultStepNum;			}	   }	   if ((CalSetup.cal_fixed_gain[MODE_11g] != INVALID_FG) && CalSetup.Gmode){		   if (CalSetup.cal_fixed_gain[MODE_11g] >= pCurrGainLadder->numStepsInLadder) {			   uiPrintf("ERROR: Invalid CAL_FIXED_GAIN specified in calsetup.txt for mode ");			   uiPrintf("11g [%d] : Valid range 0..%d\n", CalSetup.cal_fixed_gain[MODE_11g],														  (pCurrGainLadder->numStepsInLadder-1));			   exit(0);		   }		   optGainLadderIndex[MODE_11g] = (pCurrGainLadder->numStepsInLadder -1) - CalSetup.cal_fixed_gain[MODE_11g];		   NEED_GAIN_OPT_FOR_MODE[MODE_11g] = TRUE;		   uiPrintf("\nusing cal fixed gain for mode 11g from calsetup.txt ... FG%d\n", CalSetup.cal_fixed_gain[MODE_11g]);	   } else  if (CalSetup.calPower && CalSetup.Gmode && (!REWIND_TEST)){			if ( ((swDeviceID & 0xFF) == 0x12) || ((swDeviceID & 0xFF) == 0x13) || ((swDeviceID & 0xFF) == 0x15) ) {				tmpVal = art_getFieldForMode(devNumArr[MODE_11g], "rf_rfgain_step", MODE_11G, 0);				if(tmpVal == 0x3f) {					NEED_GAIN_OPT_FOR_MODE[MODE_11g] = TRUE;				}			} else if (!isGriffin(swDeviceID) && !isEagle(swDeviceID)) { // for derby 2.0				tmpVal = art_getFieldForMode(devNumArr[MODE_11g], "rf_mixvga_ovr", MODE_11G, 0);				if(tmpVal == 1) {					NEED_GAIN_OPT_FOR_MODE[MODE_11g] = TRUE;				}			}			if(NEED_GAIN_OPT_FOR_MODE[MODE_11g] && CalSetup.Gmode && CalSetup.useInstruments) {				uiPrintf("\noptimum fixed gain for mode 11g found to be ... ");				timestart = milliTime();				strcpy(testname[testnum],"Optimum fixed gain for 11g");				configSetup.eepromLoad = 0;				art_setResetParams(devNumArr[MODE_11g], configSetup.pCfgFile, (A_BOOL)configSetup.eepromLoad,						(A_BOOL)configSetup.eepromHeaderLoad, MODE_11G, configSetup.use_init);				optGainLadderIndex[MODE_11g] = optimal_fixed_gain(devNumArr[MODE_11g], pCurrGainLadder, MODE_11g);				uiPrintf(" : %d  dB\n", pCurrGainLadder->optStep[optGainLadderIndex[MODE_11g]].stepGain);				testtime[testnum++] = milliTime() - timestart;			} else {				optGainLadderIndex[MODE_11g] = pCurrGainLadder->defaultStepNum;			}	   }		if(CalSetup.Amode && CalSetup.useInstruments && (CalSetup.testTempMargin[MODE_11a]) && (!REWIND_TEST)) {			uiPrintf("\nTesting temp margin for 11a...\n");			timestart = milliTime();			strcpy(testname[testnum],"Temp margin test 11a");			//cornerCal(devNum);			configSetup.eepromLoad = 0;			art_setResetParams(devNumArr[MODE_11a], configSetup.pCfgFile, (A_BOOL)configSetup.eepromLoad,					(A_BOOL)configSetup.eepromHeaderLoad, MODE_11A, configSetup.use_init);			test_for_temp_margin(devNumArr[MODE_11a], MODE_11a);			testtime[testnum++] = milliTime() - timestart;		}		if(CalSetup.Bmode && CalSetup.useInstruments && (CalSetup.testTempMargin[MODE_11b]) && (!REWIND_TEST)) {			uiPrintf("\nTesting temp margin for 11b...\n");			timestart = milliTime();			strcpy(testname[testnum],"Temp margin test 11b");			//cornerCal(devNum);			configSetup.eepromLoad = 0;			art_setResetParams(devNumArr[MODE_11b], configSetup.pCfgFile, (A_BOOL)configSetup.eepromLoad,					(A_BOOL)configSetup.eepromHeaderLoad, MODE_11B, configSetup.use_init);			test_for_temp_margin(devNumArr[MODE_11b], MODE_11b);			testtime[testnum++] = milliTime() - timestart;		}		if((CalSetup.Gmode && CalSetup.useInstruments && (CalSetup.testTempMargin[MODE_11g]) && (!REWIND_TEST)) ){			uiPrintf("\nTesting temp margin for 11g...\n");			timestart = milliTime();			strcpy(testname[testnum],"Temp margin test 11g");			//cornerCal(devNum);			configSetup.eepromLoad = 0;			art_setResetParams(devNumArr[MODE_11g], configSetup.pCfgFile, (A_BOOL)configSetup.eepromLoad,					(A_BOOL)configSetup.eepromHeaderLoad, MODE_11G, configSetup.use_init);			test_for_temp_margin(devNumArr[MODE_11g], MODE_11g);			testtime[testnum++] = milliTime() - timestart;		}		if(CalSetup.useInstruments) {			attSet(devATT, 81);		}		uiPrintf("\nManufacturing Test start ...\n");		if (CalSetup.useFastCal && CalSetup.calPower && CalSetup.useInstruments)		{			gpibONL(guDevAtt, 0);	// take att offline. relinquish for GU.			gpibONL(guDevPM, 0);	// take att offline. relinquish for GU.			sendAck(devNumArr[MODE_11a], "DUT relinquished instrument control. Go ahead GU.", 0, 0, 0, CalSetup.customerDebug);		}		// 11a calibration		if((CalSetup.calPower && CalSetup.Amode) && (!REWIND_TEST)){			timestart = milliTime();			strcpy(testname[testnum],"11a cal");			configSetup.eepromLoad = 0;			art_setResetParams(devNumArr[MODE_11a], configSetup.pCfgFile, (A_BOOL)configSetup.eepromLoad,					(A_BOOL)configSetup.eepromHeaderLoad, MODE_11A, configSetup.use_init);			if (NEED_GAIN_OPT_FOR_MODE[MODE_11a])			{				//setGainLadderForMaxGain(pCurrGainLadder);				setGainLadderForIndex(pCurrGainLadder, optGainLadderIndex[MODE_11a]);				programNewGain(pCurrGainLadder, devNumArr[MODE_11a], 0);			}			dutCalibration(devNumArr[MODE_11a]);			initializeGainLadder(pCurrGainLadder);			programNewGain(pCurrGainLadder, devNumArr[MODE_11a], 0);			testtime[testnum++] = milliTime() - timestart;		}		// 11g calibration		if(CalSetup.calPower && CalSetup.Gmode && (!REWIND_TEST)){			printf("11g calibration  \n");			configSetup.eepromLoad = 0;			art_setResetParams(devNumArr[MODE_11g], configSetup.pCfgFile, (A_BOOL)configSetup.eepromLoad,					(A_BOOL)configSetup.eepromHeaderLoad, MODE_11G, configSetup.use_init);			timestart = milliTime();			strcpy(testname[testnum],"11g cal");			if (NEED_GAIN_OPT_FOR_MODE[MODE_11g])			{				//initializeGainLadder(pCurrGainLadder);				//setGainLadderForMaxGain(pCurrGainLadder);				setGainLadderForIndex(pCurrGainLadder, optGainLadderIndex[MODE_11g]);				programNewGain(pCurrGainLadder, devNumArr[MODE_11g], 0);			}			dutCalibration_2p4(devNumArr[MODE_11g], MODE_11g);			initializeGainLadder(pCurrGainLadder);			programNewGain(pCurrGainLadder, devNumArr[MODE_11g], 0);			testtime[testnum++] = milliTime() - timestart;	   }		// 11b calibration		if(CalSetup.calPower && CalSetup.Bmode && (!REWIND_TEST)){			configSetup.eepromLoad = 0;			art_setResetParams(devNumArr[MODE_11b], configSetup.pCfgFile, (A_BOOL)configSetup.eepromLoad,					(A_BOOL)configSetup.eepromHeaderLoad, MODE_11B, configSetup.use_init);			timestart = milliTime();			strcpy(testname[testnum],"11b cal");			if (NEED_GAIN_OPT_FOR_MODE[MODE_11b])			{				//initializeGainLadder(pCurrGainLadder);				//setGainLadderForMaxGain(pCurrGainLadder);				setGainLadderForIndex(pCurrGainLadder, optGainLadderIndex[MODE_11b]);				programNewGain(pCurrGainLadder, devNumArr[MODE_11b], 0);			}			dutCalibration_2p4(devNumArr[MODE_11b], MODE_11b);			initializeGainLadder(pCurrGainLadder);			programNewGain(pCurrGainLadder, devNumArr[MODE_11b], 0);			testtime[testnum++] = milliTime() - timestart;		}		if(CalSetup.calPower && (!REWIND_TEST))		{			timestart = milliTime();//			printf("ENTERED INTO CALPOWERE  %d\n",timestart);			strcpy(testname[testnum],"program eeprom");			configSetup.eepromLoad = 0;			//force the reload of eep file to ensure correct settings programmed into eeprom			//printf("11_A FILE NAME   %s\n",configSetup.cfgTable.pCurrentElement->eepFilename);			processEepFile(devNumArr[MODE_11a], configSetup.cfgTable.pCurrentElement->eepFilename, &configSetup.eepFileVersion);//			printf("ENTERED INTO CALPOWERE  %s\n",configSetup.cfgTable.pCurrentElement->eepFilename);			processEepFile(devNumArr[MODE_11g], configSetup.cfgTable.pCurrentElement->eepFilename, &configSetup.eepFileVersion);			if (CalSetup.eeprom_map == CAL_FORMAT_GEN2) {				CalSetup.TrgtPwrStartAddr = 0x1A5;			}			// ear_start_addr now points to the end of cal data. adjust it for target powers :			// (8 11a ch + 211b ch + 3 11g ch)*2 words per ch			CalSetup.EARStartAddr = CalSetup.TrgtPwrStartAddr + 16 + 4 + 6 + 8*pTestGroupSet->numTestGroupsDefined;//			if(CalSetup.eeprom_map == CAL_FORMAT_GEN5) {//				//add extra dummy bytes to calculation of ear start//				CalSetup.EARStartAddr += NUM_DUMMY_EEP_MAP1_LOCATIONS;//			}//			printf("CALCULATE  Program Eeprom  %x  %x  %d %d \n",CalSetup.EARStartAddr ,CalSetup.TrgtPwrStartAddr, configSetup.validInstance,pTestGroupSet->numTestGroupsDefined);			program_eeprom((configSetup.validInstance == 1) ? devNumArr[MODE_11a] : devNumArr[MODE_11g]);			testtime[testnum++] = milliTime() - timestart;		}		if((CalSetup.reprogramTargetPwr && (!REWIND_TEST)))  {			printf("\nprogram_Target_Power_and_Test_Groups( \n");			program_Target_Power_and_Test_Groups(devNumArr[MODE_11a]);			printf("\nprogram_Target_Power_and_Test_Groups( \n");		}// Code added to enable dual 11a cal for ap30 ://    + EEPROM_DATA for EEPBLK0 should already be complete at this point.//    + copy that as baseline for EEPROM_DATA for EEPBLK1//    + modify only the cal sections for the modes that need to be modified//    + all other information is duplicated in both EEPBLKs		// dual concurrent 11a calibration	   if( configSetup.remote &&			((CalSetup.modeMaskForRadio[0] & 0x2) == 0x2) &&			((CalSetup.modeMaskForRadio[1] & 0x2) == 0x2) &&  // dual 11a supported			(CalSetup.calPower && CalSetup.Amode) && (!REWIND_TEST)){				timestart = milliTime();				strcpy(testname[testnum],"dual 11a cal");				configSetup.eepromLoad = 0;				// assumption : 2nd 11a devnum should be the same as the 11g devNum. true for freedom gen chips				dual_11a_devNum = devNumArr[MODE_11g];					art_setResetParams(dual_11a_devNum, configSetup.pCfgFile, (A_BOOL)configSetup.eepromLoad,					(A_BOOL)configSetup.eepromHeaderLoad, MODE_11A, configSetup.use_init);				if (NEED_GAIN_OPT_FOR_MODE[MODE_11a])				{						//setGainLadderForMaxGain(pCurrGainLadder);						setGainLadderForIndex(pCurrGainLadder, optGainLadderIndex[MODE_11g]);						programNewGain(pCurrGainLadder, dual_11a_devNum, 0);				}				dutCalibration(dual_11a_devNum);				initializeGainLadder(pCurrGainLadder);				programNewGain(pCurrGainLadder, dual_11a_devNum, 0);				testtime[testnum++] = milliTime() - timestart;				program_eeprom_block1(dual_11a_devNum);	  }		if (CalSetup.useFastCal && CalSetup.calPower && CalSetup.useInstruments && (!REWIND_TEST))		{//** the following remarked by ccshiang			/***			sendAck(devNumArr[MODE_11a], "Request Golden Unit To Relinquish Instrument Control", 0, 0, 0, CalSetup.customerDebug);			waitForAck(CalSetup.customerDebug);			gpibRSC(0, 1);			// DUT to acquire system control (1);			uiPrintf("\nSetting up Power Meter");			devPM = pmInit(CalSetup.pmGPIBaddr, CalSetup.pmModel);			uiPrintf("\nSetting up Spectrum Analyzer");			devSA = spaInit(CalSetup.saGPIBaddr, CalSetup.saModel);			uiPrintf("\nSetting up Attenuator");			devATT = attInit(CalSetup.attGPIBaddr, CalSetup.attModel);			attSet(devATT, 81); //set to max			***///** the above remarked by ccshiang		}		if (!REWIND_TEST) {			configSetup.loadEar = loadEARState;			art_configureLibParams(devNumArr[MODE_11a]);			art_configureLibParams(devNumArr[MODE_11g]);			art_resetDevice(devNumArr[MODE_11a], rxStation, bssID, 5220, 0);			art_resetDevice(devNumArr[MODE_11g], rxStation, bssID, 2412, 0);			art_getDeviceInfo(devNumArr[MODE_11a], &devStruct);			swDeviceID = devStruct.swDevID;			if(isDragon_sd(swDeviceID))  {				art_writeField(devNumArr[MODE_11a], "mc_eeprom_size_ovr", 3);				art_writeField(devNumArr[MODE_11g], "mc_eeprom_size_ovr", 3);			}//			printf("BEFORE DUT \n");			dutTest(&(devNumArr[0]));		}		exitLoop = prepare_for_next_card(&(devNumArr[0]));	}}void dutCalibration(A_UINT32 devNum){	A_UINT32 MACID_H, MACID_L;	if(!isEagle(swDeviceID)) {		art_changeField(devNum, "rf_ovr", 0);	}	if (CalSetup.eeprom_map == CAL_FORMAT_GEN3) {		dutCalibration_gen3(devNum, MODE_11a);		return;	}	if (CalSetup.eeprom_map >= CAL_FORMAT_GEN5) {		dutCalibration_gen5(devNum, MODE_11a);		return;	}	// reset device in order to read eeprom content	art_resetDevice(devNum, rxStation, bssID, 5220, 0);	// read MAC ID	MACID_H = art_eepromRead(devNum,0x1f);	MACID_L = art_eepromRead(devNum,0x1e);	MACID_L = (MACID_L << 16) | art_eepromRead(devNum,0x1d);	// power and gainf datasets setup and measurement	if (!setup_raw_datasets()) {		uiPrintf("Could not setup raw datasets. Exiting...\n");		closeEnvironment();		exit(0);	}	if (CalSetup.readFromFile)	{		read_dataset_from_file(pRawDataset, CalSetup.rawDataFilename);	} else if (CalSetup.forcePiers)	{		getCalData(devNum, MODE_11a, CalSetup.customerDebug);		dump_rectangular_grid_to_file(pRawDataset, "force_piers_power.log") ;		if (CalSetup.customerDebug)			dump_rectangular_grid_to_file(pRawGainDataset, "force_piers_gainf.log") ;	} else	{		getCalData(devNum, MODE_11a, CalSetup.customerDebug);		dump_rectangular_grid_to_file(pRawDataset, "cal_AR5211_power.log") ;		if (CalSetup.customerDebug)			dump_rectangular_grid_to_file(pRawGainDataset, "cal_AR5211_gainf.log") ;	}	make_cal_dataset_from_raw_dataset() ;	dMapGrid(pCalDataset, pFullDataset);	if (CalSetup.customerDebug)		dump_rectangular_grid_to_file(pFullDataset, "junkff.log");}void setupChannelLists(){	A_UINT16 lower_lab_channel, upper_lab_channel ;	A_UINT16 ii,jj;	lower_lab_channel = (A_UINT16) 20*(goldenParams.channelStart/20) ;	if (lower_lab_channel < goldenParams.channelStart)		lower_lab_channel += 20;	upper_lab_channel = (A_UINT16) 20*(goldenParams.channelStop/20) ;	jj=0;	for(ii=goldenParams.channelStart; ii<=goldenParams.channelStop; ii+=goldenParams.measurementStep )	{		RAW_CHAN_LIST[jj] = ii;		jj++;	}	if (ii < goldenParams.channelStop)	{		ii+=goldenParams.measurementStep ;		RAW_CHAN_LIST[jj] = ii;		jj++;	} // measurement channels need to include the channelStop	numRAWChannels = jj;}// Write Common Data to eepromA_BOOL setup_raw_datasets(){	A_UINT16  numPcdacs;	A_UINT16 i, j, channelValue;	dPCDACS_EEPROM *pEepromStruct;	A_UINT16  myNumRawChannels; // needed to handle forced piers case.	A_UINT16 *pMyRawChanList ;	// handle forcePierList case here	if(CalSetup.forcePiers && !CalSetup.readFromFile) // 'cause read from file supercedes	{		myNumRawChannels = (A_UINT16) CalSetup.numForcedPiers;		pMyRawChanList = CalSetup.piersList ;	} else	{		myNumRawChannels = numRAWChannels;		pMyRawChanList = RAW_CHAN_LIST ;	}	numPcdacs = sizeOfRawPcdacs;	if(!d_allocateEepromStruct( pRawDataset, myNumRawChannels, numPcdacs )) {		uiPrintf("unable to allocate eeprom struct RawDataset for full struct\n");		return(0);	}	if(!d_allocateEepromStruct( pRawGainDataset, myNumRawChannels, numPcdacs )) {		uiPrintf("unable to allocate eeprom struct RawGainDataset for full struct\n");		return(0);	}	//now fill in the channel list and pcdac lists	for (j=0; j<2; j++)	{		pEepromStruct = pRawDataset;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -