diff options
author | Josh Blum <josh@joshknows.com> | 2011-01-31 16:29:12 -0800 |
---|---|---|
committer | Josh Blum <josh@joshknows.com> | 2011-01-31 16:29:12 -0800 |
commit | 625d5605dd157f9cf6f1d96e60a4d8d051817aef (patch) | |
tree | 4943b1d3fb498c8f36f574edeb1fb8ce7c66e323 /host/lib/usrp | |
parent | e16445483e1505942b7b1ddcd9fc575532fd93ba (diff) | |
download | uhd-625d5605dd157f9cf6f1d96e60a4d8d051817aef.tar.gz uhd-625d5605dd157f9cf6f1d96e60a4d8d051817aef.tar.bz2 uhd-625d5605dd157f9cf6f1d96e60a4d8d051817aef.zip |
usrp: added set and get master clock rates to usrp API
implemented set and get rates in usrp1 (its all soft)
implemented set and get rates in usrp2 (only 100MHz)
Diffstat (limited to 'host/lib/usrp')
-rw-r--r-- | host/lib/usrp/multi_usrp.cpp | 14 | ||||
-rw-r--r-- | host/lib/usrp/usrp1/clock_ctrl.cpp | 21 | ||||
-rw-r--r-- | host/lib/usrp/usrp1/clock_ctrl.hpp | 7 | ||||
-rw-r--r-- | host/lib/usrp/usrp1/mboard_impl.cpp | 8 | ||||
-rw-r--r-- | host/lib/usrp/usrp2/mboard_impl.cpp | 8 |
5 files changed, 48 insertions, 10 deletions
diff --git a/host/lib/usrp/multi_usrp.cpp b/host/lib/usrp/multi_usrp.cpp index 17458496b..817d7b085 100644 --- a/host/lib/usrp/multi_usrp.cpp +++ b/host/lib/usrp/multi_usrp.cpp @@ -53,6 +53,20 @@ public: /******************************************************************* * Mboard methods ******************************************************************/ + void set_master_clock_rate(double rate, size_t mboard){ + if (mboard != ALL_MBOARDS){ + _mboard(mboard)[MBOARD_PROP_CLOCK_RATE] = rate; + return; + } + for (size_t m = 0; m < get_num_mboards(); m++){ + set_master_clock_rate(rate, m); + } + } + + double get_master_clock_rate(size_t mboard){ + return _mboard(mboard)[MBOARD_PROP_CLOCK_RATE].as<double>(); + } + std::string get_pp_string(void){ std::string buff = str(boost::format( "%s USRP:\n" diff --git a/host/lib/usrp/usrp1/clock_ctrl.cpp b/host/lib/usrp/usrp1/clock_ctrl.cpp index 68c5f5320..156f2b0c4 100644 --- a/host/lib/usrp/usrp1/clock_ctrl.cpp +++ b/host/lib/usrp/usrp1/clock_ctrl.cpp @@ -29,32 +29,33 @@ using namespace uhd; /*********************************************************************** * Constants **********************************************************************/ -static const double master_clock_rate = 64e6; +static const double default_master_clock_rate = 64e6; /*********************************************************************** * Clock Control Implementation **********************************************************************/ class usrp1_clock_ctrl_impl : public usrp1_clock_ctrl { public: - usrp1_clock_ctrl_impl(usrp1_iface::sptr iface) - { - _iface = iface; + usrp1_clock_ctrl_impl(usrp1_iface::sptr iface): _iface(iface){ + this->set_master_clock_freq(default_master_clock_rate); } - double get_master_clock_freq(void) - { - return master_clock_rate; + void set_master_clock_freq(double freq){ + _freq = freq; + } + + double get_master_clock_freq(void){ + return _freq; } private: usrp1_iface::sptr _iface; - + double _freq; }; /*********************************************************************** * Clock Control Make **********************************************************************/ -usrp1_clock_ctrl::sptr usrp1_clock_ctrl::make(usrp1_iface::sptr iface) -{ +usrp1_clock_ctrl::sptr usrp1_clock_ctrl::make(usrp1_iface::sptr iface){ return sptr(new usrp1_clock_ctrl_impl(iface)); } diff --git a/host/lib/usrp/usrp1/clock_ctrl.hpp b/host/lib/usrp/usrp1/clock_ctrl.hpp index 366869dab..645472f02 100644 --- a/host/lib/usrp/usrp1/clock_ctrl.hpp +++ b/host/lib/usrp/usrp1/clock_ctrl.hpp @@ -40,6 +40,13 @@ public: static sptr make(usrp1_iface::sptr iface); /*! + * Set the rate of the fpga clock line. + * Note: does not really set, its all software. + * \param freq the new clock rate in Hz + */ + virtual void set_master_clock_freq(double freq) = 0; + + /*! * Get the rate of the fpga clock line. * \return the fpga clock rate in Hz */ diff --git a/host/lib/usrp/usrp1/mboard_impl.cpp b/host/lib/usrp/usrp1/mboard_impl.cpp index 23c8f03c4..6d5bf466d 100644 --- a/host/lib/usrp/usrp1/mboard_impl.cpp +++ b/host/lib/usrp/usrp1/mboard_impl.cpp @@ -317,6 +317,10 @@ void usrp1_impl::mboard_get(const wax::obj &key_, wax::obj &val) val = _soft_time_ctrl->get_time(); return; + case MBOARD_PROP_CLOCK_RATE: + val = _clock_ctrl->get_master_clock_freq(); + return; + default: UHD_THROW_PROP_GET_ERROR(); } } @@ -379,6 +383,10 @@ void usrp1_impl::mboard_set(const wax::obj &key, const wax::obj &val) _soft_time_ctrl->set_time(val.as<time_spec_t>()); return; + case MBOARD_PROP_CLOCK_RATE: + _clock_ctrl->set_master_clock_freq(val.as<double>()); + return; + default: UHD_THROW_PROP_SET_ERROR(); } } diff --git a/host/lib/usrp/usrp2/mboard_impl.cpp b/host/lib/usrp/usrp2/mboard_impl.cpp index 3e7e8b01f..784f662d9 100644 --- a/host/lib/usrp/usrp2/mboard_impl.cpp +++ b/host/lib/usrp/usrp2/mboard_impl.cpp @@ -355,6 +355,10 @@ void usrp2_mboard_impl::get(const wax::obj &key_, wax::obj &val){ val = _iface->mb_eeprom; return; + case MBOARD_PROP_CLOCK_RATE: + val = this->get_master_clock_freq(); + return; + default: UHD_THROW_PROP_GET_ERROR(); } } @@ -412,6 +416,10 @@ void usrp2_mboard_impl::set(const wax::obj &key, const wax::obj &val){ _iface->mb_eeprom = mboard_eeprom_t(*_iface, mboard_eeprom_t::MAP_N100); return; + case MBOARD_PROP_CLOCK_RATE: + UHD_ASSERT_THROW(val.as<double>() == this->get_master_clock_freq()); + return; + default: UHD_THROW_PROP_SET_ERROR(); } } |