From 8a33423ad6877fdb2bc1bc50c6506cff4ce9c5aa Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Mon, 16 Jan 2012 18:07:09 -0800 Subject: uhd: rev iq correction numbers format --- host/lib/usrp/common/apply_corrections.cpp | 49 ++++------------------------ host/lib/usrp/cores/rx_frontend_core_200.cpp | 4 +-- host/lib/usrp/cores/tx_frontend_core_200.cpp | 4 +-- 3 files changed, 10 insertions(+), 47 deletions(-) (limited to 'host/lib') 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 > fe_cal_cache; -static std::complex get_fe_dc_correction( +static std::complex get_fe_correction( const std::string &key, const double lo_freq ){ const std::vector &datas = fe_cal_cache[key]; @@ -81,36 +81,6 @@ static std::complex get_fe_dc_correction( ); } -static std::complex get_fe_iq_correction( - const std::string &key, const double lo_freq -){ - const std::vector &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(datas[lo_index].iq_corr_real, datas[lo_index].iq_corr_imag); - if (hi_index == lo_index) return std::complex(datas[hi_index].iq_corr_real, datas[hi_index].iq_corr_imag); - - const std::complex lo_val(datas[lo_index].iq_corr_real, datas[lo_index].iq_corr_imag); - const std::complex hi_val(datas[hi_index].iq_corr_real, datas[hi_index].iq_corr_imag); - - //interpolation time - return std::polar( - 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 >(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 >(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 >(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 &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 &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: -- cgit v1.2.3