📄 cal_gen5.c
字号:
fprintf(fStream,"\n");
}
fclose(fStream);
}
void raw_to_eeprom_dataset_gen5(RAW_DATA_STRUCT_GEN5 *pRawDataset, EEPROM_DATA_STRUCT_GEN5 *pCalDataset) {
A_UINT16 ii, jj, kk;
EEPROM_DATA_PER_CHANNEL_GEN5 *pCalCh;
RAW_DATA_PER_CHANNEL_GEN5 *pRawCh;
A_UINT16 xgain_list[MAX_NUM_PDGAINS_PER_CHANNEL];
A_UINT16 xpd_mask, pd_gain;
double Vpd_I_diff, pwr_I_delta_t4, pwr_I_diff_t4, Vpd_I_delta;
double vpd_delta_diff, pwr_delta_delta_t4, pwr_delta_diff_t4, vpd_delta_delta;
A_INT16 pwr_current_t4, vpd_current;
xgain_list[0] = 0xDEAD;
xgain_list[1] = 0xDEAD;
pCalDataset->xpd_mask = pRawDataset->xpd_mask;
kk = 0;
xpd_mask = pRawDataset->xpd_mask;
for (jj = 0; jj < MAX_NUM_PDGAINS_PER_CHANNEL; jj++) {
if (((xpd_mask >> jj) & 1) > 0) {
if (kk > (MAX_NUM_PDGAINS_PER_CHANNEL - 1)) {
uiPrintf("A maximum of %d xpd_gains supported in raw data\n", MAX_NUM_PDGAINS_PER_CHANNEL);
exit(0);
}
xgain_list[kk++] = (A_UINT16) jj;
}
}
pCalDataset->numChannels = pRawDataset->numChannels;
for (ii = 0; ii < pCalDataset->numChannels; ii++) {
pCalCh = &(pCalDataset->pDataPerChannel[ii]);
pRawCh = &(pRawDataset->pDataPerChannel[ii]);
pCalCh->channelValue = pRawCh->channelValue;
pCalCh->maxPower_t4 = pRawCh->maxPower_t4;
pCalCh->numPdGains = pRawCh->numPdGains;
for (jj = 0; jj < pCalCh->numPdGains; jj++) {
pd_gain = xgain_list[jj];
pCalCh->pwr_I[jj] = (A_INT16)((pRawCh->pDataPerPDGain[jj].pwr_t4[0] + 2)/4);
pwr_I_delta_t4 = ((4*pCalCh->pwr_I[jj]) - pRawCh->pDataPerPDGain[jj].pwr_t4[0]);
Vpd_I_diff = (pRawCh->pDataPerPDGain[jj].Vpd[1] - pRawCh->pDataPerPDGain[jj].Vpd[0]);
pwr_I_diff_t4 = (pRawCh->pDataPerPDGain[jj].pwr_t4[1] - pRawCh->pDataPerPDGain[jj].pwr_t4[0]);
if (pwr_I_diff_t4 != 0) {
Vpd_I_delta = ((Vpd_I_diff*pwr_I_delta_t4)/pwr_I_diff_t4) + 0.5;
} else {
Vpd_I_delta = 0;
}
pCalCh->Vpd_I[jj] = (pRawCh->pDataPerPDGain[jj].Vpd[0] + (A_INT16)Vpd_I_delta);
pwr_current_t4 = 4*pCalCh->pwr_I[jj];
vpd_current = pCalCh->Vpd_I[jj];
for (kk = 0; kk < (pRawCh->pDataPerPDGain[jj].numVpd - 1); kk++) {
pCalCh->pwr_delta_t2[kk][jj] = (A_INT16)((pRawCh->pDataPerPDGain[jj].pwr_t4[kk+1] - pwr_current_t4 + 1 )/2);
pwr_current_t4 = pwr_current_t4 + (2 * pCalCh->pwr_delta_t2[kk][jj]);
pwr_delta_delta_t4 = pwr_current_t4 - pRawCh->pDataPerPDGain[jj].pwr_t4[kk+1];
vpd_delta_diff = (pRawCh->pDataPerPDGain[jj].Vpd[kk+1] - pRawCh->pDataPerPDGain[jj].Vpd[kk]);
pwr_delta_diff_t4 = (pRawCh->pDataPerPDGain[jj].pwr_t4[kk+1] - pRawCh->pDataPerPDGain[jj].pwr_t4[kk]);
if (pwr_delta_diff_t4 != 0) {
vpd_delta_delta = ((vpd_delta_diff*pwr_delta_delta_t4)/pwr_delta_diff_t4) + 0.5;
} else {
vpd_delta_delta = 0;
}
if (pRawCh->pDataPerPDGain[jj].Vpd[kk+1] < vpd_current) {
pCalCh->Vpd_delta[kk][jj] = 0;
} else {
pCalCh->Vpd_delta[kk][jj] = (pRawCh->pDataPerPDGain[jj].Vpd[kk+1] - vpd_current) + (A_INT16)vpd_delta_delta;
}
vpd_current = vpd_current + pCalCh->Vpd_delta[kk][jj];
}
}
}
}
void fill_words_for_eeprom_gen5(A_UINT32 *word, A_UINT16 numWords, A_UINT16 *fbin,
A_UINT16 dbmmask, A_UINT16 pcdmask, A_UINT16 freqmask)
{
A_UINT16 idx = 0;
EEPROM_DATA_PER_CHANNEL_GEN5 *pCalCh;
A_UINT16 ii;
A_UINT16 numPiers;
A_UINT16 pwr_mask = 0x1F; // 5 bits
A_UINT16 vpd_mask = 0x7F; // 7 bits
A_UINT16 pwr_delta_mask = 0xF; // 4 bits
A_UINT16 vpd_delta_mask = 0x3F; // 6 bits
A_UINT16 i, num_words;
//fill in dummy eep_map 1 data for driver's that does not know how to
//crunch the eep_map = 2 data
for (i = 0; i < NUM_DUMMY_EEP_MAP1_LOCATIONS; i++) {
word[idx++] = dummpy_eep_map1_data[i];
}
// Group 1. 11a Frequency pier locations
if(CalSetup.calPower && CalSetup.Amode)
{
word[idx++] = ( (fbin[1] & freqmask) << 8) | (fbin[0] & freqmask) ;
word[idx++] = ( (fbin[3] & freqmask) << 8) | (fbin[2] & freqmask) ;
word[idx++] = ( (fbin[5] & freqmask) << 8) | (fbin[4] & freqmask) ;
word[idx++] = ( (fbin[7] & freqmask) << 8) | (fbin[6] & freqmask) ;
word[idx++] = ( (fbin[9] & freqmask) << 8) | (fbin[8] & freqmask) ;
} else {
}
//Group 2. 11a calibration data for all frequency piers
if(CalSetup.calPower && CalSetup.Amode)
{
for (ii=0; ii<pCalDataset_gen5[MODE_11a]->numChannels; ii++)
{
pCalCh = &(pCalDataset_gen5[MODE_11a]->pDataPerChannel[ii]);
num_words = fill_eeprom_words_for_curr_ch_gen5(&(word[idx]), pCalCh);
idx += num_words;
/*
word[idx++] = ( ( (pCalCh->pwr_I[0] & pwr_mask) << 0) |
( (pCalCh->Vpd_I[0] & vpd_mask) << 5) |
( (pCalCh->pwr_delta_t2[0][0] & pwr_delta_mask) << 12 ));
word[idx++] = ( ( (pCalCh->Vpd_delta[0][0] & vpd_delta_mask) << 0) |
( (pCalCh->pwr_delta_t2[1][0] & pwr_delta_mask) << 6) |
( (pCalCh->Vpd_delta[1][0] & vpd_delta_mask) << 10));
word[idx++] = ( ( (pCalCh->pwr_delta_t2[2][0] & pwr_delta_mask) << 0) |
( (pCalCh->Vpd_delta[2][0] & vpd_delta_mask) << 4) |
( (pCalCh->pwr_I[1] & pwr_mask) << 10) |
( (pCalCh->Vpd_I[1] & vpd_mask) << 15 ));
word[idx++] = ( ( (pCalCh->Vpd_I[1] & vpd_mask) >> 1) |
( (pCalCh->pwr_delta_t2[0][1] & pwr_delta_mask) << 6) |
( (pCalCh->Vpd_delta[0][1] & vpd_delta_mask) << 10));
word[idx++] = ( ( (pCalCh->pwr_delta_t2[1][1] & pwr_delta_mask) << 0 ) |
( (pCalCh->Vpd_delta[1][1] & vpd_delta_mask) << 4) |
( (pCalCh->pwr_delta_t2[2][1] & pwr_delta_mask) << 10) |
( (pCalCh->Vpd_delta[2][1] & vpd_delta_mask) << 14));
word[idx++] = ( ( (pCalCh->Vpd_delta[2][1] & vpd_delta_mask) >> 2) |
( (pCalCh->pwr_delta_t2[3][1] & pwr_delta_mask) << 4) |
( (pCalCh->Vpd_delta[3][1] & vpd_delta_mask) << 8));
*/
}
} else
{
}
// Group 3. 11b Frequency pier locations for eep_map = 2
if(CalSetup.calPower && CalSetup.Bmode)
{
word[idx++] = (freq2fbin(CalSetup.piersList_2p4[MODE_11b][0]) & 0xff) |
(( (CalSetup.numForcedPiers_2p4[MODE_11b] > 1) ? (freq2fbin(CalSetup.piersList_2p4[MODE_11b][1]) & 0xFF) : 0) << 8);
if (CalSetup.numForcedPiers_2p4[MODE_11b] > 2) {
word[idx++] = (freq2fbin(CalSetup.piersList_2p4[MODE_11b][2]) & 0xff) |
(( (CalSetup.numForcedPiers_2p4[MODE_11b] > 3) ? (freq2fbin(CalSetup.piersList_2p4[MODE_11b][3]) & 0xFF) : 0) << 8);
} else {
word[idx++] = 0 ;
}
} else {
}
//Group 4. 11b Calibration Information
if(CalSetup.calPower && CalSetup.Bmode)
{
numPiers = pCalDataset_gen5[MODE_11b]->numChannels;
for (ii=0; ii<numPiers; ii++)
{
fbin[ii] = freq2fbin(pCalDataset_gen5[MODE_11b]->pChannels[ii]) ;
}
if (numPiers < NUM_PIERS_2p4) {
for (ii=numPiers; ii<NUM_PIERS_2p4; ii++) {
fbin[ii] = 0;
}
}
for (ii=0; ii<pCalDataset_gen5[MODE_11b]->numChannels; ii++)
{
pCalCh = &(pCalDataset_gen5[MODE_11b]->pDataPerChannel[ii]);
num_words = fill_eeprom_words_for_curr_ch_gen5(&(word[idx]), pCalCh);
idx += num_words;
/*
word[idx++] = ( ( (pCalCh->pwr_I[0] & pwr_mask) << 0) |
( (pCalCh->Vpd_I[0] & vpd_mask) << 5) |
( (pCalCh->pwr_delta_t2[0][0] & pwr_delta_mask) << 12 ));
word[idx++] = ( ( (pCalCh->Vpd_delta[0][0] & vpd_delta_mask) << 0) |
( (pCalCh->pwr_delta_t2[1][0] & pwr_delta_mask) << 6) |
( (pCalCh->Vpd_delta[1][0] & vpd_delta_mask) << 10));
word[idx++] = ( ( (pCalCh->pwr_delta_t2[2][0] & pwr_delta_mask) << 0) |
( (pCalCh->Vpd_delta[2][0] & vpd_delta_mask) << 4) |
( (pCalCh->pwr_I[1] & pwr_mask) << 10) |
( (pCalCh->Vpd_I[1] & vpd_mask) << 15 ));
word[idx++] = ( ( (pCalCh->Vpd_I[1] & vpd_mask) >> 1) |
( (pCalCh->pwr_delta_t2[0][1] & pwr_delta_mask) << 6) |
( (pCalCh->Vpd_delta[0][1] & vpd_delta_mask) << 10));
word[idx++] = ( ( (pCalCh->pwr_delta_t2[1][1] & pwr_delta_mask) << 0 ) |
( (pCalCh->Vpd_delta[1][1] & vpd_delta_mask) << 4) |
( (pCalCh->pwr_delta_t2[2][1] & pwr_delta_mask) << 10) |
( (pCalCh->Vpd_delta[2][1] & vpd_delta_mask) << 14));
word[idx++] = ( ( (pCalCh->Vpd_delta[2][1] & vpd_delta_mask) >> 2) |
( (pCalCh->pwr_delta_t2[3][1] & pwr_delta_mask) << 4) |
( (pCalCh->Vpd_delta[3][1] & vpd_delta_mask) << 8));
*/
}
} else
{
}
// Group 5. 11g Frequency pier locations for eep_map = 2
if(CalSetup.calPower && CalSetup.Gmode)
{
word[idx++] = (freq2fbin(CalSetup.piersList_2p4[MODE_11g][0]) & 0xff) |
(( (CalSetup.numForcedPiers_2p4[MODE_11g] > 1) ? (freq2fbin(CalSetup.piersList_2p4[MODE_11g][1]) & 0xFF) : 0) << 8);
if (CalSetup.numForcedPiers_2p4[MODE_11g] > 2) {
word[idx++] = (freq2fbin(CalSetup.piersList_2p4[MODE_11g][2]) & 0xff) |
(( (CalSetup.numForcedPiers_2p4[MODE_11g] > 3) ? (freq2fbin(CalSetup.piersList_2p4[MODE_11g][3]) & 0xFF) : 0) << 8);
} else {
word[idx++] = 0;
}
} else {
}
//Group 6. 11g Calibration Piers and Calibration Information
if(CalSetup.calPower && CalSetup.Gmode)
{
numPiers = pCalDataset_gen5[MODE_11g]->numChannels;
for (ii=0; ii<numPiers; ii++)
{
fbin[ii] = freq2fbin(pCalDataset_gen5[MODE_11g]->pChannels[ii]) ;
}
if (numPiers < NUM_PIERS_2p4) {
for (ii=numPiers; ii<NUM_PIERS_2p4; ii++) {
fbin[ii] = 0;
}
}
for (ii=0; ii<pCalDataset_gen5[MODE_11g]->numChannels; ii++)
{
pCalCh = &(pCalDataset_gen5[MODE_11g]->pDataPerChannel[ii]);
num_words = fill_eeprom_words_for_curr_ch_gen5(&(word[idx]), pCalCh);
idx += num_words;
/*
word[idx++] = ( ( (pCalCh->pwr_I[0] & pwr_mask) << 0) |
( (pCalCh->Vpd_I[0] & vpd_mask) << 5) |
( (pCalCh->pwr_delta_t2[0][0] & pwr_delta_mask) << 12 ));
word[idx++] = ( ( (pCalCh->Vpd_delta[0][0] & vpd_delta_mask) << 0) |
( (pCalCh->pwr_delta_t2[1][0] & pwr_delta_mask) << 6) |
( (pCalCh->Vpd_delta[1][0] & vpd_delta_mask) << 10));
word[idx++] = ( ( (pCalCh->pwr_delta_t2[2][0] & pwr_delta_mask) << 0) |
( (pCalCh->Vpd_delta[2][0] & vpd_delta_mask) << 4) |
( (pCalCh->pwr_I[1] & pwr_mask) << 10) |
( (pCalCh->Vpd_I[1] & vpd_mask) << 15 ));
word[idx++] = ( ( (pCalCh->Vpd_I[1] & vpd_mask) >> 1) |
( (pCalCh->pwr_delta_t2[0][1] & pwr_delta_mask) << 6) |
( (pCalCh->Vpd_delta[0][1] & vpd_delta_mask) << 10));
word[idx++] = ( ( (pCalCh->pwr_delta_t2[1][1] & pwr_delta_mask) << 0 ) |
( (pCalCh->Vpd_delta[1][1] & vpd_delta_mask) << 4) |
( (pCalCh->pwr_delta_t2[2][1] & pwr_delta_mask) << 10) |
( (pCalCh->Vpd_delta[2][1] & vpd_delta_mask) << 14));
word[idx++] = ( ( (pCalCh->Vpd_delta[2][1] & vpd_delta_mask) >> 2) |
( (pCalCh->pwr_delta_t2[3][1] & pwr_delta_mask) << 4) |
( (pCalCh->Vpd_delta[3][1] & vpd_delta_mask) << 8));
*/
}
} else
{
}
//printf("SNOOP: fill_wrds_gen5 : startidx = 0x%x\n", idx);
fill_Target_Power_and_Test_Groups(&(word[idx]), (A_UINT16)(numWords - idx + 1), dbmmask, pcdmask, freqmask);
}
A_UINT16 fill_eeprom_words_for_curr_ch_gen5(A_UINT32 *word, EEPROM_DATA_PER_CHANNEL_GEN5 *pCalCh)
{
A_UINT16 pwr_mask = 0x1F; // 5 bits
A_UINT16 vpd_mask = 0x7F; // 7 bits
A_UINT16 pwr_delta_mask = 0xF; // 4 bits
A_UINT16 vpd_delta_mask = 0x3F; // 6 bits
A_UINT16 idx = 0;
word[idx++] = ( ( (pCalCh->pwr_I[0] & pwr_mask) << 0) |
( (pCalCh->Vpd_I[0] & vpd_mask) << 5) |
( (pCalCh->pwr_delta_t2[0][0] & pwr_delta_mask) << 12 ));
word[idx++] = ( ( (pCalCh->Vpd_delta[0][0] & vpd_delta_mask) << 0) |
( (pCalCh->pwr_delta_t2[1][0] & pwr_delta_mask) << 6) |
( (pCalCh->Vpd_delta[1][0] & vpd_delta_mask) << 10));
if (pCalCh->numPdGains < 2) { // 5 points if last pd_gain
word[idx++] = ( ( (pCalCh->pwr_delta_t2[2][0] & pwr_delta_mask) << 0) |
( (pCalCh->Vpd_delta[2][0] & vpd_delta_mask) << 4) |
( (pCalCh->pwr_delta_t2[3][0] & pwr_delta_mask) << 10) |
( (pCalCh->Vpd_delta[3][0] & 0x3) << 14));
word[idx++] = ( ( (pCalCh->Vpd_delta[3][0] >> 2) & 0xF) << 0);
return(idx); // idx = 4
} else {
word[idx++] = ( ( (pCalCh->pwr_delta_t2[2][0] & pwr_delta_mask) << 0) |
( (pCalCh->Vpd_delta[2][0] & vpd_delta_mask) << 4) |
( (pCalCh->pwr_I[1] & pwr_mask) << 10) |
( (pCalCh->Vpd_I[1] & vpd_mask) << 15 ));
word[idx++] = ( ( (pCalCh->Vpd_I[1] & vpd_mask) >> 1) |
( (pCalCh->pwr_delta_t2[0][1] & pwr_delta_mask) << 6) |
( (pCalCh->Vpd_delta[0][1] & vpd_delta_mask) << 10));
}
word[idx++] = ( ( (pCalCh->pwr_delta_t2[1][1] & pwr_delta_mask) << 0 ) |
( (pCalCh->Vpd_delta[1][1] & vpd_delta_mask) << 4) |
( (pCalCh->pwr_delta_t2[2][1] & pwr_delta_mask) << 10) |
( (pCalCh->Vpd_delta[2][1] & 0x3) << 14));
if (pCalCh->numPdGains < 3) {
word[idx++] = ( ( (pCalCh->Vpd_delta[2][1] & vpd_delta_mask) >> 2) |
( (pCalCh->pwr_delta_t2[3][1] & pwr_delta_mask) << 4) |
( (pCalCh->Vpd_delta[3][1] & vpd_delta_mask) << 8));
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -