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

📄 cal_com.c

📁 Atheros AP Test with Agilent N4010A source code
💻 C
📖 第 1 页 / 共 5 页
字号:

					pLine = strchr(pLine, '=');
					pLine = strtok(pLine, delimiters);
					pLine = strtok(pLine," ;#");
					if(!sscanf(pLine, "%d", &CalSetup.xlnaGain_2p4[MODE_11b])) {
					uiPrintf("Unable to read the 11b_XLNA_GAIN from %s\n", eep_file);
					}
			}
			else if((strnicmp("11b_NOISE_FLOOR_THRESHOLD", pLine, strlen("11b_NOISE_FLOOR_THRESHOLD")) == 0) &&
					((pLine[strlen("11b_NOISE_FLOOR_THRESHOLD")] == ' ') ||
					(pLine[strlen("11b_NOISE_FLOOR_THRESHOLD")] == '\t') ) ){

					pLine = strchr(pLine, '=');
					pLine = strtok(pLine, delimiters);
					pLine = strtok(pLine," ;#");
					if(!sscanf(pLine, "%d", &CalSetup.noisefloor_thresh_2p4[MODE_11b])) {
					uiPrintf("Unable to read the 11b_NOISE_FLOOR_THRESHOLD from %s\n", eep_file);
					}
			}
			else if((strnicmp("11g_XLNA_GAIN", pLine, strlen("11g_XLNA_GAIN")) == 0) &&
					((pLine[strlen("11g_XLNA_GAIN")] == ' ') ||
					 (pLine[strlen("11g_XLNA_GAIN")] == '\t') ) ){

					pLine = strchr(pLine, '=');
					pLine = strtok(pLine, delimiters);
					pLine = strtok(pLine," ;#");
					if(!sscanf(pLine, "%d", &CalSetup.xlnaGain_2p4[MODE_11g])) {
					uiPrintf("Unable to read the 11b_XLNA_GAIN from %s\n", eep_file);
					}
			}
			else if((strnicmp("11g_NOISE_FLOOR_THRESHOLD", pLine, strlen("11g_NOISE_FLOOR_THRESHOLD")) == 0) &&
					((pLine[strlen("11g_NOISE_FLOOR_THRESHOLD")] == ' ') ||
					(pLine[strlen("11g_NOISE_FLOOR_THRESHOLD")] == '\t') ) ){

					pLine = strchr(pLine, '=');
					pLine = strtok(pLine, delimiters);
					pLine = strtok(pLine," ;#");
					if(!sscanf(pLine, "%d", &CalSetup.noisefloor_thresh_2p4[MODE_11g])) {
					uiPrintf("Unable to read the 11b_NOISE_FLOOR_THRESHOLD from %s\n", eep_file);
					}
			}
			else if((strnicmp("11a_FALSE_DETECT_BACKOFF", pLine, strlen("11a_FALSE_DETECT_BACKOFF")) == 0) &&
					((pLine[strlen("11a_FALSE_DETECT_BACKOFF")] == ' ') ||
					 (pLine[strlen("11a_FALSE_DETECT_BACKOFF")] == '\t') ) ){

					pLine = strchr(pLine, '=');
					pLine = strtok(pLine, delimiters);
					pLine = strtok(pLine," ;#");
					if(!sscanf(pLine, "%d", &CalSetup.falseDetectBackoff[MODE_11a])) {
					uiPrintf("Unable to read the 11a_FALSE_DETECT_BACKOFF from %s\n", eep_file);
					}
			}
			else if((strnicmp("11b_FALSE_DETECT_BACKOFF", pLine, strlen("11b_FALSE_DETECT_BACKOFF")) == 0) &&
					((pLine[strlen("11b_FALSE_DETECT_BACKOFF")] == ' ') ||
					 (pLine[strlen("11b_FALSE_DETECT_BACKOFF")] == '\t') ) ){

					pLine = strchr(pLine, '=');
					pLine = strtok(pLine, delimiters);
					pLine = strtok(pLine," ;#");
					if(!sscanf(pLine, "%d", &CalSetup.falseDetectBackoff[MODE_11b])) {
					uiPrintf("Unable to read the 11b_FALSE_DETECT_BACKOFF from %s\n", eep_file);
					}
			}
			else if((strnicmp("11g_FALSE_DETECT_BACKOFF", pLine, strlen("11g_FALSE_DETECT_BACKOFF")) == 0) &&
					((pLine[strlen("11g_FALSE_DETECT_BACKOFF")] == ' ') ||
					 (pLine[strlen("11g_FALSE_DETECT_BACKOFF")] == '\t') ) ){

					pLine = strchr(pLine, '=');
					pLine = strtok(pLine, delimiters);
					pLine = strtok(pLine," ;#");
					if(!sscanf(pLine, "%d", &CalSetup.falseDetectBackoff[MODE_11g])) {
					uiPrintf("Unable to read the 11g_FALSE_DETECT_BACKOFF from %s\n", eep_file);
					}
			}
			else if((strnicmp("MODE_MASK_FOR_RADIO_0", pLine, strlen("MODE_MASK_FOR_RADIO_0")) == 0) &&
					((pLine[strlen("MODE_MASK_FOR_RADIO_0")] == ' ') ||
					 (pLine[strlen("MODE_MASK_FOR_RADIO_0")] == '\t') ) ){

					pLine = strchr(pLine, '=');
					pLine = strtok(pLine, delimiters);
					pLine = strtok(pLine," ;#");
					if(!sscanf(pLine, "%d", &CalSetup.modeMaskForRadio[0])) {
						uiPrintf("Unable to read the MODE_MASK_FOR_RADIO_0 from %s\n", eep_file);
					}
			}
			else if((strnicmp("MODE_MASK_FOR_RADIO_1", pLine, strlen("MODE_MASK_FOR_RADIO_1")) == 0) &&
					((pLine[strlen("MODE_MASK_FOR_RADIO_1")] == ' ') ||
					 (pLine[strlen("MODE_MASK_FOR_RADIO_1")] == '\t') ) ){

					pLine = strchr(pLine, '=');
					pLine = strtok(pLine, delimiters);
					pLine = strtok(pLine," ;#");
					if(!sscanf(pLine, "%d", &CalSetup.modeMaskForRadio[1])) {
						uiPrintf("Unable to read the MODE_MASK_FOR_RADIO_1 from %s\n", eep_file);
					}
			}
		else if(strnicmp("MAX_PCDAC_11A", pLine, strlen("MAX_PCDAC_11A")) == 0) {
			pLine = strchr(pLine, '=');
			pLine++;
			pLine = strtok( pLine, delimiters ); //get past any white space etc

			if(!sscanf(pLine, "%d", &CalSetup.max_pcdac_11a)) {
				uiPrintf("Unable to read MAX_PCDAC_11A from %s\n", eep_file);
				return;
			}
		}
		else if(strnicmp("MAX_PCDAC_11B", pLine, strlen("MAX_PCDAC_11B")) == 0) {
			pLine = strchr(pLine, '=');
			pLine++;
			pLine = strtok( pLine, delimiters ); //get past any white space etc

			if(!sscanf(pLine, "%d", &CalSetup.max_pcdac_11b)) {
				uiPrintf("Unable to read MAX_PCDAC_11B from %s\n", eep_file);
				return;
			}
		}
		else if(strnicmp("MAX_PCDAC_11G", pLine, strlen("MAX_PCDAC_11G")) == 0) {
			pLine = strchr(pLine, '=');
			pLine++;
			pLine = strtok( pLine, delimiters ); //get past any white space etc

			if(!sscanf(pLine, "%d", &CalSetup.max_pcdac_11g)) {
				uiPrintf("Unable to read MAX_PCDAC_11G from %s\n", eep_file);
				return;
			}
		}
		else if(strnicmp("ATTEMPT_POWER_11A", pLine, strlen("ATTEMPT_POWER_11A")) == 0) {
			pLine = strchr(pLine, '=');
			pLine++;
			pLine = strtok( pLine, delimiters ); //get past any white space etc

			if(!sscanf(pLine, "%d", &CalSetup.attempt_pcdac_11a)) {
				uiPrintf("Unable to read ATTEMPT_POWER_11A from %s\n", eep_file);
				return;
			}
		}
		else if(strnicmp("ATTEMPT_POWER_11B", pLine, strlen("ATTEMPT_POWER_11B")) == 0) {
			pLine = strchr(pLine, '=');
			pLine++;
			pLine = strtok( pLine, delimiters ); //get past any white space etc

			if(!sscanf(pLine, "%d", &CalSetup.attempt_pcdac_11b)) {
				uiPrintf("Unable to read ATTEMPT_POWER_11B from %s\n", eep_file);
				return;
			}
		}
		else if(strnicmp("ATTEMPT_POWER_11G", pLine, strlen("ATTEMPT_POWER_11G")) == 0) {
			pLine = strchr(pLine, '=');
			pLine++;
			pLine = strtok( pLine, delimiters ); //get past any white space etc

			if(!sscanf(pLine, "%d", &CalSetup.attempt_pcdac_11g)) {
				uiPrintf("Unable to read ATTEMPT_POWER_11G from %s\n", eep_file);
				return;
			}
		}
		} // done parsing cal section
	} // end of file
	if(CalSetup.eepromLength == 0)
		userEepromSize =0x400;
}

A_UINT32 read_gainf_with_probe_packet(A_UINT32 devNum, A_UINT32 power) {

	A_UINT32 rddata, retVal;

	art_writeField(devNum, "bb_probe_powertx", power);
	art_writeField(devNum, "bb_probe_next_tx", 1);
	Sleep(1);
	rddata = art_regRead(devNum, 0x9930);
	retVal = (rddata >> 25) ;

	return(retVal);
}

A_UINT32 read_gainf_twice(A_UINT32 devNum)
{
	A_UINT32 gain1, gain2;
	// index of pcdac table to read gainF for. set to 0 for all contTX
	gain1 = read_gainf_with_probe_packet(devNum, 0);
	if (abs(gain1 - global_prev_gainf) > 10) {
		// index of pcdac table to read gainF for. set to 0 for all contTX
		gain2 = read_gainf_with_probe_packet(devNum, 0);
	} else {
		gain2 = gain1;
	}
	global_prev_gainf = (A_UINT16) gain1;
	return( (gain1 >= gain2) ? gain1 : gain2);
}


A_UINT32 dump_a2_pc_out(A_UINT32 devNum)
{

	A_UINT32 a2_data=0;
	A_UINT32 tmp;
	A_UINT32 OS_1   = 0;
	A_UINT32 OS_0   = 1;
	A_UINT32 M_2    = 0;
	A_UINT32 M_1    = 1;
	A_UINT32 M_0    = 1;
	A_UINT32 DREG_1 = 0;
	A_UINT32 DREG_0 = 0;
	A_UINT32 DA_2   = 0;
	A_UINT32 DA_1   = 0;
	A_UINT32 DA_0   = 0;
	A_UINT32 NUM_SHIFTS = 7; //used to be 6 in crete-fez
	A_UINT32 indata, outdata, bit, pos;


	tmp = art_regRead(devNum, 0x9808) | (0x1<<27);

	art_regWrite(devNum, 0x9808, tmp);

	// now dump
	tmp =  ((M_2 << 10) | (M_1 << 11) | (M_0 << 12) | (OS_1 << 0) | (OS_0 << 1) | (DREG_1 << 16)
		   | (DREG_0 << 17) | (DA_2 << 18) | (DA_1 << 19) | (DA_0 << 20) | (0x5 << 2));

	art_regWrite(devNum, 0x9800+(0x34<<2), tmp);

	// shift out 32 bits
	for (tmp=0;tmp<NUM_SHIFTS;tmp++)
	{
	   art_regWrite(devNum, 0x9800+(0x20<<2), 0x10000);
	}

	a2_data = art_regRead(devNum, 0x9800+(256<<2));

	// reverse 7
	indata = ((a2_data>>25)&0x7f);
	outdata=bit=0;
	for (pos=0; pos<NUM_SHIFTS; pos++) {
		bit = (indata >> pos) & 0x1;
		outdata = (outdata << 1) | bit;
	}
	a2_data = outdata;

	// clear out register 5
	art_regWrite(devNum, 0x9800+(0x34<<2), 0x14);

	// d2_enable_agc_to_a2();
	tmp = art_regRead(devNum, 0x9808) & ~(0x1<<27);
	art_regWrite(devNum, 0x9808, tmp);

	return(a2_data);

}

void parseSetup(A_UINT32 devNum)
{
  //printf("\n Start parsesetup\n");
	load_calsetup_vals() ;
	load_eep_vals(devNum);
	if(userEepromSize == 0x400)
	{
		checkSumLength = eepromSize = 0x400;
		//uiPrintf("In parseSetup() checkSumLength = %x eepromSize = %x \n",checkSumLength,eepromSize);
	}
	else
	{
		eepromSize = userEepromSize;
		//uiPrintf("In ParseSetup() eepromSize = %x \n",eepromSize);
	}
	//printf("\n  End parsesetup\n");
}

void load_calsetup_vals(void)
{
	FILE *fStream;
	char lineBuf[122], *pLine;
	A_UINT32 testVal;
	A_INT32  signedTempVal;
	A_UINT16 ii;
	char delimiters[] = " \t\n\r;=";

	uiPrintf("\nReading in Calibration Setup from %s\n", calsetupFileName);
	if( (fStream = fopen( (const char*) calsetupFileName, "r")) == NULL ) {
		uiPrintf("\n\n**************************************************\n");
		uiPrintf("Failed to open calsetup file : %s \n", calsetupFileName);
		uiPrintf("Make Sure COMPUTE_CALSETUP_FILE is set to correct \n");
		uiPrintf("value in artsetup.txt\n");
		uiPrintf("**************************************************\n\n");
		return;
	}

	while(fgets(lineBuf, 120, fStream) != NULL) {
		pLine = lineBuf;

		while(isspace(*pLine)) pLine++;

		if(strnicmp("#BEGIN_11a_TEST_CHANNEL_MATRIX", pLine, strlen("#BEGIN_11a_TEST_CHANNEL_MATRIX")) == 0) {
			parseTestChannels(fStream, pLine, MODE_11a);
			continue;
		}

		if(strnicmp("#BEGIN_11b_TEST_CHANNEL_MATRIX", pLine, strlen("#BEGIN_11b_TEST_CHANNEL_MATRIX")) == 0) {
			parseTestChannels(fStream, pLine, MODE_11b);
			continue;
		}

		if(strnicmp("#BEGIN_11g_TEST_CHANNEL_MATRIX", pLine, strlen("#BEGIN_11g_TEST_CHANNEL_MATRIX")) == 0) {
			parseTestChannels(fStream, pLine, MODE_11g);
			continue;
		}

		if(*pLine == '#') {
			continue;
		}
		else if(strnicmp("SUBSYSTEM_ID", pLine, strlen("SUBSYSTEM_ID")) == 0) {
			pLine = strchr(pLine, '=');
			pLine = strtok(pLine, delimiters);
		CalSetup.subsystemID = (A_UINT16) strtoul(pLine, NULL, 0);
		}
		else if(strnicmp("USE_INSTRUMENTS", pLine, strlen("USE_INSTRUMENTS")) == 0) {
			pLine = strchr(pLine, '=');
			pLine = strtok(pLine, delimiters);
			if(!sscanf(pLine, "%d", &testVal)) {
				uiPrintf("Unable to read the USE_INSTRUMENTS from %s\n", calsetupFileName);
			}
			else {
				CalSetup.useInstruments = (testVal) ? TRUE : FALSE;
			}
		}
		else if(strnicmp("COUNTRY_OR_DOMAIN_FLAG", pLine, strlen("COUNTRY_OR_DOMAIN_FLAG")) == 0) {
			pLine = strchr(pLine, '=');
			pLine = strtok(pLine, delimiters);
			if(!sscanf(pLine, "%d", &CalSetup.countryOrDomain)) {
				uiPrintf("Unable to read the COUNTRY_OR_DOMAIN_FLAG flag from %s\n", calsetupFileName);
			}
		}
		else if(strnicmp("WORLD_WIDE_ROAMING_FLAG", pLine, strlen("WORLD_WIDE_ROAMING_FLAG")) == 0) {
			pLine = strchr(pLine, '=');
			pLine = strtok(pLine, delimiters);
			if(!sscanf(pLine, "%d", &CalSetup.worldWideRoaming)) {
				uiPrintf("Unable to read the WORLD_WIDE_ROAMING_FLAG flag from %s\n", calsetupFileName);
			}
		}
		else if(strnicmp("COUNTRY_OR_DOMAIN_CODE", pLine, strlen("COUNTRY_OR_DOMAIN_CODE")) == 0) {
			pLine = strchr(pLine, '=');
			pLine = strtok(pLine, delimiters);
			CalSetup.countryOrDomainCode = (A_UINT16) strtoul(pLine, NULL, 0);
	   }
	   else if(strnicmp("READ_FROM_FILE", pLine, strlen("READ_FROM_FILE")) == 0) {
			pLine = strchr(pLine, '=');
			pLine++;
			if(!sscanf(pLine, "%d", &testVal)) {
				printf("Unable to read the READ_FROM_FILE from %s\n", calsetupFileName);
			}
			else {
				CalSetup.readFromFile = (testVal) ? TRUE : FALSE;
			}
		}
	   else if(strnicmp("RAW_DATA_FILENAME", pLine, strlen("RAW_DATA_FILENAME")) == 0) {
			pLine = strchr(pLine, '=');
			pLine++;
			pLine = strtok(pLine, delimiters);
			if(!sscanf(pLine, "%s", CalSetup.rawDataFilename)) {
				printf("Unable to read the RAW_DATA_FILENAME from %s\n", calsetupFileName);
			}

⌨️ 快捷键说明

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