diff options
author | Josh Blum <josh@joshknows.com> | 2011-11-16 06:39:31 +0000 |
---|---|---|
committer | Josh Blum <josh@joshknows.com> | 2011-11-16 06:39:31 +0000 |
commit | 95568c8b30490f630a72b665b135c46549ee5882 (patch) | |
tree | 35d00a6ad0c7cc4fe1a8c2ea4e89b8e47e9e694a /host/utils/usrp_cal_utils.hpp | |
parent | 075e6a9788856d6951df42349afef7816852ca68 (diff) | |
download | uhd-95568c8b30490f630a72b665b135c46549ee5882.tar.gz uhd-95568c8b30490f630a72b665b135c46549ee5882.tar.bz2 uhd-95568c8b30490f630a72b665b135c46549ee5882.zip |
e100: added self-cal support with minor speedups
Diffstat (limited to 'host/utils/usrp_cal_utils.hpp')
-rw-r--r-- | host/utils/usrp_cal_utils.hpp | 36 |
1 files changed, 22 insertions, 14 deletions
diff --git a/host/utils/usrp_cal_utils.hpp b/host/utils/usrp_cal_utils.hpp index 6417b5d8b..0faaf9a84 100644 --- a/host/utils/usrp_cal_utils.hpp +++ b/host/utils/usrp_cal_utils.hpp @@ -58,6 +58,10 @@ static inline void set_optimum_defaults(uhd::usrp::multi_usrp::sptr usrp){ usrp->set_tx_rate(4e6); usrp->set_rx_rate(4e6); } + else if (mb_name.find("E10") != std::string::npos){ + usrp->set_tx_rate(4e6); + usrp->set_rx_rate(8e6); + } else{ throw std::runtime_error("self-calibration is not supported for this hardware"); } @@ -85,18 +89,22 @@ static inline void set_optimum_defaults(uhd::usrp::multi_usrp::sptr usrp){ /*********************************************************************** * Sinusoid wave table **********************************************************************/ -static inline std::vector<std::complex<float> > gen_table(void){ - std::vector<std::complex<float> > wave_table(wave_table_len); - for (size_t i = 0; i < wave_table_len; i++){ - wave_table[i] = std::complex<float>(std::polar(1.0, (tau*i)/wave_table_len)); +class wave_table{ +public: + wave_table(const double ampl){ + _table.resize(wave_table_len); + for (size_t i = 0; i < wave_table_len; i++){ + _table[i] = std::complex<float>(std::polar(ampl, (tau*i)/wave_table_len)); + } } - return wave_table; -} -static inline std::complex<float> wave_table_lookup(const size_t index){ - static const std::vector<std::complex<float> > wave_table = gen_table(); - return wave_table[index % wave_table_len]; -} + inline std::complex<float> operator()(const size_t index) const{ + return _table[index % wave_table_len]; + } + +private: + std::vector<std::complex<float> > _table; +}; /*********************************************************************** * Compute power of a tone @@ -106,16 +114,16 @@ static inline double compute_tone_dbrms( const double freq //freq is fractional ){ //shift the samples so the tone at freq is down at DC - std::vector<std::complex<double> > shifted(samples.size() - skip_initial_samps); + std::vector<std::complex<float> > shifted(samples.size() - skip_initial_samps); for (size_t i = 0; i < shifted.size(); i++){ - shifted[i] = std::complex<double>(samples[i+skip_initial_samps]) * std::polar<double>(1.0, -freq*tau*i); + shifted[i] = samples[i+skip_initial_samps] * std::complex<float>(std::polar(1.0, -freq*tau*i)); } //filter the samples with a narrow low pass - std::complex<double> iir_output = 0, iir_last = 0; + std::complex<float> iir_output = 0, iir_last = 0; double output = 0; for (size_t i = 0; i < shifted.size(); i++){ - iir_output = alpha * shifted[i] + (1-alpha)*iir_last; + iir_output = float(alpha) * shifted[i] + float(1-alpha)*iir_last; iir_last = iir_output; output += std::abs(iir_output); } |