📄 l1_cust.c_traceversion
字号:
l1_config.params.prg_tx_gsm = rf.tx.prg_tx;
l1_config.params.prg_tx_dcs = rf.tx.prg_tx; //delay for dual band not implemented yet
l1_config.params.low_agc_noise_thr = rf.rx.agc.low_agc_noise_thr;
l1_config.params.high_agc_sat_thr = rf.rx.agc.high_agc_sat_thr;
l1_config.params.low_agc = rf.rx.agc.low_agc;
l1_config.params.high_agc = rf.rx.agc.high_agc;
l1_config.params.il_min = IL_MIN;
l1_config.params.fixed_txpwr = FIXED_TXPWR;
l1_config.params.eeprom_afc = rf.afc.eeprom_afc;
l1_config.params.setup_afc_and_rf = SETUP_AFC_AND_RF;
l1_config.params.psi_sta_inv = rf.afc.psi_sta_inv;
l1_config.params.psi_st = rf.afc.psi_st;
l1_config.params.psi_st_32 = rf.afc.psi_st_32;
l1_config.params.psi_st_inv = rf.afc.psi_st_inv;
#if (CODE_VERSION == SIMULATION)
#if (VCXO_ALGO == 1)
l1_config.params.afc_algo = ALGO_AFC_LQG_PREDICTOR; // VCXO|VCTCXO - Choosing AFC algorithm
#endif
#else
#if (VCXO_ALGO == 1)
l1_config.params.afc_dac_center = rf.afc.dac_center; // VCXO - assuming DAC linearity
l1_config.params.afc_dac_min = rf.afc.dac_min; // VCXO - assuming DAC linearity
l1_config.params.afc_dac_max = rf.afc.dac_max; // VCXO - assuming DAC linearity
l1_config.params.afc_snr_thr = rf.afc.snr_thr; // VCXO - SNR threshold
l1_config.params.afc_algo = ALGO_AFC_LQG_PREDICTOR; // VCXO|VCTCXO - Choosing AFC algorithm
l1_config.params.afc_win_avg_size_M = C_WIN_AVG_SIZE_M; // VCXO - Average psi values with this value
l1_config.params.rgap_algo = ALGO_AFC_RXGAP; // VCXO - Choosing Reception Gap algorithm
l1_config.params.rgap_bad_snr_count_B = C_RGAP_BAD_SNR_COUNT_B; // VCXO - Prediction SNR count
#endif
#endif
#if DCO_ALGO
#if (RF == 10)
// Enable DCO algorithm for direct conversion RFs
l1_config.params.dco_enabled = TRUE;
#else
l1_config.params.dco_enabled = FALSE;
#endif
#endif
#if (ANALOG == 1)
l1_config.params.debug1 = C_DEBUG1; // Enable f_tx delay of 400000 cyc DEBUG
l1_config.params.afcctladd = abb[ABB_AFCCTLADD]; // Value at reset
l1_config.params.vbur = abb[ABB_VBUR]; // Uplink gain amp 0dB, Sidetone gain to mute
l1_config.params.vbdr = abb[ABB_VBDR]; // Downlink gain amp 0dB, Volume control 0 dB
l1_config.params.bbctl = abb[ABB_BBCTL]; // value at reset
l1_config.params.apcoff = abb[ABB_APCOFF]; // value at reset
l1_config.params.bulioff = abb[ABB_BULIOFF]; // value at reset
l1_config.params.bulqoff = abb[ABB_BULQOFF]; // value at reset
l1_config.params.dai_onoff = abb[ABB_DAI_ON_OFF]; // value at reset
l1_config.params.auxdac = abb[ABB_AUXDAC]; // value at reset
l1_config.params.vbcr = abb[ABB_VBCR]; // VULSWITCH=0, VDLAUX=1, VDLEAR=1
l1_config.params.apcdel = abb[ABB_APCDEL]; // value at reset
#endif
#if (ANALOG == 2)
l1_config.params.debug1 = C_DEBUG1; // Enable f_tx delay of 400000 cyc DEBUG
l1_config.params.afcctladd = abb[ABB_AFCCTLADD]; // Value at reset
l1_config.params.vbur = abb[ABB_VBUR]; // Uplink gain amp 0dB, Sidetone gain to mute
l1_config.params.vbdr = abb[ABB_VBDR]; // Downlink gain amp 0dB, Volume control 0 dB
l1_config.params.bbctl = abb[ABB_BBCTL]; // value at reset
l1_config.params.bulgcal = abb[ABB_BULGCAL]; // value at reset
l1_config.params.apcoff = abb[ABB_APCOFF]; // value at reset
l1_config.params.bulioff = abb[ABB_BULIOFF]; // value at reset
l1_config.params.bulqoff = abb[ABB_BULQOFF]; // value at reset
l1_config.params.dai_onoff = abb[ABB_DAI_ON_OFF]; // value at reset
l1_config.params.auxdac = abb[ABB_AUXDAC]; // value at reset
l1_config.params.vbcr = abb[ABB_VBCR]; // VULSWITCH=0, VDLAUX=1, VDLEAR=1
l1_config.params.vbcr2 = abb[ABB_VBCR2]; // MICBIASEL=0, VDLHSO=0, MICAUX=0
l1_config.params.apcdel = abb[ABB_APCDEL]; // value at reset
l1_config.params.apcdel2 = abb[ABB_APCDEL2]; // value at reset
#endif
#if (ANALOG == 3)
l1_config.params.debug1 = C_DEBUG1; // Enable f_tx delay of 400000 cyc DEBUG
l1_config.params.afcctladd = abb[ABB_AFCCTLADD]; // Value at reset
l1_config.params.vbur = abb[ABB_VBUR]; // Uplink gain amp 0dB, Sidetone gain to mute
l1_config.params.vbdr = abb[ABB_VBDR]; // Downlink gain amp 0dB, Volume control 0 dB
l1_config.params.bbctl = abb[ABB_BBCTL]; // value at reset
l1_config.params.bulgcal = abb[ABB_BULGCAL]; // value at reset
l1_config.params.apcoff = abb[ABB_APCOFF]; // X2 Slope 128 and APCSWP disabled
l1_config.params.bulioff = abb[ABB_BULIOFF]; // value at reset
l1_config.params.bulqoff = abb[ABB_BULQOFF]; // value at reset
l1_config.params.dai_onoff = abb[ABB_DAI_ON_OFF]; // value at reset
l1_config.params.auxdac = abb[ABB_AUXDAC]; // value at reset
l1_config.params.vbcr = abb[ABB_VBCR]; // VULSWITCH=0
l1_config.params.vbcr2 = abb[ABB_VBCR2]; // MICBIASEL=0, VDLHSO=0, MICAUX=0
l1_config.params.apcdel = abb[ABB_APCDEL]; // value at reset
l1_config.params.apcdel2 = abb[ABB_APCDEL2]; // value at reset
l1_config.params.vbpop = abb[ABB_VBPOP]; // HSOAUTO enabled
l1_config.params.vau_delay_init = abb[ABB_VAUDINITD]; // 2 TDMA Frames between VDL "ON" and VDLHSO "ON"
l1_config.params.vaud_cfg = abb[ABB_VAUDCR]; // value at reset
l1_config.params.vauo_onoff = abb[ABB_VAUOCR]; // speech on AUX and EAR
l1_config.params.vaus_vol = abb[ABB_VAUSCR]; // value at reset
l1_config.params.vaud_pll = abb[ABB_VAUDPLL]; // value at reset
#endif
// global variable for access to deep sleep time
l1_config.params.sleep_time = 0;
}
/************************************/
/* Automatic Gain Control */
/************************************/
/*-------------------------------------------------------*/
/* Cust_get_agc_from_IL() */
/*-------------------------------------------------------*/
/* Parameters : */
/* Return : */
/* Functionality : returns agc value */
/*-------------------------------------------------------*/
WORD8 Cust_get_agc_from_IL(UWORD16 radio_freq, UWORD16 agc_index, UWORD8 table_id)
{
// radio_freq currently not used
// this parameter is passed in order to allow band dependent tables for specific RFs
// (e.g. dual band RF with separate AGC H/W blocks for GSM and DCS)
if (agc_index > 120)
agc_index = 120; // Clip agc_index
switch (table_id)
{
case MAX_ID: return(rf.rx.agc.il2agc_max[agc_index]);
case AV_ID: return(rf.rx.agc.il2agc_av[agc_index]);
case PWR_ID: return(rf.rx.agc.il2agc_pwr[agc_index]);
}
}
/*-------------------------------------------------------*/
/* Cust_get_agc_band */
/*-------------------------------------------------------*/
/* Parameters : radio_freq */
/* Return : band number */
/* Functionality : Computes the band for RF calibration */
/*-------------------------------------------------------*/
/*---------------------------------------------*/
#if (CODE_VERSION == SIMULATION)
UWORD16 Cust_get_agc_band(UWORD16 arfcn, UWORD8 gsm_band)
#else
UWORD16 inline Cust_get_agc_band(UWORD16 arfcn, UWORD8 gsm_band)
#endif
{
WORD32 i ;
for (i=0;i<RF_RX_CAL_CHAN_SIZE;i++)
{
if (arfcn <= rf_band[gsm_band].rx.agc_bands[i].upper_bound)
return(i);
}
// Should never happen!
return(0);
}
/*-------------------------------------------------------*/
/* Cust_is_band_high */
/*-------------------------------------------------------*/
/* Parameters : arfcn */
/* Return : 0 if low band */
/* 1 if high band */
/* Functionality : Generic function which return 1 if */
/* arfcn is in the high band */
/*-------------------------------------------------------*/
UWORD8 Cust_is_band_high(UWORD16 radio_freq)
{
UWORD16 max_carrier;
UWORD8 std = l1_config.std.id;
max_carrier = band_config[std_config[std].band[0]].max_carrier;
return(((radio_freq >= l1_config.std.first_radio_freq) &&
(radio_freq < (l1_config.std.first_radio_freq + max_carrier))) ? MULTI_BAND1 : MULTI_BAND2);
}
/*-------------------------------------------------------*/
/* l1ctl_encode_delta2() */
/*-------------------------------------------------------*/
/* Parameters : */
/* Return : */
/* Functionality : */
/*-------------------------------------------------------*/
WORD8 l1ctl_encode_delta2(UWORD16 radio_freq)
{
WORD8 delta2_freq;
UWORD16 i;
UWORD16 arfcn;
UWORD8 band;
band = Cust_is_band_high(radio_freq);
arfcn = Convert_l1_radio_freq(radio_freq);
i = Cust_get_agc_band(arfcn,band); //
delta2_freq = rf_band[band].rx.agc_bands[i].agc_calib;
//temperature compensation
for (i=0;i<RF_RX_CAL_TEMP_SIZE;i++)
{
if ((WORD16)adc.converted[ADC_RFTEMP] <= rf_band[band].rx.temp[i].temperature)
{
delta2_freq += rf_band[band].rx.temp[i].agc_calib;
break;
}
}
return(delta2_freq);
}
/************************************/
/* TX Management */
/************************************/
/*-------------------------------------------------------*/
/* Cust_get_ramp_tab */
/*-------------------------------------------------------*/
/* Parameters : */
/* Return : */
/* Functionality : */
/*-------------------------------------------------------*/
void Cust_get_ramp_tab(API *a_ramp, UWORD8 txpwr_ramp_up, UWORD8 txpwr_ramp_down, UWORD16 radio_freq)
{
UWORD16 index_up, index_down,j, arfcn;
UWORD8 band;
band = Cust_is_band_high(radio_freq);
arfcn = Convert_l1_radio_freq(radio_freq);
index_up = rf_band[band].tx.levels[txpwr_ramp_up].ramp_index;
index_down = rf_band[band].tx.levels[txpwr_ramp_down].ramp_index;
#if ((ANALOG == 1) || (ANALOG == 2) || (ANALOG == 3))
for (j=0; j<16; j++)
{
a_ramp[j]=((rf_band[band].tx.ramp_tables[index_down].ramp_down[j])<<11) |
((rf_band[band].tx.ramp_tables[index_up].ramp_up[j]) << 6) |
0x14;
}
#endif
}
/*-------------------------------------------------------*/
/* get_pwr_data */
/*-------------------------------------------------------*/
/* Parameters : */
/* Return : */
/* Functionality : */
/*-------------------------------------------------------*/
#if ((ANALOG == 1) || (ANALOG == 2) || (ANALOG == 3))
UWORD16 Cust_get_pwr_data(UWORD8 txpwr, UWORD16 radio_freq)
{
UWORD16 i,j;
UWORD16 arfcn;
UWORD8 band;
#if(ORDER2_TX_TEMP_CAL==1)
WORD16 pwr_data;
#else
UWORD16 pwr_data;
#endif
band = Cust_is_band_high(radio_freq);
arfcn = Convert_l1_radio_freq(radio_freq);
i = rf_band[band].tx.levels[txpwr].chan_cal_index;
j=0;
// get uncalibrated apc
pwr_data = rf_band[band].tx.levels[txpwr].apc;
while (arfcn > rf_band[band].tx.chan_cal_table[i][j].arfcn_limit)
j++;
// channel calibrate apc
pwr_data = ((UWORD32) (pwr_data * rf_band[band].tx.chan_cal_table[i][j].chan_cal))/128;
// temperature compensate apc
{
T_TX_TEMP_CAL *pt;
pt = rf_band[band].tx.temp;
while ((WORD16)adc.converted[ADC_RFTEMP] > pt->temperature)
pt++;
#if(ORDER2_TX_TEMP_CAL==1)
pwr_data += (txpwr*(pt->a*txpwr + pt->b) + pt->c) / 64; //delta apc = ax^2+bx+c
if(pwr_data < 0) pwr_data = 0;
#else
pwr_data += pt->apc_calib;
#endif
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -