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

📄 meeprom_d.c

📁 Atheros AP Test with Agilent N4010A source code
💻 C
📖 第 1 页 / 共 3 页
字号:
		if (((xpd_mask >> jj) & 1) > 0) {
			if (kk > 1) {
				printf("A maximum of 2 xpd_gains supported in eep_to_raw_data\n");
				exit(0);
			}
			xgain_list[kk++] = (A_UINT16) jj;			
		}
	}

	pRawDataset->numChannels = pCalDataset->numChannels;
	for (ii = 0; ii < pRawDataset->numChannels; ii++) {
		pCalCh = &(pCalDataset->pDataPerChannel[ii]);
		pRawDataset->pDataPerChannel[ii].channelValue = pCalCh->channelValue;
		pRawDataset->pDataPerChannel[ii].maxPower_t4  = pCalCh->maxPower_t4;
		maxPower_t4 = pRawDataset->pDataPerChannel[ii].maxPower_t4;
	
		if (xgain_list[1] == 0xDEAD) {	// case of single xpd_gain cal
			for (jj=0; jj<NUM_XPD_PER_CHANNEL; jj++) {
				pRawDataset->pDataPerChannel[ii].pDataPerXPD[jj].numPcdacs = 0;
			}

			jj = xgain_list[0];
			pRawXPD = &(pRawDataset->pDataPerChannel[ii].pDataPerXPD[jj]);
			pRawXPD->numPcdacs = 4;
			pRawXPD->pcdac[0] = pCalCh->pcd1_xg0;
			pRawXPD->pcdac[1] = (A_UINT16)(pRawXPD->pcdac[0] + pCalCh->pcd2_delta_xg0);
			pRawXPD->pcdac[2] = (A_UINT16)(pRawXPD->pcdac[1] + pCalCh->pcd3_delta_xg0);
			pRawXPD->pcdac[3] = (A_UINT16)(pRawXPD->pcdac[2] + pCalCh->pcd4_delta_xg0);

			pRawXPD->pwr_t4[0] = pCalCh->pwr1_xg0;
			pRawXPD->pwr_t4[1] = pCalCh->pwr2_xg0;
			pRawXPD->pwr_t4[2] = pCalCh->pwr3_xg0;
			pRawXPD->pwr_t4[3] = pCalCh->pwr4_xg0;
	
		} else {
			for (jj=0; jj<NUM_XPD_PER_CHANNEL; jj++) {
				pRawDataset->pDataPerChannel[ii].pDataPerXPD[jj].numPcdacs = 0;
			}

			pRawDataset->pDataPerChannel[ii].pDataPerXPD[xgain_list[0]].pcdac[0] = pCalCh->pcd1_xg0;
			pRawDataset->pDataPerChannel[ii].pDataPerXPD[xgain_list[1]].pcdac[0] = 20;
			pRawDataset->pDataPerChannel[ii].pDataPerXPD[xgain_list[1]].pcdac[1] = 35;
			pRawDataset->pDataPerChannel[ii].pDataPerXPD[xgain_list[1]].pcdac[2] = 63;

			jj = xgain_list[0];
			pRawXPD = &(pRawDataset->pDataPerChannel[ii].pDataPerXPD[jj]);
			pRawXPD->numPcdacs = 4;
			pRawXPD->pcdac[1] = (A_UINT16)(pRawXPD->pcdac[0] + pCalCh->pcd2_delta_xg0);
			pRawXPD->pcdac[2] = (A_UINT16)(pRawXPD->pcdac[1] + pCalCh->pcd3_delta_xg0);
			pRawXPD->pcdac[3] = (A_UINT16)(pRawXPD->pcdac[2] + pCalCh->pcd4_delta_xg0);
			pRawXPD->pwr_t4[0] = pCalCh->pwr1_xg0;
			pRawXPD->pwr_t4[1] = pCalCh->pwr2_xg0;
			pRawXPD->pwr_t4[2] = pCalCh->pwr3_xg0;
			pRawXPD->pwr_t4[3] = pCalCh->pwr4_xg0;
				
			jj = xgain_list[1];
			pRawXPD = &(pRawDataset->pDataPerChannel[ii].pDataPerXPD[jj]);
			pRawXPD->numPcdacs = 3;

			pRawXPD->pwr_t4[0] = pCalCh->pwr1_xg3;
			pRawXPD->pwr_t4[1] = pCalCh->pwr2_xg3;
			pRawXPD->pwr_t4[2] = pCalCh->pwr3_xg3;
		}
	}
	devNum = 0;  //quiet warnings
}


A_BOOL get_xpd_gain_and_pcdacs_for_powers
(
 A_UINT32				devNum,                         // In
 A_UINT16				channel,                         // In       
 RAW_DATA_STRUCT_GEN3	*pRawDataset,					// In
 A_UINT32				numXpdGain,                      // In
 A_UINT32				xpdGainMask,                      // In     - desired xpd_gain
 A_INT16				*pPowerMin,                      // In/Out	(2 x power)
 A_INT16				*pPowerMax,                      // In/Out	(2 x power)
 A_INT16				*pPowerMid,                      // Out		(2 x power)
 A_UINT16				pXpdGainValues[],               // Out
 A_UINT16				pPCDACValues[]                  // Out 
)
{
	A_UINT32	ii, jj, kk;
	A_INT16		minPwr_t4, maxPwr_t4, Pmin, Pmid;

	A_UINT32	chan_idx_L, chan_idx_R;
	A_UINT16	chan_L, chan_R;
	
	A_INT16		pwr_table0[64];
	A_INT16		pwr_table1[64];
	RAW_DATA_PER_CHANNEL_GEN3	*pRawCh;	
	A_UINT16	pcdacs[10];
	A_INT16		powers[10];
	A_UINT16	numPcd;
	A_INT16		powTableLXPD[2][64];
	A_INT16		powTableHXPD[2][64];
	A_INT16		tmpPowerTable[64];
	A_UINT16		xgain_list[2];
	A_UINT16		xpd_mask;
	LIB_DEV_INFO *pLibDev = gLibInfo.pLibDevArray[devNum];
	
	if (pRawDataset == NULL) {
		mError(devNum, EINVAL,"NULL dataset pointer. This mode may not be supported.\n");
		return(FALSE);
	}
	
	if ((xpdGainMask & pRawDataset->xpd_mask) < 1) {
		mError(devNum, EINVAL,"desired xpdGainMask not supported by calibrated xpd_mask\n");
		return(FALSE);
	}

	maxPwr_t4 = (A_INT16)(2*(*pPowerMax));   // pwr_t2 -> pwr_t4
	minPwr_t4 = (A_INT16)(2*(*pPowerMin));	  // pwr_t2 -> pwr_t4



	xgain_list[0] = 0xDEAD;
	xgain_list[1] = 0xDEAD;
 
	kk = 0;
	xpd_mask = pRawDataset->xpd_mask;

	for (jj = 0; jj < NUM_XPD_PER_CHANNEL; jj++) {
		if (((xpd_mask >> jj) & 1) > 0) {
			if (kk > 1) {
				printf("A maximum of 2 xpd_gains supported in eep_to_raw_data\n");
				exit(0);
			}
			xgain_list[kk++] = (A_UINT16) jj;			
		}
	}

	mdk_GetLowerUpperIndex(channel, &(pRawDataset->pChannels[0]), pRawDataset->numChannels, &(chan_idx_L), &(chan_idx_R));

	kk = 0;
	for (ii=chan_idx_L; ii<=chan_idx_R; ii++) {
		pRawCh = &(pRawDataset->pDataPerChannel[ii]);
		if (xgain_list[1] == 0xDEAD) {
			jj = xgain_list[0];
			numPcd = pRawCh->pDataPerXPD[jj].numPcdacs;
			memcpy(&(pcdacs[0]), &(pRawCh->pDataPerXPD[jj].pcdac[0]), numPcd*sizeof(A_UINT16));
			memcpy(&(powers[0]), &(pRawCh->pDataPerXPD[jj].pwr_t4[0]), numPcd*sizeof(A_INT16));
			if (!mdk_getFullPwrTable(devNum, numPcd, &(pcdacs[0]), &(powers[0]), pRawCh->maxPower_t4, &(tmpPowerTable[0]))) {
				return(FALSE);
			} else {
				memcpy(&(powTableLXPD[kk][0]), &(tmpPowerTable[0]), 64*sizeof(A_INT16));
			}
		} else {
			jj = xgain_list[0];
			numPcd = pRawCh->pDataPerXPD[jj].numPcdacs;
			memcpy(&(pcdacs[0]), &(pRawCh->pDataPerXPD[jj].pcdac[0]), numPcd*sizeof(A_UINT16));
			memcpy(&(powers[0]), &(pRawCh->pDataPerXPD[jj].pwr_t4[0]), numPcd*sizeof(A_INT16));
			if (!mdk_getFullPwrTable(devNum, numPcd, &(pcdacs[0]), &(powers[0]), pRawCh->maxPower_t4, &(tmpPowerTable[0]))) {
				return(FALSE);
			} else {
				memcpy(&(powTableLXPD[kk][0]), &(tmpPowerTable[0]), 64*sizeof(A_INT16));
			}

			jj = xgain_list[1];
			numPcd = pRawCh->pDataPerXPD[jj].numPcdacs;
			memcpy(&(pcdacs[0]), &(pRawCh->pDataPerXPD[jj].pcdac[0]), numPcd*sizeof(A_UINT16));
			memcpy(&(powers[0]), &(pRawCh->pDataPerXPD[jj].pwr_t4[0]), numPcd*sizeof(A_INT16));
			if (!mdk_getFullPwrTable(devNum, numPcd, &(pcdacs[0]), &(powers[0]), pRawCh->maxPower_t4, &(tmpPowerTable[0]))) {
				return(FALSE);
			} else {
				memcpy(&(powTableHXPD[kk][0]), &(tmpPowerTable[0]), 64*sizeof(A_INT16));
			}
		}
			
		kk++;
	}
	
	chan_L = pRawDataset->pChannels[chan_idx_L];
	chan_R = pRawDataset->pChannels[chan_idx_R];
	kk = chan_idx_R - chan_idx_L;

	pLibDev->maxLinPwrx4 = mdk_GetInterpolatedValue_Signed16(channel, chan_L, chan_R, 
										pRawDataset->pDataPerChannel[chan_idx_L].pDataPerXPD[0].pwr_t4[2],
										pRawDataset->pDataPerChannel[chan_idx_R].pDataPerXPD[0].pwr_t4[2]);

	if (xgain_list[1] == 0xDEAD) {
		for (jj=0; jj<64; jj++) {
			pwr_table0[jj] = mdk_GetInterpolatedValue_Signed16(channel, chan_L, chan_R, powTableLXPD[0][jj], powTableLXPD[kk][jj]);			
		}
		Pmin = getPminAndPcdacTableFromPowerTable(devNum, &(pwr_table0[0]), pPCDACValues);
		*pPowerMin = (A_INT16) (Pmin / 2);
		*pPowerMid = (A_INT16) (pwr_table0[63] / 2);
		*pPowerMax = (A_INT16) (pwr_table0[63] / 2);
		pXpdGainValues[0] = xgain_list[0];
		pXpdGainValues[1] = pXpdGainValues[0];
	} else {
		for (jj=0; jj<64; jj++) {
			pwr_table0[jj] = mdk_GetInterpolatedValue_Signed16(channel, chan_L, chan_R, powTableLXPD[0][jj], powTableLXPD[kk][jj]);			
			pwr_table1[jj] = mdk_GetInterpolatedValue_Signed16(channel, chan_L, chan_R, powTableHXPD[0][jj], powTableHXPD[kk][jj]);			
		}
		if (numXpdGain == 2) {
	    	Pmin = getPminAndPcdacTableFromTwoPowerTables(devNum, &(pwr_table0[0]), &(pwr_table1[0]), pPCDACValues, &Pmid);
			*pPowerMin = (A_INT16) (Pmin / 2);
			*pPowerMid = (A_INT16) (Pmid / 2);
			*pPowerMax = (A_INT16) (pwr_table0[63] / 2);
			pXpdGainValues[0] = xgain_list[0];
			pXpdGainValues[1] = xgain_list[1];
		} else {
			if ( (minPwr_t4  <= pwr_table1[63]) && (maxPwr_t4  <= pwr_table1[63])) {
				Pmin = getPminAndPcdacTableFromPowerTable(devNum, &(pwr_table1[0]), pPCDACValues);
				pXpdGainValues[0] = xgain_list[1];
				pXpdGainValues[1] = pXpdGainValues[0];
				*pPowerMin = (A_INT16) (Pmin / 2);
				*pPowerMid = (A_INT16) (pwr_table1[63] / 2);
				*pPowerMax = (A_INT16) (pwr_table1[63] / 2);
			} else {
				Pmin = getPminAndPcdacTableFromPowerTable(devNum, &(pwr_table0[0]), pPCDACValues);
				pXpdGainValues[0] = xgain_list[0];
				pXpdGainValues[1] = xgain_list[0];
				*pPowerMin = (A_INT16) (Pmin/2);
				*pPowerMid = (A_INT16) (pwr_table0[63] / 2);
				*pPowerMax = (A_INT16) (pwr_table0[63] / 2);
			}
		}
	}

	if (isFalcon(devNum)) {
// since eirp_limited mode in falcon can't handle different Pmax values for 2 chains
// make it fixed 0-31.5 dBm
		*pPowerMax  = 63;
//		*pPowerMax += 2*FALCON_BAND_EIRP_HEADROOM_IN_DB;
	}

	devNum = 0;   //quiet compiler

    return(TRUE);
}
	

A_INT16 mdk_GetInterpolatedValue_Signed16(A_UINT16 target, A_UINT16 srcLeft, A_UINT16 srcRight, 
							 A_INT16 targetLeft, A_INT16 targetRight)
{
  A_INT16 returnValue;

  if (srcRight != srcLeft) {
		returnValue = (A_INT16)( ( (target - srcLeft)*targetRight + (srcRight - target)*targetLeft)/(srcRight - srcLeft));
  } 
  else {
		returnValue = targetLeft;
  }
  return (returnValue);
}


// returns indices surrounding the value in sorted integer lists. used for channel and pcdac lists
void mdk_GetLowerUpperIndex (
 A_UINT16	value,			//value to search for
 A_UINT16	*pList,			//ptr to the list to search
 A_UINT16	listSize,		//number of entries in list
 A_UINT32	*pLowerValue,	//return the lower value
 A_UINT32	*pUpperValue	//return the upper value	
)
{
	A_UINT16	i;
	A_UINT16	listEndValue = *(pList + listSize - 1);
	A_UINT16	target = value ;

	//see if value is lower than the first value in the list
	//if so return first value
	if (target <= (*pList)) {
		*pLowerValue = 0;
		*pUpperValue = 0;
		return;
	}
  
	//see if value is greater than last value in list
	//if so return last value
	if (target >= listEndValue) {
		*pLowerValue = listSize - 1;
		*pUpperValue = listSize - 1;
		return;
	}

	//look for value being near or between 2 values in list
	for(i = 0; i < listSize; i++) {
		//if value is close to the current value of the list 
		//then target is not between values, it is one of the values
		if (pList[i] == target) {
			*pLowerValue = i;
			*pUpperValue = i;
			return;
		}

		//look for value being between current value and next value
		//if so return these 2 values
		if (target < pList[i + 1]) {
			*pLowerValue = i;
			*pUpperValue = i + 1;
			return;
		}
	}
} 

A_UINT16 fbin2freq_gen3(A_UINT32 fbin, A_UINT32 mode)
{
	A_UINT16 returnValue; 

	if(mode == MODE_11A) {

⌨️ 快捷键说明

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