summaryrefslogtreecommitdiffstats
path: root/host/lib/usrp/usrp1
diff options
context:
space:
mode:
authorJosh Blum <josh@joshknows.com>2010-09-20 18:17:52 -0700
committerJosh Blum <josh@joshknows.com>2010-09-20 18:17:52 -0700
commitd68922ed306cd73eb761165369619cdbac2ca637 (patch)
treeb5e0e50faee9cb906d4b316270c1d1a72a61d682 /host/lib/usrp/usrp1
parent1625bcb4139a317189ff2a4c71b96473944aba50 (diff)
downloaduhd-d68922ed306cd73eb761165369619cdbac2ca637.tar.gz
uhd-d68922ed306cd73eb761165369619cdbac2ca637.tar.bz2
uhd-d68922ed306cd73eb761165369619cdbac2ca637.zip
usrp1: implemented multi-channel dsp control of shift freq
usrp: simple usrp calls into single usrp and prints deprecation warning usrp: tune helper now supports multi-channel dsps
Diffstat (limited to 'host/lib/usrp/usrp1')
-rw-r--r--host/lib/usrp/usrp1/dsp_impl.cpp77
-rw-r--r--host/lib/usrp/usrp1/mboard_impl.cpp34
-rw-r--r--host/lib/usrp/usrp1/usrp1_impl.hpp6
3 files changed, 73 insertions, 44 deletions
diff --git a/host/lib/usrp/usrp1/dsp_impl.cpp b/host/lib/usrp/usrp1/dsp_impl.cpp
index ba05fa6ed..573bce21f 100644
--- a/host/lib/usrp/usrp1/dsp_impl.cpp
+++ b/host/lib/usrp/usrp1/dsp_impl.cpp
@@ -21,6 +21,8 @@
#include <uhd/usrp/dsp_props.hpp>
#include <boost/bind.hpp>
#include <boost/format.hpp>
+#include <boost/lexical_cast.hpp>
+#include <boost/assign/list_of.hpp>
#include <iostream>
#include <cmath>
@@ -42,8 +44,9 @@ void usrp1_impl::rx_dsp_init(void)
/***********************************************************************
* RX DDC Get
**********************************************************************/
-void usrp1_impl::rx_dsp_get(const wax::obj &key, wax::obj &val)
-{
+void usrp1_impl::rx_dsp_get(const wax::obj &key_, wax::obj &val){
+ named_prop_t key = named_prop_t::extract(key_);
+
switch(key.as<dsp_prop_t>()){
case DSP_PROP_NAME:
val = str(boost::format("usrp1 ddc %uX %s")
@@ -57,7 +60,16 @@ void usrp1_impl::rx_dsp_get(const wax::obj &key, wax::obj &val)
return;
case DSP_PROP_FREQ_SHIFT:
- val = _rx_dsp_freq;
+ val = _rx_dsp_freqs[key.name];
+ return;
+
+ case DSP_PROP_FREQ_SHIFT_NAMES:{
+ prop_names_t names;
+ for(size_t i = 0; i < this->get_num_ddcs(); i++){
+ names.push_back(boost::lexical_cast<std::string>(i));
+ }
+ val = names;
+ }
return;
case DSP_PROP_CODEC_RATE:
@@ -76,25 +88,22 @@ void usrp1_impl::rx_dsp_get(const wax::obj &key, wax::obj &val)
/***********************************************************************
* RX DDC Set
**********************************************************************/
-void usrp1_impl::rx_dsp_set(const wax::obj &key, const wax::obj &val)
-{
+void usrp1_impl::rx_dsp_set(const wax::obj &key_, const wax::obj &val){
+ named_prop_t key = named_prop_t::extract(key_);
+
switch(key.as<dsp_prop_t>()) {
case DSP_PROP_FREQ_SHIFT: {
double new_freq = val.as<double>();
boost::uint32_t reg_word = dsp_type1::calc_cordic_word_and_update(
new_freq, _clock_ctrl->get_master_clock_freq());
- //TODO TODO TODO TODO TODO TODO TODO TODO TODO
- //
- // Handle multiple receive channels / DDC's
- //
- //TODO TODO TODO TODO TODO TODO TODO TODO TODO
- _iface->poke32(FR_RX_FREQ_0, reg_word);
- _iface->poke32(FR_RX_FREQ_1, reg_word);
- _iface->poke32(FR_RX_FREQ_2, reg_word);
- _iface->poke32(FR_RX_FREQ_3, reg_word);
-
- _rx_dsp_freq = new_freq;
+ static const uhd::dict<std::string, boost::uint32_t>
+ freq_name_to_reg_val = boost::assign::map_list_of
+ ("0", FR_RX_FREQ_0) ("1", FR_RX_FREQ_1)
+ ("2", FR_RX_FREQ_2) ("3", FR_RX_FREQ_3)
+ ;
+ _iface->poke32(freq_name_to_reg_val[key.name], reg_word);
+ _rx_dsp_freqs[key.name] = new_freq;
return;
}
case DSP_PROP_HOST_RATE: {
@@ -136,8 +145,9 @@ void usrp1_impl::tx_dsp_init(void)
/***********************************************************************
* TX DUC Get
**********************************************************************/
-void usrp1_impl::tx_dsp_get(const wax::obj &key, wax::obj &val)
-{
+void usrp1_impl::tx_dsp_get(const wax::obj &key_, wax::obj &val){
+ named_prop_t key = named_prop_t::extract(key_);
+
switch(key.as<dsp_prop_t>()) {
case DSP_PROP_NAME:
val = str(boost::format("usrp1 duc %uX %s")
@@ -151,7 +161,16 @@ void usrp1_impl::tx_dsp_get(const wax::obj &key, wax::obj &val)
return;
case DSP_PROP_FREQ_SHIFT:
- val = _tx_dsp_freq;
+ val = _tx_dsp_freqs[key.name];
+ return;
+
+ case DSP_PROP_FREQ_SHIFT_NAMES:{
+ prop_names_t names;
+ for(size_t i = 0; i < this->get_num_ducs(); i++){
+ names.push_back(boost::lexical_cast<std::string>(i));
+ }
+ val = names;
+ }
return;
case DSP_PROP_CODEC_RATE:
@@ -170,20 +189,20 @@ void usrp1_impl::tx_dsp_get(const wax::obj &key, wax::obj &val)
/***********************************************************************
* TX DUC Set
**********************************************************************/
-void usrp1_impl::tx_dsp_set(const wax::obj &key, const wax::obj &val)
-{
+void usrp1_impl::tx_dsp_set(const wax::obj &key_, const wax::obj &val){
+ named_prop_t key = named_prop_t::extract(key_);
+
switch(key.as<dsp_prop_t>()) {
- //TODO TODO TODO TODO TODO TODO TODO TODO TODO TODO TODO TODO
- //
- // Set both codec frequencies until we have duality properties
- //
- //TODO TODO TODO TODO TODO TODO TODO TODO TODO TODO TODO TODO
case DSP_PROP_FREQ_SHIFT: {
double new_freq = val.as<double>();
- _codec_ctrls[DBOARD_SLOT_A]->set_duc_freq(new_freq);
- _codec_ctrls[DBOARD_SLOT_B]->set_duc_freq(new_freq);
- _tx_dsp_freq = new_freq;
+
+ //map the freq shift key to a subdev spec to a particular codec chip
+ std::string db_name = _tx_subdev_spec.at(boost::lexical_cast<size_t>(key.name)).db_name;
+ if (db_name == "A") _codec_ctrls[DBOARD_SLOT_A]->set_duc_freq(new_freq);
+ if (db_name == "B") _codec_ctrls[DBOARD_SLOT_B]->set_duc_freq(new_freq);
+
+ _tx_dsp_freqs[key.name] = new_freq;
return;
}
diff --git a/host/lib/usrp/usrp1/mboard_impl.cpp b/host/lib/usrp/usrp1/mboard_impl.cpp
index 464a82494..e55c3685b 100644
--- a/host/lib/usrp/usrp1/mboard_impl.cpp
+++ b/host/lib/usrp/usrp1/mboard_impl.cpp
@@ -36,6 +36,8 @@
using namespace uhd;
using namespace uhd::usrp;
+static const bool usrp1_mboard_verbose = false;
+
/***********************************************************************
* Calculate the RX mux value:
* The I and Q mux values are intentionally reversed to flip I and Q
@@ -220,15 +222,13 @@ void usrp1_impl::mboard_init(void)
// Set default for TX format to 16-bit I&Q
_iface->poke32(FR_TX_FORMAT, 0x00000000);
- // TODO TODO TODO TODO TODO TODO TODO TODO TODO TODO
- //
- // Do something useful with the capabilities register
- //
- std::cout << "USRP1 Capabilities" << std::endl;
- std::cout << " number of duc's: " << get_num_ddcs() << std::endl;
- std::cout << " number of ddc's: " << get_num_ducs() << std::endl;
- std::cout << " rx halfband: " << has_rx_halfband() << std::endl;
- std::cout << " tx halfband: " << has_tx_halfband() << std::endl;
+ if (usrp1_mboard_verbose){
+ std::cout << "USRP1 Capabilities" << std::endl;
+ std::cout << " number of duc's: " << get_num_ddcs() << std::endl;
+ std::cout << " number of ddc's: " << get_num_ducs() << std::endl;
+ std::cout << " rx halfband: " << has_rx_halfband() << std::endl;
+ std::cout << " tx halfband: " << has_tx_halfband() << std::endl;
+ }
}
void usrp1_impl::issue_stream_cmd(const stream_cmd_t &stream_cmd)
@@ -362,18 +362,26 @@ void usrp1_impl::mboard_set(const wax::obj &key, const wax::obj &val)
case MBOARD_PROP_RX_SUBDEV_SPEC:
_rx_subdev_spec = val.as<subdev_spec_t>();
+ if (_rx_subdev_spec.size() > this->get_num_ddcs()){
+ throw std::runtime_error(str(boost::format(
+ "USRP1 suports up to %u RX channels.\n"
+ "However, this RX subdev spec requires %u channels\n"
+ ) % this->get_num_ddcs() % _rx_subdev_spec.size()));
+ }
verify_rx_subdev_spec(_rx_subdev_spec, _mboard_proxy->get_link());
- //sanity check
- UHD_ASSERT_THROW(_rx_subdev_spec.size() <= 2);
//set the mux and set the number of rx channels
_iface->poke32(FR_RX_MUX, calc_rx_mux(_rx_subdev_spec, _mboard_proxy->get_link()));
return;
case MBOARD_PROP_TX_SUBDEV_SPEC:
_tx_subdev_spec = val.as<subdev_spec_t>();
+ if (_tx_subdev_spec.size() > this->get_num_ducs()){
+ throw std::runtime_error(str(boost::format(
+ "USRP1 suports up to %u TX channels.\n"
+ "However, this TX subdev spec requires %u channels\n"
+ ) % this->get_num_ducs() % _tx_subdev_spec.size()));
+ }
verify_tx_subdev_spec(_tx_subdev_spec, _mboard_proxy->get_link());
- //sanity check
- UHD_ASSERT_THROW(_tx_subdev_spec.size() <= 2);
//set the mux and set the number of tx channels
_iface->poke32(FR_TX_MUX, calc_tx_mux(_tx_subdev_spec, _mboard_proxy->get_link()));
return;
diff --git a/host/lib/usrp/usrp1/usrp1_impl.hpp b/host/lib/usrp/usrp1/usrp1_impl.hpp
index 663fbb34b..f5e423654 100644
--- a/host/lib/usrp/usrp1/usrp1_impl.hpp
+++ b/host/lib/usrp/usrp1/usrp1_impl.hpp
@@ -179,14 +179,16 @@ private:
void rx_dsp_init(void);
void rx_dsp_get(const wax::obj &, wax::obj &);
void rx_dsp_set(const wax::obj &, const wax::obj &);
- double _rx_dsp_freq; size_t _rx_dsp_decim;
+ uhd::dict<std::string, double> _rx_dsp_freqs;
+ size_t _rx_dsp_decim;
wax_obj_proxy::sptr _rx_dsp_proxy;
//tx dsp functions and settings
void tx_dsp_init(void);
void tx_dsp_get(const wax::obj &, wax::obj &);
void tx_dsp_set(const wax::obj &, const wax::obj &);
- double _tx_dsp_freq; size_t _tx_dsp_interp;
+ uhd::dict<std::string, double> _tx_dsp_freqs;
+ size_t _tx_dsp_interp;
wax_obj_proxy::sptr _tx_dsp_proxy;
//transports