aboutsummaryrefslogtreecommitdiffstats
path: root/host/lib/usrp/usrp1
diff options
context:
space:
mode:
Diffstat (limited to 'host/lib/usrp/usrp1')
-rw-r--r--host/lib/usrp/usrp1/codec_ctrl.cpp9
-rw-r--r--host/lib/usrp/usrp1/io_impl.cpp12
-rw-r--r--host/lib/usrp/usrp1/usrp1_impl.cpp28
-rw-r--r--host/lib/usrp/usrp1/usrp1_impl.hpp4
4 files changed, 37 insertions, 16 deletions
diff --git a/host/lib/usrp/usrp1/codec_ctrl.cpp b/host/lib/usrp/usrp1/codec_ctrl.cpp
index c82569ea3..7383c9833 100644
--- a/host/lib/usrp/usrp1/codec_ctrl.cpp
+++ b/host/lib/usrp/usrp1/codec_ctrl.cpp
@@ -1,5 +1,5 @@
//
-// Copyright 2010-2011 Ettus Research LLC
+// Copyright 2010-2012 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
@@ -27,6 +27,7 @@
#include <boost/format.hpp>
#include <boost/tuple/tuple.hpp>
#include <boost/math/special_functions/round.hpp>
+#include <boost/math/special_functions/sign.hpp>
#include <boost/assign/list_of.hpp>
#include <iomanip>
@@ -375,6 +376,12 @@ double usrp1_codec_ctrl_impl::fine_tune(double codec_rate, double target_freq)
void usrp1_codec_ctrl_impl::set_duc_freq(double freq, double rate)
{
double codec_rate = rate * 2;
+
+ //correct for outside of rate (wrap around)
+ freq = std::fmod(freq, rate);
+ if (std::abs(freq) > rate/2.0)
+ freq -= boost::math::sign(freq)*rate;
+
double coarse_freq = coarse_tune(codec_rate, freq);
double fine_freq = fine_tune(codec_rate / 4, freq - coarse_freq);
diff --git a/host/lib/usrp/usrp1/io_impl.cpp b/host/lib/usrp/usrp1/io_impl.cpp
index b5575ef8f..8940a92bb 100644
--- a/host/lib/usrp/usrp1/io_impl.cpp
+++ b/host/lib/usrp/usrp1/io_impl.cpp
@@ -90,8 +90,8 @@ public:
/* NOP */
}
- void commit(size_t size){
- if (size != 0) this->_commit_cb(_curr_buff, _next_buff, size);
+ void release(void){
+ this->_commit_cb(_curr_buff, _next_buff, size());
}
sptr get_new(
@@ -100,13 +100,13 @@ public:
){
_curr_buff = curr_buff;
_next_buff = next_buff;
- return make_managed_buffer(this);
+ return make(this,
+ _curr_buff.buff->cast<char *>() + _curr_buff.offset,
+ _curr_buff.buff->size() - _curr_buff.offset
+ );
}
private:
- void *get_buff(void) const{return _curr_buff.buff->cast<char *>() + _curr_buff.offset;}
- size_t get_size(void) const{return _curr_buff.buff->size() - _curr_buff.offset;}
-
offset_send_buffer _curr_buff, _next_buff;
commit_cb_type _commit_cb;
};
diff --git a/host/lib/usrp/usrp1/usrp1_impl.cpp b/host/lib/usrp/usrp1/usrp1_impl.cpp
index 96570d019..253ac1d6f 100644
--- a/host/lib/usrp/usrp1/usrp1_impl.cpp
+++ b/host/lib/usrp/usrp1/usrp1_impl.cpp
@@ -84,11 +84,7 @@ static device_addrs_t usrp1_find(const device_addr_t &hint)
usrp1_fw_image = find_image_path(hint.get("fw", "usrp1_fw.ihx"));
}
catch(...){
- UHD_MSG(warning) << boost::format(
- "Could not locate USRP1 firmware.\n"
- "Please install the images package.\n"
- );
- return usrp1_addrs;
+ UHD_MSG(warning) << boost::format("Could not locate USRP1 firmware. %s") % print_images_error();
}
UHD_LOG << "USRP1 firmware image: " << usrp1_fw_image << std::endl;
@@ -116,7 +112,7 @@ static device_addrs_t usrp1_find(const device_addr_t &hint)
catch(const uhd::exception &){continue;} //ignore claimed
fx2_ctrl::sptr fx2_ctrl = fx2_ctrl::make(control);
- const mboard_eeprom_t mb_eeprom(*fx2_ctrl, mboard_eeprom_t::MAP_B000);
+ const mboard_eeprom_t mb_eeprom(*fx2_ctrl, USRP1_EEPROM_MAP_KEY);
device_addr_t new_addr;
new_addr["type"] = "usrp1";
new_addr["name"] = mb_eeprom["name"];
@@ -209,14 +205,20 @@ usrp1_impl::usrp1_impl(const device_addr_t &device_addr){
_tree = property_tree::make();
_tree->create<std::string>("/name").set("USRP1 Device");
const fs_path mb_path = "/mboards/0";
- _tree->create<std::string>(mb_path / "name").set("USRP1 (Classic)");
+ _tree->create<std::string>(mb_path / "name").set("USRP1");
_tree->create<std::string>(mb_path / "load_eeprom")
.subscribe(boost::bind(&fx2_ctrl::usrp_load_eeprom, _fx2_ctrl, _1));
////////////////////////////////////////////////////////////////////
+ // create user-defined control objects
+ ////////////////////////////////////////////////////////////////////
+ _tree->create<std::pair<boost::uint8_t, boost::uint32_t> >(mb_path / "user" / "regs")
+ .subscribe(boost::bind(&usrp1_impl::set_reg, this, _1));
+
+ ////////////////////////////////////////////////////////////////////
// setup the mboard eeprom
////////////////////////////////////////////////////////////////////
- const mboard_eeprom_t mb_eeprom(*_fx2_ctrl, mboard_eeprom_t::MAP_B000);
+ const mboard_eeprom_t mb_eeprom(*_fx2_ctrl, USRP1_EEPROM_MAP_KEY);
_tree->create<mboard_eeprom_t>(mb_path / "eeprom")
.set(mb_eeprom)
.subscribe(boost::bind(&usrp1_impl::set_mb_eeprom, this, _1));
@@ -353,6 +355,9 @@ usrp1_impl::usrp1_impl(const device_addr_t &device_addr){
tx_db_eeprom.load(*_fx2_ctrl, (db == "A")? (I2C_ADDR_TX_A) : (I2C_ADDR_TX_B));
gdb_eeprom.load(*_fx2_ctrl, (db == "A")? (I2C_ADDR_TX_A ^ 5) : (I2C_ADDR_TX_B ^ 5));
+ //disable rx dc offset if LFRX
+ if (rx_db_eeprom.id == 0x000f) _tree->access<bool>(mb_path / "rx_frontends" / db / "dc_offset" / "enable").set(false);
+
//create the properties and register subscribers
_tree->create<dboard_eeprom_t>(mb_path / "dboards" / db/ "rx_eeprom")
.set(rx_db_eeprom)
@@ -447,7 +452,7 @@ bool usrp1_impl::has_tx_halfband(void){
* Properties callback methods below
**********************************************************************/
void usrp1_impl::set_mb_eeprom(const uhd::usrp::mboard_eeprom_t &mb_eeprom){
- mb_eeprom.commit(*_fx2_ctrl, mboard_eeprom_t::MAP_B000);
+ mb_eeprom.commit(*_fx2_ctrl, USRP1_EEPROM_MAP_KEY);
}
void usrp1_impl::set_db_eeprom(const std::string &db, const std::string &type, const uhd::usrp::dboard_eeprom_t &db_eeprom){
@@ -496,3 +501,8 @@ std::complex<double> usrp1_impl::set_rx_dc_offset(const std::string &db, const s
return std::complex<double>(double(i_off) * (1ul << 31), double(q_off) * (1ul << 31));
}
+
+void usrp1_impl::set_reg(const std::pair<boost::uint8_t, boost::uint32_t> &reg)
+{
+ _iface->poke32(reg.first, reg.second);
+}
diff --git a/host/lib/usrp/usrp1/usrp1_impl.hpp b/host/lib/usrp/usrp1/usrp1_impl.hpp
index d903a18e9..0be8ebca9 100644
--- a/host/lib/usrp/usrp1/usrp1_impl.hpp
+++ b/host/lib/usrp/usrp1/usrp1_impl.hpp
@@ -38,6 +38,8 @@
#ifndef INCLUDED_USRP1_IMPL_HPP
#define INCLUDED_USRP1_IMPL_HPP
+static const std::string USRP1_EEPROM_MAP_KEY = "B000";
+
#define FR_RB_CAPS 3
#define FR_MODE 13
#define FR_DEBUG_EN 14
@@ -152,6 +154,8 @@ private:
void vandal_conquest_loop(void);
+ void set_reg(const std::pair<boost::uint8_t, boost::uint32_t> &reg);
+
//handle the enables
bool _rx_enabled, _tx_enabled;
void enable_rx(bool enb){