diff options
Diffstat (limited to 'host/lib/usrp/dboard/db_dbsrx.cpp')
-rw-r--r-- | host/lib/usrp/dboard/db_dbsrx.cpp | 57 |
1 files changed, 24 insertions, 33 deletions
diff --git a/host/lib/usrp/dboard/db_dbsrx.cpp b/host/lib/usrp/dboard/db_dbsrx.cpp index 8fdd4f953..cfe06db29 100644 --- a/host/lib/usrp/dboard/db_dbsrx.cpp +++ b/host/lib/usrp/dboard/db_dbsrx.cpp @@ -20,10 +20,11 @@ // RX IO Functions #include "max2118_regs.hpp" +#include <uhd/utils/log.hpp> #include <uhd/utils/static.hpp> #include <uhd/utils/assert_has.hpp> #include <uhd/utils/algorithm.hpp> -#include <uhd/utils/warning.hpp> +#include <uhd/utils/msg.hpp> #include <uhd/types/ranges.hpp> #include <uhd/types/sensors.hpp> #include <uhd/types/dict.hpp> @@ -44,8 +45,6 @@ using namespace boost::assign; /*********************************************************************** * The DBSRX constants **********************************************************************/ -static const bool dbsrx_debug = false; - static const freq_range_t dbsrx_freq_range(0.8e9, 2.4e9); static const freq_range_t dbsrx_pfd_freq_range(0.15e6, 2.01e6); @@ -98,7 +97,7 @@ private: //get the register data for(int i=0; i<num_bytes; i++){ regs_vector[1+i] = _max2118_write_regs.get_reg(start_addr+i); - if(dbsrx_debug) std::cerr << boost::format( + UHD_LOGV(often) << boost::format( "DBSRX: send reg 0x%02x, value 0x%04x, start_addr = 0x%04x, num_bytes %d" ) % int(start_addr+i) % int(regs_vector[1+i]) % int(start_addr) % num_bytes << std::endl; } @@ -130,7 +129,7 @@ private: if (i + start_addr >= status_addr){ _max2118_read_regs.set_reg(i + start_addr, regs_vector[i]); } - if(dbsrx_debug) std::cerr << boost::format( + UHD_LOGV(often) << boost::format( "DBSRX: read reg 0x%02x, value 0x%04x, start_addr = 0x%04x, num_bytes %d" ) % int(start_addr+i) % int(regs_vector[i]) % int(start_addr) % num_bytes << std::endl; } @@ -147,7 +146,7 @@ private: //mask and return lock detect bool locked = 5 >= _max2118_read_regs.adc and _max2118_read_regs.adc >= 2; - if(dbsrx_debug) std::cerr << boost::format( + UHD_LOGV(often) << boost::format( "DBSRX: locked %d" ) % locked << std::endl; @@ -176,25 +175,21 @@ UHD_STATIC_BLOCK(reg_dbsrx_dboard){ dbsrx::dbsrx(ctor_args_t args) : rx_dboard_base(args){ //warn user about incorrect DBID on USRP1, requires R193 populated if (this->get_iface()->get_special_props().soft_clock_divider and this->get_rx_id() == 0x000D) - uhd::warning::post( - str(boost::format( + UHD_MSG(warning) << boost::format( "DBSRX: incorrect dbid\n" "Expected dbid 0x0002 and R193\n" "found dbid == %d\n" "Please see the daughterboard app notes" - ) % this->get_rx_id().to_pp_string()) - ); + ) % this->get_rx_id().to_pp_string(); //warn user about incorrect DBID on non-USRP1, requires R194 populated if (not this->get_iface()->get_special_props().soft_clock_divider and this->get_rx_id() == 0x0002) - uhd::warning::post( - str(boost::format( + UHD_MSG(warning) << boost::format( "DBSRX: incorrect dbid\n" "Expected dbid 0x000D and R194\n" "found dbid == %d\n" "Please see the daughterboard app notes" - ) % this->get_rx_id().to_pp_string()) - ); + ) % this->get_rx_id().to_pp_string(); //enable only the clocks we need this->get_iface()->set_clock_enabled(dboard_iface::UNIT_RX, true); @@ -246,7 +241,7 @@ void dbsrx::set_lo_freq(double target_freq){ m = 31; while ((ref_clock/m < 1e6 or ref_clock/m > 2.5e6) and m > 0){ m--; } - if(dbsrx_debug) std::cerr << boost::format( + UHD_LOGV(often) << boost::format( "DBSRX: trying ref_clock %f and m_divider %d" ) % (ref_clock) % m << std::endl; @@ -256,7 +251,7 @@ void dbsrx::set_lo_freq(double target_freq){ for(r = 0; r <= 6; r += 1) { //compute divider from setting R = 1 << (r+1); - if (dbsrx_debug) std::cerr << boost::format("DBSRX R:%d\n") % R << std::endl; + UHD_LOGV(often) << boost::format("DBSRX R:%d\n") % R << std::endl; //compute PFD compare frequency = ref_clock/R pfd_freq = ref_clock / R; @@ -282,7 +277,7 @@ void dbsrx::set_lo_freq(double target_freq){ UHD_ASSERT_THROW((pfd_freq >= dbsrx_pfd_freq_range.start()) and (pfd_freq <= dbsrx_pfd_freq_range.stop())); UHD_ASSERT_THROW((N >= 256) and (N <= 32768)); - if(dbsrx_debug) std::cerr << boost::format( + UHD_LOGV(often) << boost::format( "DBSRX: choose ref_clock (current: %f, new: %f) and m_divider %d" ) % (this->get_iface()->get_clock_rate(dboard_iface::UNIT_RX)) % ref_clock % m << std::endl; @@ -304,7 +299,7 @@ void dbsrx::set_lo_freq(double target_freq){ int scaler = actual_freq > 1125e6 ? 2 : 4; _max2118_write_regs.div2 = scaler == 4 ? max2118_write_regs_t::DIV2_DIV4 : max2118_write_regs_t::DIV2_DIV2; - if(dbsrx_debug) std::cerr << boost::format( + UHD_LOGV(often) << boost::format( "DBSRX: scaler %d, actual_freq %f MHz, register bit: %d" ) % scaler % (actual_freq/1e6) % int(_max2118_write_regs.div2) << std::endl; @@ -333,7 +328,7 @@ void dbsrx::set_lo_freq(double target_freq){ //check vtune for lock condition read_reg(0x0, 0x0); - if(dbsrx_debug) std::cerr << boost::format( + UHD_LOGV(often) << boost::format( "DBSRX: initial guess for vco %d, vtune adc %d" ) % int(_max2118_write_regs.osc_band) % int(_max2118_read_regs.adc) << std::endl; @@ -343,11 +338,9 @@ void dbsrx::set_lo_freq(double target_freq){ //vtune is too low, try lower frequency vco if (_max2118_read_regs.adc == 0){ if (_max2118_write_regs.osc_band == 0){ - uhd::warning::post( - str(boost::format( + UHD_MSG(warning) << boost::format( "DBSRX: Tuning exceeded vco range, _max2118_write_regs.osc_band == %d\n" - ) % int(_max2118_write_regs.osc_band)) - ); + ) % int(_max2118_write_regs.osc_band); UHD_ASSERT_THROW(_max2118_read_regs.adc != 0); //just to cause a throw } if (_max2118_write_regs.osc_band <= 0) break; @@ -357,18 +350,16 @@ void dbsrx::set_lo_freq(double target_freq){ //vtune is too high, try higher frequency vco if (_max2118_read_regs.adc == 7){ if (_max2118_write_regs.osc_band == 7){ - uhd::warning::post( - str(boost::format( + UHD_MSG(warning) << boost::format( "DBSRX: Tuning exceeded vco range, _max2118_write_regs.osc_band == %d\n" - ) % int(_max2118_write_regs.osc_band)) - ); + ) % int(_max2118_write_regs.osc_band); UHD_ASSERT_THROW(_max2118_read_regs.adc != 7); //just to cause a throw } if (_max2118_write_regs.osc_band >= 7) break; _max2118_write_regs.osc_band += 1; } - if(dbsrx_debug) std::cerr << boost::format( + UHD_LOGV(often) << boost::format( "DBSRX: trying vco %d, vtune adc %d" ) % int(_max2118_write_regs.osc_band) % int(_max2118_read_regs.adc) << std::endl; @@ -380,7 +371,7 @@ void dbsrx::set_lo_freq(double target_freq){ boost::this_thread::sleep(boost::posix_time::milliseconds(10)); } - if(dbsrx_debug) std::cerr << boost::format( + UHD_LOGV(often) << boost::format( "DBSRX: final vco %d, vtune adc %d" ) % int(_max2118_write_regs.osc_band) % int(_max2118_read_regs.adc) << std::endl; @@ -396,7 +387,7 @@ void dbsrx::set_lo_freq(double target_freq){ _lo_freq = this->get_iface()->get_clock_rate(dboard_iface::UNIT_RX) / std::pow(2.0,(1 + _max2118_write_regs.r_divider)) * _max2118_write_regs.get_n_divider(); //debug output of calculated variables - if (dbsrx_debug) std::cerr + UHD_LOGV(often) << boost::format("DBSRX tune:\n") << boost::format(" VCO=%d, CP=%d, PFD Freq=%fMHz\n") % int(_max2118_write_regs.osc_band) % _max2118_write_regs.cp_current % (pfd_freq/1e6) << boost::format(" R=%d, N=%f, scaler=%d, div2=%d\n") % R % N % scaler % int(_max2118_write_regs.div2) @@ -432,7 +423,7 @@ static int gain_to_gc2_vga_reg(double &gain){ gain = double(boost::math::iround(gain)); } - if (dbsrx_debug) std::cerr << boost::format( + UHD_LOGV(often) << boost::format( "DBSRX GC2 Gain: %f dB, reg: %d" ) % gain % reg << std::endl; @@ -456,7 +447,7 @@ static double gain_to_gc1_rfvga_dac(double &gain){ //calculate the voltage for the aux dac double dac_volts = gain*slope + min_volts; - if (dbsrx_debug) std::cerr << boost::format( + UHD_LOGV(often) << boost::format( "DBSRX GC1 Gain: %f dB, dac_volts: %f V" ) % gain % dac_volts << std::endl; @@ -497,7 +488,7 @@ void dbsrx::set_bandwidth(double bandwidth){ //determine actual bandwidth _bandwidth = double((ref_clock/(_max2118_write_regs.m_divider))*(4+0.145*_max2118_write_regs.f_dac)); - if (dbsrx_debug) std::cerr << boost::format( + UHD_LOGV(often) << boost::format( "DBSRX Filter Bandwidth: %f MHz, m: %d, f_dac: %d\n" ) % (_bandwidth/1e6) % int(_max2118_write_regs.m_divider) % int(_max2118_write_regs.f_dac) << std::endl; |