diff --git a/executables/nr-ru.c b/executables/nr-ru.c index fbe757ca300ec1489dd6a67f05cba4b965c1fa29..e050c2776a4c72bdd7a251901567a62676575c27 100644 --- a/executables/nr-ru.c +++ b/executables/nr-ru.c @@ -1049,11 +1049,12 @@ void fill_rf_config(RU_t *ru, char *rf_config_file) { cfg->tx_gain[i] = ru->att_tx; cfg->rx_gain[i] = ru->max_rxgain-ru->att_rx; cfg->configFilename = rf_config_file; - LOG_I(PHY, "Channel %d: setting tx_gain offset %f, rx_gain offset %f, tx_freq %lu Hz, rx_freq %lu Hz\n", + LOG_I(PHY, "Channel %d: setting tx_gain offset %f, rx_gain offset %f, tx_freq %.0f Hz, rx_freq %.0f Hz, tune_offset %.0f Hz\n", i, cfg->tx_gain[i], cfg->rx_gain[i], - (unsigned long)cfg->tx_freq[i], - (unsigned long)cfg->rx_freq[i]); + cfg->tx_freq[i], + cfg->rx_freq[i], + cfg->tune_offset); } } @@ -2051,6 +2052,8 @@ static void NRRCconfig_RU(void) { RC.ru[j]->openair0_cfg.time_source = internal; } + RC.ru[j]->openair0_cfg.tune_offset = get_softmodem_params()->tune_offset; + if (strcmp(*(RUParamList.paramarray[j][RU_LOCAL_RF_IDX].strptr), "yes") == 0) { if ( !(config_isparamset(RUParamList.paramarray[j],RU_LOCAL_IF_NAME_IDX)) ) { RC.ru[j]->if_south = LOCAL_RF; diff --git a/executables/nr-uesoftmodem.c b/executables/nr-uesoftmodem.c index b1960faf7d555057cba80704529d2f71ccd9eef0..234705540273ac85571d27a216ac910a0e9c2dde 100644 --- a/executables/nr-uesoftmodem.c +++ b/executables/nr-uesoftmodem.c @@ -354,6 +354,7 @@ void init_openair0(void) { openair0_cfg[card].num_rb_dl = frame_parms->N_RB_DL; openair0_cfg[card].clock_source = get_softmodem_params()->clock_source; openair0_cfg[card].time_source = get_softmodem_params()->timing_source; + openair0_cfg[card].tune_offset = get_softmodem_params()->tune_offset; openair0_cfg[card].tx_num_channels = min(4, frame_parms->nb_antennas_tx); openair0_cfg[card].rx_num_channels = min(4, frame_parms->nb_antennas_rx); diff --git a/executables/softmodem-common.h b/executables/softmodem-common.h index eb0c1a54f74025e5c3cb31d159790883c4e59ea7..72a9491f27f5817337f81961dc01ee368db96488 100644 --- a/executables/softmodem-common.h +++ b/executables/softmodem-common.h @@ -60,6 +60,7 @@ extern "C" #define CONFIG_HLP_DMRSSYNC "tells RU to insert DMRS in subframe 1 slot 0" #define CONFIG_HLP_CLK "tells hardware to use a clock reference (0:internal, 1:external, 2:gpsdo)\n" #define CONFIG_HLP_TME "tells hardware to use a time reference (0:internal, 1:external, 2:gpsdo)\n" +#define CONFIG_HLP_TUNE_OFFSET "LO tuning offset to use in Hz\n" #define CONFIG_HLP_USIM "use XOR autentication algo in case of test usim mode\n" #define CONFIG_HLP_NOSNGLT "Disables single-thread mode in lte-softmodem\n" #define CONFIG_HLP_DLF "Set the downlink frequency for all component carriers\n" @@ -118,6 +119,7 @@ extern "C" #define EMULATE_RF softmodem_params.emulate_rf #define CLOCK_SOURCE softmodem_params.clock_source #define TIMING_SOURCE softmodem_params.timing_source +#define TUNE_OFFSET softmodem_params.tune_offset #define SEND_DMRSSYNC softmodem_params.send_dmrs_sync #define USIM_TEST softmodem_params.usim_test #define PRB_INTERPOLATION softmodem_params.prb_interpolation @@ -141,6 +143,7 @@ extern int usrp_tx_thread; {"usim-test", CONFIG_HLP_USIM, PARAMFLAG_BOOL, u8ptr:&USIM_TEST, defintval:0, TYPE_UINT8, 0}, \ {"clock-source", CONFIG_HLP_CLK, 0, uptr:&CLOCK_SOURCE, defintval:0, TYPE_UINT, 0}, \ {"time-source", CONFIG_HLP_TME, 0, uptr:&TIMING_SOURCE, defintval:0, TYPE_UINT, 0}, \ + {"tune-offset", CONFIG_HLP_TUNE_OFFSET, 0, dblptr:&TUNE_OFFSET, defintval:0, TYPE_DOUBLE, 0}, \ {"wait-for-sync", NULL, PARAMFLAG_BOOL, iptr:&WAIT_FOR_SYNC, defintval:0, TYPE_INT, 0}, \ {"single-thread-enable", CONFIG_HLP_NOSNGLT, PARAMFLAG_BOOL, iptr:&SINGLE_THREAD_FLAG, defintval:0, TYPE_INT, 0}, \ {"C" , CONFIG_HLP_DLF, 0, u64ptr:&(downlink_frequency[0][0]), defuintval:0, TYPE_UINT64, 0}, \ @@ -245,6 +248,7 @@ typedef struct { int band; uint32_t clock_source; uint32_t timing_source; + double tune_offset; int hw_timing_advance; uint32_t send_dmrs_sync; int prb_interpolation; diff --git a/targets/ARCH/COMMON/common_lib.h b/targets/ARCH/COMMON/common_lib.h index 95e5e3ed030ed00934224ee55a2ece4f7e60296e..78acc373ee5ac3df3ad2d9822a6a7a400a5bb9d1 100644 --- a/targets/ARCH/COMMON/common_lib.h +++ b/targets/ARCH/COMMON/common_lib.h @@ -188,6 +188,7 @@ typedef struct { //! \brief Center frequency in Hz for TX. //! index: [0..rx_num_channels[ !!! see lte-ue.c:427 FIXME iterates over rx_num_channels double tx_freq[4]; + double tune_offset; //! \brief memory //! \brief Pointer to Calibration table for RX gains rx_gain_calib_table_t *rx_gain_calib_table; diff --git a/targets/ARCH/USRP/USERSPACE/LIB/usrp_lib.cpp b/targets/ARCH/USRP/USERSPACE/LIB/usrp_lib.cpp index 731129b1d9bf3891962fe7d1eca516928f62fc0a..0896780bfd1fd95aed1a99caeb3a4d36564e7d90 100644 --- a/targets/ARCH/USRP/USERSPACE/LIB/usrp_lib.cpp +++ b/targets/ARCH/USRP/USERSPACE/LIB/usrp_lib.cpp @@ -746,8 +746,12 @@ static bool is_equal(double a, double b) { void *freq_thread(void *arg) { openair0_device *device=(openair0_device *)arg; usrp_state_t *s = (usrp_state_t *)device->priv; - s->usrp->set_tx_freq(device->openair0_cfg[0].tx_freq[0]); - s->usrp->set_rx_freq(device->openair0_cfg[0].rx_freq[0]); + uhd::tune_request_t tx_tune_req(device->openair0_cfg[0].tx_freq[0], + device->openair0_cfg[0].tune_offset); + uhd::tune_request_t rx_tune_req(device->openair0_cfg[0].rx_freq[0], + device->openair0_cfg[0].tune_offset); + s->usrp->set_tx_freq(tx_tune_req); + s->usrp->set_rx_freq(rx_tune_req); return NULL; } /*! \brief Set frequencies (TX/RX). Spawns a thread to handle the frequency change to not block the calling thread @@ -759,14 +763,18 @@ void *freq_thread(void *arg) { int trx_usrp_set_freq(openair0_device *device, openair0_config_t *openair0_cfg, int dont_block) { usrp_state_t *s = (usrp_state_t *)device->priv; pthread_t f_thread; - printf("Setting USRP TX Freq %f, RX Freq %f\n",openair0_cfg[0].tx_freq[0],openair0_cfg[0].rx_freq[0]); + printf("Setting USRP TX Freq %f, RX Freq %f, tune_offset: %f, dont_block: %d\n", + openair0_cfg[0].tx_freq[0],openair0_cfg[0].rx_freq[0], + openair0_cfg[0].tune_offset, dont_block); // spawn a thread to handle the frequency change to not block the calling thread if (dont_block == 1) pthread_create(&f_thread,NULL,freq_thread,(void *)device); else { - s->usrp->set_tx_freq(device->openair0_cfg[0].tx_freq[0]); - s->usrp->set_rx_freq(device->openair0_cfg[0].rx_freq[0]); + uhd::tune_request_t tx_tune_req(openair0_cfg[0].tx_freq[0], openair0_cfg[0].tune_offset); + uhd::tune_request_t rx_tune_req(openair0_cfg[0].rx_freq[0], openair0_cfg[0].tune_offset); + s->usrp->set_tx_freq(tx_tune_req); + s->usrp->set_rx_freq(rx_tune_req); } return(0); @@ -779,9 +787,11 @@ int trx_usrp_set_freq(openair0_device *device, openair0_config_t *openair0_cfg, */ int openair0_set_rx_frequencies(openair0_device *device, openair0_config_t *openair0_cfg) { usrp_state_t *s = (usrp_state_t *)device->priv; - uhd::tune_request_t rx_tune_req(openair0_cfg[0].rx_freq[0]); - rx_tune_req.rf_freq_policy = uhd::tune_request_t::POLICY_MANUAL; - rx_tune_req.rf_freq = openair0_cfg[0].rx_freq[0]; + uhd::tune_request_t rx_tune_req(openair0_cfg[0].rx_freq[0], openair0_cfg[0].tune_offset); + printf("In openair0_set_rx_frequencies, freq: %f, tune offset: %f\n", + openair0_cfg[0].rx_freq[0], openair0_cfg[0].tune_offset); + //rx_tune_req.rf_freq_policy = uhd::tune_request_t::POLICY_MANUAL; + //rx_tune_req.rf_freq = openair0_cfg[0].rx_freq[0]; s->usrp->set_rx_freq(rx_tune_req); return(0); } @@ -1276,7 +1286,9 @@ extern "C" { for(int i=0; i<((int) s->usrp->get_rx_num_channels()); i++) { if (i<openair0_cfg[0].rx_num_channels) { s->usrp->set_rx_rate(openair0_cfg[0].sample_rate,i+choffset); - s->usrp->set_rx_freq(openair0_cfg[0].rx_freq[i],i+choffset); + uhd::tune_request_t rx_tune_req(openair0_cfg[0].rx_freq[i], + openair0_cfg[0].tune_offset); + s->usrp->set_rx_freq(rx_tune_req, i+choffset); set_rx_gain_offset(&openair0_cfg[0],i,bw_gain_adjust); ::uhd::gain_range_t gain_range = s->usrp->get_rx_gain_range(i+choffset); // limit to maximum gain @@ -1302,7 +1314,9 @@ extern "C" { if (i<openair0_cfg[0].tx_num_channels) { s->usrp->set_tx_rate(openair0_cfg[0].sample_rate,i+choffset); - s->usrp->set_tx_freq(openair0_cfg[0].tx_freq[i],i+choffset); + uhd::tune_request_t tx_tune_req(openair0_cfg[0].tx_freq[i], + openair0_cfg[0].tune_offset); + s->usrp->set_tx_freq(tx_tune_req, i+choffset); s->usrp->set_tx_gain(gain_range_tx.stop()-openair0_cfg[0].tx_gain[i],i+choffset); LOG_I(HW,"USRP TX_GAIN:%3.2lf gain_range:%3.2lf tx_gain:%3.2lf\n", gain_range_tx.stop()-openair0_cfg[0].tx_gain[i], gain_range_tx.stop(), openair0_cfg[0].tx_gain[i]); } diff --git a/targets/RT/USER/lte-ru.c b/targets/RT/USER/lte-ru.c index 571551cee9a61bf1fd8cf88f4977e937c6a61d00..4bef1e30cfa11f30ff4cab0af8e821878fd63454 100644 --- a/targets/RT/USER/lte-ru.c +++ b/targets/RT/USER/lte-ru.c @@ -1371,11 +1371,12 @@ void fill_rf_config(RU_t *ru, cfg->tx_gain[i] = (double)ru->att_tx; cfg->rx_gain[i] = ru->max_rxgain-(double)ru->att_rx; cfg->configFilename = rf_config_file; - LOG_I(PHY,"channel %d, Setting tx_gain offset %f, rx_gain offset %f, tx_freq %f, rx_freq %f\n", + LOG_I(PHY,"channel %d, Setting tx_gain offset %f, rx_gain offset %f, tx_freq %f, rx_freq %f, tune_offset %.0f Hz\n", i, cfg->tx_gain[i], cfg->rx_gain[i], cfg->tx_freq[i], - cfg->rx_freq[i]); + cfg->rx_freq[i], + cfg->tune_offset); } } @@ -2972,6 +2973,8 @@ RU_t **RCconfig_RU(int nb_RU,int nb_L1_inst,PHY_VARS_eNB ***eNB,uint64_t *ru_mas ru[j]->openair0_cfg.time_source = unset; } + ru[j]->openair0_cfg.tune_offset = get_softmodem_params()->tune_offset; + LOG_I(PHY,"RU %d is_slave=%s\n",j,*(RUParamList.paramarray[j][RU_IS_SLAVE_IDX].strptr)); if (strcmp(*(RUParamList.paramarray[j][RU_IS_SLAVE_IDX].strptr), "yes") == 0) ru[j]->is_slave=1; diff --git a/targets/RT/USER/lte-uesoftmodem.c b/targets/RT/USER/lte-uesoftmodem.c index 089941c7dfc0de799960b9206bf2f771e5564e11..946ee76cc8483762eab9c9867c51441d3eeb0997 100644 --- a/targets/RT/USER/lte-uesoftmodem.c +++ b/targets/RT/USER/lte-uesoftmodem.c @@ -446,6 +446,7 @@ void init_openair0(LTE_DL_FRAME_PARMS *frame_parms,int rxgain) { openair0_cfg[card].num_rb_dl=frame_parms->N_RB_DL; openair0_cfg[card].clock_source = get_softmodem_params()->clock_source; openair0_cfg[card].time_source = get_softmodem_params()->timing_source; + openair0_cfg[card].tune_offset = get_softmodem_params()->tune_offset; openair0_cfg[card].tx_num_channels=min(2,frame_parms->nb_antennas_tx); openair0_cfg[card].rx_num_channels=min(2,frame_parms->nb_antennas_rx); @@ -464,11 +465,12 @@ void init_openair0(LTE_DL_FRAME_PARMS *frame_parms,int rxgain) { openair0_cfg[card].tx_gain[i] = tx_gain[0][i]; openair0_cfg[card].rx_gain[i] = rxgain - rx_gain_off; openair0_cfg[card].configFilename = get_softmodem_params()->rf_config_file; - printf("Card %d, channel %d, Setting tx_gain %f, rx_gain %f, tx_freq %f, rx_freq %f\n", + printf("Card %d, channel %d, Setting tx_gain %f, rx_gain %f, tx_freq %f, rx_freq %f, tune_offset %.0f\n", card,i, openair0_cfg[card].tx_gain[i], openair0_cfg[card].rx_gain[i], openair0_cfg[card].tx_freq[i], - openair0_cfg[card].rx_freq[i]); + openair0_cfg[card].rx_freq[i], + openair0_cfg[card].tune_offset); } if (usrp_args) openair0_cfg[card].sdr_addrs = usrp_args;