summaryrefslogtreecommitdiffstats
path: root/host/lib/usrp
diff options
context:
space:
mode:
Diffstat (limited to 'host/lib/usrp')
-rw-r--r--host/lib/usrp/CMakeLists.txt1
-rw-r--r--host/lib/usrp/mboard_rev.cpp29
-rw-r--r--host/lib/usrp/usrp2/clock_ctrl.cpp6
-rw-r--r--host/lib/usrp/usrp2/codec_ctrl.cpp10
-rw-r--r--host/lib/usrp/usrp2/codec_impl.cpp4
-rw-r--r--host/lib/usrp/usrp2/mboard_impl.cpp18
-rw-r--r--host/lib/usrp/usrp2/usrp2_iface.cpp4
-rw-r--r--host/lib/usrp/usrp2/usrp2_iface.hpp1
-rw-r--r--host/lib/usrp/usrp2/usrp2_regs.cpp11
-rw-r--r--host/lib/usrp/usrp2/usrp2_regs.hpp6
10 files changed, 62 insertions, 28 deletions
diff --git a/host/lib/usrp/CMakeLists.txt b/host/lib/usrp/CMakeLists.txt
index 69a190bfa..fd4eb1016 100644
--- a/host/lib/usrp/CMakeLists.txt
+++ b/host/lib/usrp/CMakeLists.txt
@@ -23,6 +23,7 @@ LIBUHD_APPEND_SOURCES(
${CMAKE_SOURCE_DIR}/lib/usrp/dboard_id.cpp
${CMAKE_SOURCE_DIR}/lib/usrp/dboard_manager.cpp
${CMAKE_SOURCE_DIR}/lib/usrp/dsp_utils.cpp
+ ${CMAKE_SOURCE_DIR}/lib/usrp/mboard_rev.cpp
${CMAKE_SOURCE_DIR}/lib/usrp/mimo_usrp.cpp
${CMAKE_SOURCE_DIR}/lib/usrp/misc_utils.cpp
${CMAKE_SOURCE_DIR}/lib/usrp/simple_usrp.cpp
diff --git a/host/lib/usrp/mboard_rev.cpp b/host/lib/usrp/mboard_rev.cpp
index 8206d12af..41600951f 100644
--- a/host/lib/usrp/mboard_rev.cpp
+++ b/host/lib/usrp/mboard_rev.cpp
@@ -23,7 +23,9 @@
using namespace uhd::usrp;
-mboard_rev_t::mboard_rev_t(boost::uint16_t id){
+static const mboard_rev_t usrp2p_first_hw_rev = mboard_rev_t(0x0A00);
+
+mboard_rev_t::mboard_rev_t(boost::uint16_t rev){
_rev = rev;
}
@@ -60,9 +62,30 @@ std::string mboard_rev_t::to_string(void) const{
return str(boost::format("0x%04x") % this->to_uint16());
}
-//Note: to_pp_string is implemented in the dboard manager
-//because it needs access to the dboard registration table
+std::string mboard_rev_t::to_pp_string(void) const{
+ if(this->is_usrp2p()) {
+ return str(boost::format("USRP2+, major rev %i, minor rev %i") % int(this->major()) % int(this->minor()));
+ } else {
+ return str(boost::format("USRP2, major rev %i, minor rev %i") % int(this->major()) % int(this->minor()));
+ }
+}
+
+bool mboard_rev_t::is_usrp2p(void) const{
+ return _rev >= usrp2p_first_hw_rev;
+}
+
+boost::uint8_t mboard_rev_t::major(void) const{
+ return _rev >> 8;
+}
+
+boost::uint8_t mboard_rev_t::minor(void) const{
+ return _rev & 0xff;
+}
bool uhd::usrp::operator==(const mboard_rev_t &lhs, const mboard_rev_t &rhs){
return lhs.to_uint16() == rhs.to_uint16();
}
+
+bool uhd::usrp::operator<(const mboard_rev_t &lhs, const mboard_rev_t &rhs){
+ return lhs.to_uint16() < rhs.to_uint16();
+}
diff --git a/host/lib/usrp/usrp2/clock_ctrl.cpp b/host/lib/usrp/usrp2/clock_ctrl.cpp
index 8887faf12..c652b592b 100644
--- a/host/lib/usrp/usrp2/clock_ctrl.cpp
+++ b/host/lib/usrp/usrp2/clock_ctrl.cpp
@@ -32,7 +32,8 @@ using namespace uhd;
class usrp2_clock_ctrl_impl : public usrp2_clock_ctrl{
public:
usrp2_clock_ctrl_impl(usrp2_iface::sptr iface){
- clk_regs = usrp2_clk_regs_t(iface->get_hw_rev());
+ _iface = iface;
+ clk_regs = usrp2_clk_regs_t(_iface->get_hw_rev());
_ad9510_regs.cp_current_setting = ad9510_regs_t::CP_CURRENT_SETTING_3_0MA;
this->write_reg(clk_regs.pll_3);
@@ -123,6 +124,7 @@ public:
break;
default:
+ break;
}
this->write_reg(clk_regs.output(clk_regs.exp));
this->write_reg(clk_regs.div_lo(clk_regs.exp));
@@ -296,6 +298,8 @@ private:
this->write_reg(clk_regs.div_hi(clk_regs.adc));
this->update_regs();
}
+
+ usrp2_iface::sptr _iface;
usrp2_clk_regs_t clk_regs;
ad9510_regs_t _ad9510_regs;
diff --git a/host/lib/usrp/usrp2/codec_ctrl.cpp b/host/lib/usrp/usrp2/codec_ctrl.cpp
index 22a892f02..533534bd0 100644
--- a/host/lib/usrp/usrp2/codec_ctrl.cpp
+++ b/host/lib/usrp/usrp2/codec_ctrl.cpp
@@ -59,7 +59,7 @@ public:
}
//power-up adc
- if(_iface->get_hw_rev() < USRP2P_FIRST_HW_REV) { //if we're on a USRP2
+ if(!_iface->get_hw_rev().is_usrp2p()) { //if we're on a USRP2
_iface->poke32(_iface->regs.misc_ctrl_adc, U2_FLAG_MISC_CTRL_ADC_ON);
} else { //we're on a USRP2+
_ads62p44_regs.reset = 1;
@@ -77,7 +77,7 @@ public:
this->send_ad9777_reg(0);
//power-down adc
- if(_iface->get_hw_rev() < USRP2P_FIRST_HW_REV) { //if we're on a USRP2
+ if(!_iface->get_hw_rev().is_usrp2p()) { //if we're on a USRP2
_iface->poke32(_iface->regs.misc_ctrl_adc, U2_FLAG_MISC_CTRL_ADC_OFF);
} else { //we're on a USRP2+
//send a global power-down to the ADC here... it will get lifted on reset
@@ -87,21 +87,21 @@ public:
}
void set_rx_digital_gain(float gain) { //fine digital gain
- if(_iface->get_hw_rev() >= USRP2P_FIRST_HW_REV) {
+ if(_iface->get_hw_rev().is_usrp2p()) {
_ads62p44_regs.fine_gain = int(gain/0.5);
this->send_ads62p44_reg(0x17);
} else UHD_THROW_INVALID_CODE_PATH(); //should never have been called for USRP2
}
void set_rx_digital_fine_gain(float gain) { //gain correction
- if(_iface->get_hw_rev() >= USRP2P_FIRST_HW_REV) {
+ if(_iface->get_hw_rev().is_usrp2p()) {
_ads62p44_regs.gain_correction = int(gain / 0.05);
this->send_ads62p44_reg(0x1A);
} else UHD_THROW_INVALID_CODE_PATH(); //should never have been called for USRP2
}
void set_rx_analog_gain(bool gain) { //turns on/off analog 3.5dB preamp
- if(_iface->get_hw_rev() >= USRP2P_FIRST_HW_REV) {
+ if(_iface->get_hw_rev().is_usrp2p()) {
_ads62p44_regs.coarse_gain = gain ? ads62p44_regs_t::COARSE_GAIN_3_5DB : ads62p44_regs_t::COARSE_GAIN_0DB;
this->send_ads62p44_reg(0x14);
} else UHD_THROW_INVALID_CODE_PATH();
diff --git a/host/lib/usrp/usrp2/codec_impl.cpp b/host/lib/usrp/usrp2/codec_impl.cpp
index 04a11d922..6065b6c28 100644
--- a/host/lib/usrp/usrp2/codec_impl.cpp
+++ b/host/lib/usrp/usrp2/codec_impl.cpp
@@ -67,7 +67,7 @@ void usrp2_mboard_impl::rx_codec_get(const wax::obj &key_, wax::obj &val){
return;
case CODEC_PROP_GAIN_NAMES:
- if(_iface->get_hw_rev().to_uint16() >= USRP2P_FIRST_HW_REV) {
+ if(_iface->get_hw_rev().is_usrp2p()) {
val = prop_names_t(codec_rx_gain_ranges.keys());
} else val = prop_names_t();
return;
@@ -94,7 +94,7 @@ void usrp2_mboard_impl::rx_codec_set(const wax::obj &key_, const wax::obj &val){
switch(key.as<codec_prop_t>()) {
case CODEC_PROP_GAIN_I:
case CODEC_PROP_GAIN_Q:
- if(_iface->get_hw_rev().to_uint16() < USRP2P_FIRST_HW_REV) UHD_THROW_PROP_SET_ERROR();//this capability is only found in USRP2P
+ if(!_iface->get_hw_rev().is_usrp2p()) UHD_THROW_PROP_SET_ERROR();//this capability is only found in USRP2P
gain = val.as<float>();
this->rx_codec_set_gain(gain, key.name);
diff --git a/host/lib/usrp/usrp2/mboard_impl.cpp b/host/lib/usrp/usrp2/mboard_impl.cpp
index 6ee6d03a1..3a7048cdd 100644
--- a/host/lib/usrp/usrp2/mboard_impl.cpp
+++ b/host/lib/usrp/usrp2/mboard_impl.cpp
@@ -51,7 +51,7 @@ usrp2_mboard_impl::usrp2_mboard_impl(
//extract the mboard rev numbers
byte_vector_t rev_bytes = _iface->read_eeprom(USRP2_I2C_ADDR_MBOARD, USRP2_EE_MBOARD_REV, 2);
- _iface->set_hw_rev(mboard_rev_t::from_uint16(rev_bytes.at(0) | (revbytes.at(1) << 8)));
+ _iface->set_hw_rev(mboard_rev_t::from_uint16(rev_bytes.at(0) | (rev_bytes.at(1) << 8)));
//contruct the interfaces to mboard perifs
_clock_ctrl = usrp2_clock_ctrl::make(_iface);
@@ -158,7 +158,7 @@ void usrp2_mboard_impl::update_clock_config(void){
_iface->poke32(_iface->regs.time64_flags, pps_flags);
//clock source ref 10mhz
- if(_iface->get_hw_rev() >= USRP2P_FIRST_HW_REV) {
+ if(_iface->get_hw_rev().is_usrp2p()) {
switch(_clock_config.ref_source){
case clock_config_t::REF_INT : _iface->poke32(_iface->regs.misc_ctrl_clock, 0x12); break;
case clock_config_t::REF_SMA : _iface->poke32(_iface->regs.misc_ctrl_clock, 0x1C); break;
@@ -176,7 +176,7 @@ void usrp2_mboard_impl::update_clock_config(void){
//clock source ref 10mhz
bool use_external = (_clock_config.ref_source != clock_config_t::REF_INT)
- || (_iface->get_hw_rev() >= USRP2P_FIRST_HW_REV); //USRP2P has an internal 10MHz TCXO
+ || (_iface->get_hw_rev().is_usrp2p()); //USRP2P has an internal 10MHz TCXO
_clock_ctrl->enable_external_ref(use_external);
}
@@ -224,10 +224,11 @@ void usrp2_mboard_impl::get(const wax::obj &key_, wax::obj &val){
}
if (key.as<std::string>() == "hw-rev"){
- //extract the mboard rev numbers
+ //extract the mboard rev number
val = _iface->get_hw_rev().to_string();
return;
}
+ }
//handle the get request conditioned on the key
switch(key.as<mboard_prop_t>()){
@@ -327,12 +328,13 @@ void usrp2_mboard_impl::set(const wax::obj &key, const wax::obj &val){
if (key.as<std::string>() == "hw-rev"){
mboard_rev_t rev = mboard_rev_t::from_string(val.as<std::string>());
- byte_vector_t revbytes(2);
- revbytes(1) = rev.to_uint16() >> 8;
- revbytes(0) = rev.to_uint16() & 0xff;
- _iface->write_eeprom(USRP2_I2C_ADDR_MBOARD, USRP2_EE_MBOARD_REV, revbytes);
+ byte_vector_t rev_bytes(2);
+ rev_bytes[1] = rev.to_uint16() >> 8;
+ rev_bytes[0] = rev.to_uint16() & 0xff;
+ _iface->write_eeprom(USRP2_I2C_ADDR_MBOARD, USRP2_EE_MBOARD_REV, rev_bytes);
_iface->set_hw_rev(rev); //so the iface knows what rev it is
return;
+ }
}
//handle the set request conditioned on the key
diff --git a/host/lib/usrp/usrp2/usrp2_iface.cpp b/host/lib/usrp/usrp2/usrp2_iface.cpp
index 7ce5cc936..bce859629 100644
--- a/host/lib/usrp/usrp2/usrp2_iface.cpp
+++ b/host/lib/usrp/usrp2/usrp2_iface.cpp
@@ -260,12 +260,12 @@ public:
/***********************************************************************
* Get/set hardware revision
**********************************************************************/
- void set_hw_rev(mboard_rev_t rev) {
+ void set_hw_rev(uhd::usrp::mboard_rev_t rev) {
hw_rev = rev;
regs = usrp2_get_regs(rev); //might be a better place to do this
}
- mboard_rev_t get_hw_rev(void) {
+ uhd::usrp::mboard_rev_t get_hw_rev(void) {
return hw_rev;
}
diff --git a/host/lib/usrp/usrp2/usrp2_iface.hpp b/host/lib/usrp/usrp2/usrp2_iface.hpp
index fe2687d02..53a8e4bc8 100644
--- a/host/lib/usrp/usrp2/usrp2_iface.hpp
+++ b/host/lib/usrp/usrp2/usrp2_iface.hpp
@@ -23,6 +23,7 @@
#include <boost/shared_ptr.hpp>
#include <boost/utility.hpp>
#include <boost/cstdint.hpp>
+#include <uhd/usrp/mboard_rev.hpp>
#include <utility>
#include "fw_common.h"
#include "usrp2_regs.hpp"
diff --git a/host/lib/usrp/usrp2/usrp2_regs.cpp b/host/lib/usrp/usrp2/usrp2_regs.cpp
index 49f077221..f9b54b76e 100644
--- a/host/lib/usrp/usrp2/usrp2_regs.cpp
+++ b/host/lib/usrp/usrp2/usrp2_regs.cpp
@@ -15,19 +15,20 @@
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
+#include <uhd/usrp/mboard_rev.hpp>
#include "usrp2_regs.hpp"
int sr_addr(int misc_output_base, int sr) {
return misc_output_base + 4 * sr;
}
-usrp2_regs_t usrp2_get_regs(int hw_rev) {
+usrp2_regs_t usrp2_get_regs(uhd::usrp::mboard_rev_t hw_rev) {
//how about you just make this dependent on hw_rev instead of doing the init before main, and give up the const globals, since the application won't ever need both.
- const int misc_output_base = (hw_rev>=USRP2P_FIRST_HW_REV) ? USRP2P_MISC_OUTPUT_BASE : USRP2_MISC_OUTPUT_BASE,
- gpio_base = (hw_rev>=USRP2P_FIRST_HW_REV) ? USRP2P_GPIO_BASE : USRP2_GPIO_BASE,
- atr_base = (hw_rev>=USRP2P_FIRST_HW_REV) ? USRP2P_ATR_BASE : USRP2_ATR_BASE,
- bp_base = (hw_rev>=USRP2P_FIRST_HW_REV) ? USRP2P_BP_STATUS_BASE : USRP2_BP_STATUS_BASE;
+ const int misc_output_base = (hw_rev.is_usrp2p()) ? USRP2P_MISC_OUTPUT_BASE : USRP2_MISC_OUTPUT_BASE,
+ gpio_base = (hw_rev.is_usrp2p()) ? USRP2P_GPIO_BASE : USRP2_GPIO_BASE,
+ atr_base = (hw_rev.is_usrp2p()) ? USRP2P_ATR_BASE : USRP2_ATR_BASE,
+ bp_base = (hw_rev.is_usrp2p()) ? USRP2P_BP_STATUS_BASE : USRP2_BP_STATUS_BASE;
usrp2_regs_t x;
x.sr_misc = 0;
diff --git a/host/lib/usrp/usrp2/usrp2_regs.hpp b/host/lib/usrp/usrp2/usrp2_regs.hpp
index 8dae843ab..bb15ed496 100644
--- a/host/lib/usrp/usrp2/usrp2_regs.hpp
+++ b/host/lib/usrp/usrp2/usrp2_regs.hpp
@@ -18,6 +18,8 @@
#ifndef INCLUDED_USRP2_REGS_HPP
#define INCLUDED_USRP2_REGS_HPP
+#include <uhd/usrp/mboard_rev.hpp>
+
#define USRP2_MISC_OUTPUT_BASE 0xD400
#define USRP2_GPIO_BASE 0xC800
#define USRP2_ATR_BASE 0xE400
@@ -28,7 +30,7 @@
#define USRP2P_ATR_BASE 0x3800
#define USRP2P_BP_STATUS_BASE 0x3300
-#define USRP2P_FIRST_HW_REV 0x0A00
+const uhd::usrp::mboard_rev_t USRP2P_FIRST_HW_REV(0x0A00);
typedef struct {
int sr_misc;
@@ -101,7 +103,7 @@ typedef struct {
extern const usrp2_regs_t usrp2_regs; //the register definitions, set in usrp2_regs.cpp and usrp2p_regs.cpp
-usrp2_regs_t usrp2_get_regs(int hw_rev);
+usrp2_regs_t usrp2_get_regs(uhd::usrp::mboard_rev_t hw_rev);
////////////////////////////////////////////////////
// Settings Bus, Slave #7, Not Byte Addressable!