From b998964ca78e3d7927c82680c167aebf9cabae73 Mon Sep 17 00:00:00 2001 From: Nick Foster Date: Thu, 1 Sep 2011 12:48:16 -0700 Subject: B100: unshadow dboard clock rates so you can set master freq after init and still tune ok --- host/lib/usrp/b100/clock_ctrl.cpp | 2 +- host/lib/usrp/b100/clock_ctrl.hpp | 12 ++++++++++++ host/lib/usrp/b100/dboard_iface.cpp | 14 ++++++++------ 3 files changed, 21 insertions(+), 7 deletions(-) diff --git a/host/lib/usrp/b100/clock_ctrl.cpp b/host/lib/usrp/b100/clock_ctrl.cpp index b1e12773e..df1442420 100644 --- a/host/lib/usrp/b100/clock_ctrl.cpp +++ b/host/lib/usrp/b100/clock_ctrl.cpp @@ -159,7 +159,7 @@ static clock_settings_type get_clock_settings(double rate){ } } - throw uhd::runtime_error(str(boost::format( + throw uhd::value_error(str(boost::format( "USRP-B100 clock control: could not calculate settings for clock rate %fMHz" ) % (rate/1e6))); } diff --git a/host/lib/usrp/b100/clock_ctrl.hpp b/host/lib/usrp/b100/clock_ctrl.hpp index 5ef231281..68c24bdce 100644 --- a/host/lib/usrp/b100/clock_ctrl.hpp +++ b/host/lib/usrp/b100/clock_ctrl.hpp @@ -78,6 +78,18 @@ public: * \throw exception when rate cannot be achieved */ virtual void set_tx_dboard_clock_rate(double rate) = 0; + + /*! + * Get the current rx dboard clock rate. + * \return the clock rate in Hz + */ + virtual double get_rx_clock_rate(void) = 0; + + /*! + * Get the current tx dboard clock rate. + * \return the clock rate in Hz + */ + virtual double get_tx_clock_rate(void) = 0; /*! * Enable/disable the FPGA clock. diff --git a/host/lib/usrp/b100/dboard_iface.cpp b/host/lib/usrp/b100/dboard_iface.cpp index 33c4b355d..229215a4e 100644 --- a/host/lib/usrp/b100/dboard_iface.cpp +++ b/host/lib/usrp/b100/dboard_iface.cpp @@ -104,7 +104,6 @@ private: spi_iface::sptr _spi_iface; b100_clock_ctrl::sptr _clock; b100_codec_ctrl::sptr _codec; - uhd::dict _clock_rates; }; /*********************************************************************** @@ -124,7 +123,6 @@ dboard_iface::sptr make_b100_dboard_iface( * Clock Rates **********************************************************************/ void b100_dboard_iface::set_clock_rate(unit_t unit, double rate){ - _clock_rates[unit] = rate; switch(unit){ case UNIT_RX: return _clock->set_rx_dboard_clock_rate(rate); case UNIT_TX: return _clock->set_tx_dboard_clock_rate(rate); @@ -140,7 +138,11 @@ std::vector b100_dboard_iface::get_clock_rates(unit_t unit){ } double b100_dboard_iface::get_clock_rate(unit_t unit){ - return _clock_rates[unit]; + switch(unit){ + case UNIT_RX: return _clock->get_rx_clock_rate(); + case UNIT_TX: return _clock->get_tx_clock_rate(); + } + UHD_THROW_INVALID_CODE_PATH(); } void b100_dboard_iface::set_clock_enabled(unit_t unit, bool enb){ @@ -244,7 +246,7 @@ static boost::uint32_t unit_to_otw_spi_dev(dboard_iface::unit_t unit){ case dboard_iface::UNIT_TX: return B100_SPI_SS_TX_DB; case dboard_iface::UNIT_RX: return B100_SPI_SS_RX_DB; } - throw std::invalid_argument("unknown unit type"); + UHD_THROW_INVALID_CODE_PATH(); } void b100_dboard_iface::write_spi( @@ -253,7 +255,7 @@ void b100_dboard_iface::write_spi( boost::uint32_t data, size_t num_bits ){ - _spi_iface->transact_spi(unit_to_otw_spi_dev(unit), config, data, num_bits, false /*no rb*/); + _spi_iface->write_spi(unit_to_otw_spi_dev(unit), config, data, num_bits); } boost::uint32_t b100_dboard_iface::read_write_spi( @@ -262,7 +264,7 @@ boost::uint32_t b100_dboard_iface::read_write_spi( boost::uint32_t data, size_t num_bits ){ - return _spi_iface->transact_spi(unit_to_otw_spi_dev(unit), config, data, num_bits, true /*rb*/); + return _spi_iface->read_spi(unit_to_otw_spi_dev(unit), config, data, num_bits); } /*********************************************************************** -- cgit v1.2.3