diff options
author | Josh Blum <josh@joshknows.com> | 2012-01-16 18:07:09 -0800 |
---|---|---|
committer | Josh Blum <josh@joshknows.com> | 2012-03-14 00:02:44 -0700 |
commit | 8a33423ad6877fdb2bc1bc50c6506cff4ce9c5aa (patch) | |
tree | c0aef50afc507333f80fe31e000fa6f3f980a4d3 /host/lib/usrp | |
parent | abab58f5404fcd769bf72fd0f486323659e9c087 (diff) | |
download | uhd-8a33423ad6877fdb2bc1bc50c6506cff4ce9c5aa.tar.gz uhd-8a33423ad6877fdb2bc1bc50c6506cff4ce9c5aa.tar.bz2 uhd-8a33423ad6877fdb2bc1bc50c6506cff4ce9c5aa.zip |
uhd: rev iq correction numbers format
Diffstat (limited to 'host/lib/usrp')
-rw-r--r-- | host/lib/usrp/common/apply_corrections.cpp | 49 | ||||
-rw-r--r-- | host/lib/usrp/cores/rx_frontend_core_200.cpp | 4 | ||||
-rw-r--r-- | host/lib/usrp/cores/tx_frontend_core_200.cpp | 4 |
3 files changed, 10 insertions, 47 deletions
diff --git a/host/lib/usrp/common/apply_corrections.cpp b/host/lib/usrp/common/apply_corrections.cpp index 6aee00753..b889266f2 100644 --- a/host/lib/usrp/common/apply_corrections.cpp +++ b/host/lib/usrp/common/apply_corrections.cpp @@ -54,7 +54,7 @@ static bool fe_cal_comp(fe_cal_t a, fe_cal_t b){ static uhd::dict<std::string, std::vector<fe_cal_t> > fe_cal_cache; -static std::complex<double> get_fe_dc_correction( +static std::complex<double> get_fe_correction( const std::string &key, const double lo_freq ){ const std::vector<fe_cal_t> &datas = fe_cal_cache[key]; @@ -81,36 +81,6 @@ static std::complex<double> get_fe_dc_correction( ); } -static std::complex<double> get_fe_iq_correction( - const std::string &key, const double lo_freq -){ - const std::vector<fe_cal_t> &datas = fe_cal_cache[key]; - if (datas.empty()) throw uhd::runtime_error("empty calibration table " + key); - - //search for lo freq - size_t lo_index = 0; - size_t hi_index = datas.size()-1; - for (size_t i = 0; i < datas.size(); i++){ - if (datas[i].lo_freq > lo_freq){ - hi_index = i; - break; - } - lo_index = i; - } - - if (lo_index == 0) return std::complex<double>(datas[lo_index].iq_corr_real, datas[lo_index].iq_corr_imag); - if (hi_index == lo_index) return std::complex<double>(datas[hi_index].iq_corr_real, datas[hi_index].iq_corr_imag); - - const std::complex<double> lo_val(datas[lo_index].iq_corr_real, datas[lo_index].iq_corr_imag); - const std::complex<double> hi_val(datas[hi_index].iq_corr_real, datas[hi_index].iq_corr_imag); - - //interpolation time - return std::polar<double>( - linear_interp(lo_freq, datas[lo_index].lo_freq, std::abs(lo_val), datas[hi_index].lo_freq, std::abs(hi_val)), - linear_interp(lo_freq, datas[lo_index].lo_freq, std::arg(lo_val), datas[hi_index].lo_freq, std::arg(hi_val)) - ); -} - static void apply_fe_corrections( uhd::property_tree::sptr sub_tree, const uhd::fs_path &db_path, @@ -155,15 +125,8 @@ static void apply_fe_corrections( } - if (file_prefix.find("dc_cal") != std::string::npos){ - sub_tree->access<std::complex<double> >(fe_path) - .set(get_fe_dc_correction(cal_data_path.string(), lo_freq)); - } - else if (file_prefix.find("iq_cal") != std::string::npos){ - sub_tree->access<std::complex<double> >(fe_path) - .set(get_fe_iq_correction(cal_data_path.string(), lo_freq)); - } - else throw uhd::runtime_error("could not determine interpolation function"); + sub_tree->access<std::complex<double> >(fe_path) + .set(get_fe_correction(cal_data_path.string(), lo_freq)); } /*********************************************************************** @@ -180,14 +143,14 @@ void uhd::usrp::apply_tx_fe_corrections( sub_tree, "dboards/" + slot + "/tx_eeprom", "tx_frontends/" + slot + "/iq_balance/value", - "tx_iq_cal_v0.1_", + "tx_iq_cal_v0.2_", lo_freq ); apply_fe_corrections( sub_tree, "dboards/" + slot + "/tx_eeprom", "tx_frontends/" + slot + "/dc_offset/value", - "tx_dc_cal_v0.1_", + "tx_dc_cal_v0.2_", lo_freq ); } @@ -207,7 +170,7 @@ void uhd::usrp::apply_rx_fe_corrections( sub_tree, "dboards/" + slot + "/rx_eeprom", "rx_frontends/" + slot + "/iq_balance/value", - "rx_iq_cal_v0.1_", + "rx_iq_cal_v0.2_", lo_freq ); } diff --git a/host/lib/usrp/cores/rx_frontend_core_200.cpp b/host/lib/usrp/cores/rx_frontend_core_200.cpp index d6396ef45..eb9f39fcf 100644 --- a/host/lib/usrp/cores/rx_frontend_core_200.cpp +++ b/host/lib/usrp/cores/rx_frontend_core_200.cpp @@ -64,8 +64,8 @@ public: } void set_iq_balance(const std::complex<double> &cor){ - _iface->poke32(REG_RX_FE_MAG_CORRECTION, fs_to_bits(std::abs(cor) - 1, 18)); - _iface->poke32(REG_RX_FE_PHASE_CORRECTION, fs_to_bits(std::arg(cor)/6.28318531, 18)); + _iface->poke32(REG_RX_FE_MAG_CORRECTION, fs_to_bits(cor.real(), 18)); + _iface->poke32(REG_RX_FE_PHASE_CORRECTION, fs_to_bits(cor.imag(), 18)); } private: diff --git a/host/lib/usrp/cores/tx_frontend_core_200.cpp b/host/lib/usrp/cores/tx_frontend_core_200.cpp index b90281d9f..e35874173 100644 --- a/host/lib/usrp/cores/tx_frontend_core_200.cpp +++ b/host/lib/usrp/cores/tx_frontend_core_200.cpp @@ -62,8 +62,8 @@ public: } void set_iq_balance(const std::complex<double> &cor){ - _iface->poke32(REG_TX_FE_MAG_CORRECTION, fs_to_bits(std::abs(cor) - 1, 18)); - _iface->poke32(REG_TX_FE_PHASE_CORRECTION, fs_to_bits(std::arg(cor)/6.28318531, 18)); + _iface->poke32(REG_TX_FE_MAG_CORRECTION, fs_to_bits(cor.real(), 18)); + _iface->poke32(REG_TX_FE_PHASE_CORRECTION, fs_to_bits(cor.imag(), 18)); } private: |