From 7b854476a233a7f047c736e3ebae69bbaed65068 Mon Sep 17 00:00:00 2001 From: Ismael Gomez Date: Tue, 12 Sep 2017 11:10:13 +0200 Subject: [PATCH] fixed radio set/get freq precision --- lib/include/srslte/radio/radio.h | 22 +++++++++++----------- lib/src/radio/radio.cc | 16 ++++++++-------- srsue/src/phy/phch_recv.cc | 10 ++++------ 3 files changed, 23 insertions(+), 25 deletions(-) diff --git a/lib/include/srslte/radio/radio.h b/lib/include/srslte/radio/radio.h index f04fee98d..30d274f44 100644 --- a/lib/include/srslte/radio/radio.h +++ b/lib/include/srslte/radio/radio.h @@ -98,16 +98,16 @@ namespace srslte { void set_tx_rx_gain_offset(float offset); double set_rx_gain_th(float gain); - void set_freq_offset(float freq); - void set_tx_freq(float freq); - void set_rx_freq(float freq); + void set_freq_offset(double freq); + void set_tx_freq(double freq); + void set_rx_freq(double freq); - float get_tx_freq(); - float get_rx_freq(); + double get_tx_freq(); + double get_rx_freq(); - void set_master_clock_rate(float rate); - void set_tx_srate(float srate); - void set_rx_srate(float srate); + void set_master_clock_rate(double rate); + void set_tx_srate(double srate); + void set_rx_srate(double srate); float get_tx_gain(); float get_rx_gain(); @@ -157,9 +157,9 @@ namespace srslte { const static double blade_default_burst_preamble_sec = 0.0; const static double blade_default_tx_adv_samples = 27; - const static double blade_default_tx_adv_offset_sec = 1e-6; - - float tx_freq, rx_freq, freq_offset; + const static double blade_default_tx_adv_offset_sec = 1e-6; + + double tx_freq, rx_freq, freq_offset; trace tr_local_time; trace tr_usrp_time; diff --git a/lib/src/radio/radio.cc b/lib/src/radio/radio.cc index b43e837cd..c3592f168 100644 --- a/lib/src/radio/radio.cc +++ b/lib/src/radio/radio.cc @@ -250,11 +250,11 @@ void radio::save_trace(uint32_t is_eob, srslte_timestamp_t *tx_time) { } } -void radio::set_freq_offset(float freq) { +void radio::set_freq_offset(double freq) { freq_offset = freq; } -void radio::set_rx_freq(float freq) +void radio::set_rx_freq(double freq) { rx_freq = srslte_rf_set_rx_freq(&rf_device, freq+freq_offset); } @@ -269,17 +269,17 @@ double radio::set_rx_gain_th(float gain) return srslte_rf_set_rx_gain_th(&rf_device, gain); } -void radio::set_master_clock_rate(float rate) +void radio::set_master_clock_rate(double rate) { srslte_rf_set_master_clock_rate(&rf_device, rate); } -void radio::set_rx_srate(float srate) +void radio::set_rx_srate(double srate) { srslte_rf_set_rx_srate(&rf_device, srate); } -void radio::set_tx_freq(float freq) +void radio::set_tx_freq(double freq) { tx_freq = srslte_rf_set_tx_freq(&rf_device, freq+freq_offset); } @@ -289,12 +289,12 @@ void radio::set_tx_gain(float gain) srslte_rf_set_tx_gain(&rf_device, gain); } -float radio::get_rx_freq() +double radio::get_rx_freq() { return rx_freq; } -float radio::get_tx_freq() +double radio::get_tx_freq() { return tx_freq; } @@ -309,7 +309,7 @@ float radio::get_rx_gain() return srslte_rf_get_rx_gain(&rf_device); } -void radio::set_tx_srate(float srate) +void radio::set_tx_srate(double srate) { cur_tx_srate = srslte_rf_set_tx_srate(&rf_device, srate); burst_preamble_samples = (uint32_t) (cur_tx_srate * burst_preamble_sec); diff --git a/srsue/src/phy/phch_recv.cc b/srsue/src/phy/phch_recv.cc index 61eda8562..5b725d49f 100644 --- a/srsue/src/phy/phch_recv.cc +++ b/srsue/src/phy/phch_recv.cc @@ -169,9 +169,7 @@ void phch_recv::set_ue_sync_opts(srslte_ue_sync_t *q) { srslte_ue_sync_cfo_i_detec_en(q, true); } - float cfo_tol = worker_com->args->cfo_correct_tol_hz; - srslte_cfo_set_tol(&q->strack.cfocorr, cfo_tol / (15000 * q->fft_size)); - srslte_cfo_set_tol(&q->sfind.cfocorr, cfo_tol / (15000 * q->fft_size)); + srslte_ue_sync_set_cfo_tol(q, worker_com->args->cfo_correct_tol_hz); int time_correct_period = worker_com->args->time_correct_period; if (time_correct_period > 0) { @@ -499,8 +497,8 @@ bool phch_recv::cell_select(uint32_t earfcn, srslte_cell_t cell) { bool phch_recv::set_frequency() { - float dl_freq = 1e6*srslte_band_fd(current_earfcn); - float ul_freq = 1e6*srslte_band_fu(srslte_band_ul_earfcn(current_earfcn)); + double dl_freq = 1e6*srslte_band_fd(current_earfcn); + double ul_freq = 1e6*srslte_band_fu(srslte_band_ul_earfcn(current_earfcn)); if (dl_freq > 0 && ul_freq > 0) { log_h->info("SYNC: Set DL EARFCN=%d, f_dl=%.1f MHz, f_ul=%.1f MHz\n", current_earfcn, dl_freq / 1e6, ul_freq / 1e6); @@ -510,7 +508,7 @@ bool phch_recv::set_frequency() radio_h->set_rx_freq(dl_freq); radio_h->set_tx_freq(ul_freq); - ul_dl_factor = ul_freq / dl_freq; + ul_dl_factor = radio_h->get_tx_freq()/radio_h->get_rx_freq(); srslte_ue_sync_reset(&ue_sync);