summaryrefslogtreecommitdiffstats
path: root/host
diff options
context:
space:
mode:
Diffstat (limited to 'host')
-rw-r--r--host/lib/usrp/usrp2/CMakeLists.txt3
-rw-r--r--host/lib/usrp/usrp2/clock_ctrl.cpp (renamed from host/lib/usrp/usrp2/clock_control.cpp)14
-rw-r--r--host/lib/usrp/usrp2/clock_ctrl.hpp (renamed from host/lib/usrp/usrp2/clock_control.hpp)6
-rw-r--r--host/lib/usrp/usrp2/codec_ctrl.cpp91
-rw-r--r--host/lib/usrp/usrp2/codec_ctrl.hpp38
-rw-r--r--host/lib/usrp/usrp2/dboard_iface.cpp18
-rw-r--r--host/lib/usrp/usrp2/dboard_impl.cpp2
-rw-r--r--host/lib/usrp/usrp2/mboard_impl.cpp32
-rw-r--r--host/lib/usrp/usrp2/usrp2_impl.cpp2
-rw-r--r--host/lib/usrp/usrp2/usrp2_impl.hpp8
10 files changed, 158 insertions, 56 deletions
diff --git a/host/lib/usrp/usrp2/CMakeLists.txt b/host/lib/usrp/usrp2/CMakeLists.txt
index f9907e21e..6c7881861 100644
--- a/host/lib/usrp/usrp2/CMakeLists.txt
+++ b/host/lib/usrp/usrp2/CMakeLists.txt
@@ -18,7 +18,8 @@
#This file will be included by cmake, use absolute paths!
LIBUHD_APPEND_SOURCES(
- ${CMAKE_SOURCE_DIR}/lib/usrp/usrp2/clock_control.cpp
+ ${CMAKE_SOURCE_DIR}/lib/usrp/usrp2/clock_ctrl.cpp
+ ${CMAKE_SOURCE_DIR}/lib/usrp/usrp2/codec_ctrl.cpp
${CMAKE_SOURCE_DIR}/lib/usrp/usrp2/dboard_impl.cpp
${CMAKE_SOURCE_DIR}/lib/usrp/usrp2/dboard_iface.cpp
${CMAKE_SOURCE_DIR}/lib/usrp/usrp2/dsp_impl.cpp
diff --git a/host/lib/usrp/usrp2/clock_control.cpp b/host/lib/usrp/usrp2/clock_ctrl.cpp
index 72f1f1c7a..db8d8a886 100644
--- a/host/lib/usrp/usrp2/clock_control.cpp
+++ b/host/lib/usrp/usrp2/clock_ctrl.cpp
@@ -15,21 +15,19 @@
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
-#include "usrp2_impl.hpp"
-#include "clock_control.hpp"
+#include "clock_ctrl.hpp"
#include "ad9510_regs.hpp"
#include "usrp2_regs.hpp" //spi slave constants
#include <boost/cstdint.hpp>
using namespace uhd;
-using namespace uhd::usrp;
/*!
* A usrp2 clock control specific to the ad9510 ic.
*/
-class clock_control_ad9510 : public clock_control{
+class clock_ctrl_impl : public clock_ctrl{
public:
- clock_control_ad9510(usrp2_iface::sptr iface){
+ clock_ctrl_impl(usrp2_iface::sptr iface){
_iface = iface;
_ad9510_regs.cp_current_setting = ad9510_regs_t::CP_CURRENT_SETTING_3_0MA;
@@ -70,7 +68,7 @@ public:
}
- ~clock_control_ad9510(void){
+ ~clock_ctrl_impl(void){
/* private clock enables, must be set here */
this->enable_dac_clock(false);
this->enable_adc_clock(false);
@@ -152,6 +150,6 @@ private:
/***********************************************************************
* Public make function for the ad9510 clock control
**********************************************************************/
-clock_control::sptr clock_control::make_ad9510(usrp2_iface::sptr iface){
- return clock_control::sptr(new clock_control_ad9510(iface));
+clock_ctrl::sptr clock_ctrl::make(usrp2_iface::sptr iface){
+ return sptr(new clock_ctrl_impl(iface));
}
diff --git a/host/lib/usrp/usrp2/clock_control.hpp b/host/lib/usrp/usrp2/clock_ctrl.hpp
index b64a53196..3208008a9 100644
--- a/host/lib/usrp/usrp2/clock_control.hpp
+++ b/host/lib/usrp/usrp2/clock_ctrl.hpp
@@ -22,16 +22,16 @@
#include <boost/shared_ptr.hpp>
#include <boost/utility.hpp>
-class clock_control : boost::noncopyable{
+class clock_ctrl : boost::noncopyable{
public:
- typedef boost::shared_ptr<clock_control> sptr;
+ typedef boost::shared_ptr<clock_ctrl> sptr;
/*!
* Make a clock config for the ad9510 ic.
* \param _iface a pointer to the usrp2 interface object
* \return a new clock control object
*/
- static sptr make_ad9510(usrp2_iface::sptr iface);
+ static sptr make(usrp2_iface::sptr iface);
/*!
* Enable/disable the rx dboard clock.
diff --git a/host/lib/usrp/usrp2/codec_ctrl.cpp b/host/lib/usrp/usrp2/codec_ctrl.cpp
new file mode 100644
index 000000000..452aa39b1
--- /dev/null
+++ b/host/lib/usrp/usrp2/codec_ctrl.cpp
@@ -0,0 +1,91 @@
+//
+// Copyright 2010 Ettus Research LLC
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see <http://www.gnu.org/licenses/>.
+//
+
+#include "codec_ctrl.hpp"
+#include "ad9777_regs.hpp"
+#include "usrp2_regs.hpp"
+#include <boost/cstdint.hpp>
+#include <boost/foreach.hpp>
+#include <iostream>
+
+static const bool codec_ctrl_debug = false;
+
+using namespace uhd;
+
+/*!
+ * A usrp2 codec control specific to the ad9777 ic.
+ */
+class codec_ctrl_impl : public codec_ctrl{
+public:
+ codec_ctrl_impl(usrp2_iface::sptr iface){
+ _iface = iface;
+
+ //setup the ad9777 dac
+ _ad9777_regs.x_1r_2r_mode = ad9777_regs_t::X_1R_2R_MODE_1R;
+ _ad9777_regs.filter_interp_rate = ad9777_regs_t::FILTER_INTERP_RATE_4X;
+ _ad9777_regs.mix_mode = ad9777_regs_t::MIX_MODE_REAL;
+ _ad9777_regs.pll_divide_ratio = ad9777_regs_t::PLL_DIVIDE_RATIO_DIV1;
+ _ad9777_regs.pll_state = ad9777_regs_t::PLL_STATE_OFF;
+ _ad9777_regs.auto_cp_control = ad9777_regs_t::AUTO_CP_CONTROL_ENB;
+ //I dac values
+ _ad9777_regs.idac_fine_gain_adjust = 0;
+ _ad9777_regs.idac_coarse_gain_adjust = 0xf;
+ _ad9777_regs.idac_offset_adjust_lsb = 0;
+ _ad9777_regs.idac_offset_adjust_msb = 0;
+ //Q dac values
+ _ad9777_regs.qdac_fine_gain_adjust = 0;
+ _ad9777_regs.qdac_coarse_gain_adjust = 0xf;
+ _ad9777_regs.qdac_offset_adjust_lsb = 0;
+ _ad9777_regs.qdac_offset_adjust_msb = 0;
+ //write all regs
+ for(boost::uint8_t addr = 0; addr <= 0xC; addr++){
+ send_ad9777_reg(addr);
+ }
+
+ //power-up adc
+ _iface->poke32(FR_MISC_CTRL_ADC, FRF_MISC_CTRL_ADC_ON);
+ }
+
+ ~codec_ctrl_impl(void){
+ //power-down dac
+ _ad9777_regs.power_down_mode = 1;
+ send_ad9777_reg(0);
+
+ //power-down adc
+ _iface->poke32(FR_MISC_CTRL_ADC, FRF_MISC_CTRL_ADC_OFF);
+ }
+
+private:
+ ad9777_regs_t _ad9777_regs;
+ usrp2_iface::sptr _iface;
+
+ void send_ad9777_reg(boost::uint8_t addr){
+ boost::uint16_t reg = _ad9777_regs.get_write_reg(addr);
+ if (codec_ctrl_debug) std::cout << "send_ad9777_reg: " << std::hex << reg << std::endl;
+ _iface->transact_spi(
+ SPI_SS_AD9777, spi_config_t::EDGE_RISE,
+ reg, 6, false /*no rb*/
+ );
+ }
+};
+
+/***********************************************************************
+ * Public make function for the usrp2 codec control
+ **********************************************************************/
+codec_ctrl::sptr codec_ctrl::make(usrp2_iface::sptr iface){
+ return sptr(new codec_ctrl_impl(iface));
+}
diff --git a/host/lib/usrp/usrp2/codec_ctrl.hpp b/host/lib/usrp/usrp2/codec_ctrl.hpp
new file mode 100644
index 000000000..c34fb8159
--- /dev/null
+++ b/host/lib/usrp/usrp2/codec_ctrl.hpp
@@ -0,0 +1,38 @@
+//
+// Copyright 2010 Ettus Research LLC
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see <http://www.gnu.org/licenses/>.
+//
+
+#ifndef INCLUDED_CODEC_CONTROL_HPP
+#define INCLUDED_CODEC_CONTROL_HPP
+
+#include "usrp2_iface.hpp"
+#include <boost/shared_ptr.hpp>
+#include <boost/utility.hpp>
+
+class codec_ctrl : boost::noncopyable{
+public:
+ typedef boost::shared_ptr<codec_ctrl> sptr;
+
+ /*!
+ * Make a codec control for the DAC and ADC.
+ * \param _iface a pointer to the usrp2 interface object
+ * \return a new codec control object
+ */
+ static sptr make(usrp2_iface::sptr iface);
+
+};
+
+#endif /* INCLUDED_CODEC_CONTROL_HPP */
diff --git a/host/lib/usrp/usrp2/dboard_iface.cpp b/host/lib/usrp/usrp2/dboard_iface.cpp
index 372a5af07..d33a11fd6 100644
--- a/host/lib/usrp/usrp2/dboard_iface.cpp
+++ b/host/lib/usrp/usrp2/dboard_iface.cpp
@@ -16,7 +16,7 @@
//
#include "usrp2_iface.hpp"
-#include "clock_control.hpp"
+#include "clock_ctrl.hpp"
#include "usrp2_regs.hpp" //wishbone address constants
#include <uhd/usrp/dboard_iface.hpp>
#include <uhd/types/dict.hpp>
@@ -33,7 +33,7 @@ using namespace boost::assign;
class usrp2_dboard_iface : public dboard_iface{
public:
- usrp2_dboard_iface(usrp2_iface::sptr iface, clock_control::sptr clk_ctrl);
+ usrp2_dboard_iface(usrp2_iface::sptr iface, clock_ctrl::sptr clock_ctrl);
~usrp2_dboard_iface(void);
void write_aux_dac(unit_t, int, float);
@@ -66,7 +66,7 @@ public:
private:
usrp2_iface::sptr _iface;
- clock_control::sptr _clk_ctrl;
+ clock_ctrl::sptr _clock_ctrl;
boost::uint32_t _ddr_shadow;
uhd::dict<unit_t, ad5624_regs_t> _dac_regs;
@@ -78,17 +78,17 @@ private:
**********************************************************************/
dboard_iface::sptr make_usrp2_dboard_iface(
usrp2_iface::sptr iface,
- clock_control::sptr clk_ctrl
+ clock_ctrl::sptr clock_ctrl
){
- return dboard_iface::sptr(new usrp2_dboard_iface(iface, clk_ctrl));
+ return dboard_iface::sptr(new usrp2_dboard_iface(iface, clock_ctrl));
}
/***********************************************************************
* Structors
**********************************************************************/
-usrp2_dboard_iface::usrp2_dboard_iface(usrp2_iface::sptr iface, clock_control::sptr clk_ctrl){
+usrp2_dboard_iface::usrp2_dboard_iface(usrp2_iface::sptr iface, clock_ctrl::sptr clock_ctrl){
_iface = iface;
- _clk_ctrl = clk_ctrl;
+ _clock_ctrl = clock_ctrl;
_ddr_shadow = 0;
//set the selection mux to use atr
@@ -123,8 +123,8 @@ double usrp2_dboard_iface::get_clock_rate(unit_t){
void usrp2_dboard_iface::set_clock_enabled(unit_t unit, bool enb){
switch(unit){
- case UNIT_RX: _clk_ctrl->enable_rx_dboard_clock(enb); return;
- case UNIT_TX: _clk_ctrl->enable_tx_dboard_clock(enb); return;
+ case UNIT_RX: _clock_ctrl->enable_rx_dboard_clock(enb); return;
+ case UNIT_TX: _clock_ctrl->enable_tx_dboard_clock(enb); return;
}
}
diff --git a/host/lib/usrp/usrp2/dboard_impl.cpp b/host/lib/usrp/usrp2/dboard_impl.cpp
index 403faf5cf..0f8a739f2 100644
--- a/host/lib/usrp/usrp2/dboard_impl.cpp
+++ b/host/lib/usrp/usrp2/dboard_impl.cpp
@@ -39,7 +39,7 @@ void usrp2_impl::dboard_init(void){
//create a new dboard interface and manager
dboard_iface::sptr _dboard_iface(
- make_usrp2_dboard_iface(_iface, _clk_ctrl)
+ make_usrp2_dboard_iface(_iface, _clock_ctrl)
);
_dboard_manager = dboard_manager::make(
_rx_db_eeprom.id, _tx_db_eeprom.id, _dboard_iface
diff --git a/host/lib/usrp/usrp2/mboard_impl.cpp b/host/lib/usrp/usrp2/mboard_impl.cpp
index 2c8fd2df4..892e45f49 100644
--- a/host/lib/usrp/usrp2/mboard_impl.cpp
+++ b/host/lib/usrp/usrp2/mboard_impl.cpp
@@ -17,7 +17,6 @@
#include "usrp2_impl.hpp"
#include "usrp2_regs.hpp"
-#include "ad9777_regs.hpp"
#include <uhd/usrp/mboard_props.hpp>
#include <uhd/utils/assert.hpp>
#include <uhd/types/mac_addr.hpp>
@@ -38,35 +37,6 @@ void usrp2_impl::mboard_init(void){
boost::bind(&usrp2_impl::mboard_set, this, _1, _2)
);
- _clk_ctrl = clock_control::make_ad9510(_iface);
-
- //setup the ad9777 dac
- ad9777_regs_t ad9777_regs;
- ad9777_regs.x_1r_2r_mode = ad9777_regs_t::X_1R_2R_MODE_1R;
- ad9777_regs.filter_interp_rate = ad9777_regs_t::FILTER_INTERP_RATE_4X;
- ad9777_regs.mix_mode = ad9777_regs_t::MIX_MODE_REAL;
- ad9777_regs.pll_divide_ratio = ad9777_regs_t::PLL_DIVIDE_RATIO_DIV1;
- ad9777_regs.pll_state = ad9777_regs_t::PLL_STATE_OFF;
- ad9777_regs.auto_cp_control = ad9777_regs_t::AUTO_CP_CONTROL_ENB;
- //I dac values
- ad9777_regs.idac_fine_gain_adjust = 0;
- ad9777_regs.idac_coarse_gain_adjust = 0xf;
- ad9777_regs.idac_offset_adjust_lsb = 0;
- ad9777_regs.idac_offset_adjust_msb = 0;
- //Q dac values
- ad9777_regs.qdac_fine_gain_adjust = 0;
- ad9777_regs.qdac_coarse_gain_adjust = 0xf;
- ad9777_regs.qdac_offset_adjust_lsb = 0;
- ad9777_regs.qdac_offset_adjust_msb = 0;
- //write all regs
- for(boost::uint8_t addr = 0; addr <= 0xC; addr++){
- boost::uint16_t data = ad9777_regs.get_write_reg(addr);
- _iface->transact_spi(SPI_SS_AD9777, spi_config_t::EDGE_RISE, data, 16, false /*no rb*/);
- }
-
- //enable ADCs
- _iface->poke32(FR_MISC_CTRL_ADC, FRF_MISC_CTRL_ADC_ON);
-
//set up serdes
_iface->poke32(FR_MISC_CTRL_SERDES, FRF_MISC_CTRL_SERDES_ENABLE | FRF_MISC_CTRL_SERDES_RXEN);
@@ -112,7 +82,7 @@ void usrp2_impl::update_clock_config(void){
//clock source ref 10mhz
bool use_external = _clock_config.ref_source != clock_config_t::REF_INT;
- _clk_ctrl->enable_external_ref(use_external);
+ _clock_ctrl->enable_external_ref(use_external);
}
void usrp2_impl::set_time_spec(const time_spec_t &time_spec, bool now){
diff --git a/host/lib/usrp/usrp2/usrp2_impl.cpp b/host/lib/usrp/usrp2/usrp2_impl.cpp
index 1dde8c054..ef7754c33 100644
--- a/host/lib/usrp/usrp2/usrp2_impl.cpp
+++ b/host/lib/usrp/usrp2/usrp2_impl.cpp
@@ -147,6 +147,8 @@ usrp2_impl::usrp2_impl(
//make a new interface for usrp2 stuff
_iface = usrp2_iface::make(ctrl_transport);
+ _clock_ctrl = clock_ctrl::make(_iface);
+ _codec_ctrl = codec_ctrl::make(_iface);
//load the allowed decim/interp rates
//_USRP2_RATES = range(4, 128+1, 1) + range(130, 256+1, 2) + range(260, 512+1, 4)
diff --git a/host/lib/usrp/usrp2/usrp2_impl.hpp b/host/lib/usrp/usrp2/usrp2_impl.hpp
index 1c9387744..871050356 100644
--- a/host/lib/usrp/usrp2/usrp2_impl.hpp
+++ b/host/lib/usrp/usrp2/usrp2_impl.hpp
@@ -19,7 +19,8 @@
#define INCLUDED_USRP2_IMPL_HPP
#include "usrp2_iface.hpp"
-#include "clock_control.hpp"
+#include "clock_ctrl.hpp"
+#include "codec_ctrl.hpp"
#include <uhd/usrp/usrp2.hpp>
#include <uhd/types/dict.hpp>
#include <uhd/types/otw_type.hpp>
@@ -40,7 +41,7 @@
*/
uhd::usrp::dboard_iface::sptr make_usrp2_dboard_iface(
usrp2_iface::sptr iface,
- clock_control::sptr clk_ctrl
+ clock_ctrl::sptr clk_ctrl
);
/*!
@@ -114,7 +115,8 @@ private:
void set(const wax::obj &, const wax::obj &);
//interfaces
- clock_control::sptr _clk_ctrl;
+ clock_ctrl::sptr _clock_ctrl;
+ codec_ctrl::sptr _codec_ctrl;
usrp2_iface::sptr _iface;
//the raw io interface (samples are in the usrp2 native format)