aboutsummaryrefslogtreecommitdiffstats
path: root/host/lib/usrp/simple_usrp.cpp
diff options
context:
space:
mode:
authorNick Foster <nick@nerdnetworks.org>2010-08-10 17:02:47 -0700
committerNick Foster <nick@nerdnetworks.org>2010-08-10 17:02:47 -0700
commit663808e847c4970551c6c8127c2c5d816e2a2014 (patch)
tree12183a2d7ea5434880dccfa414d8a378ae134abc /host/lib/usrp/simple_usrp.cpp
parent90a5d84a18aaa338092e572ff257aab1fdcc8e6b (diff)
parent9e419c7b7f35062ceb2ed4e508cadb163067593f (diff)
downloaduhd-663808e847c4970551c6c8127c2c5d816e2a2014.tar.gz
uhd-663808e847c4970551c6c8127c2c5d816e2a2014.tar.bz2
uhd-663808e847c4970551c6c8127c2c5d816e2a2014.zip
Merge branch 'master' into usrp2p
this was the merge from hell Conflicts: firmware/microblaze/Makefile.am firmware/microblaze/bootstrap firmware/microblaze/configure.ac firmware/microblaze/lib/Makefile.inc host/lib/CMakeLists.txt host/lib/usrp/mimo_usrp.cpp host/lib/usrp/simple_usrp.cpp host/lib/usrp/usrp2/clock_ctrl.cpp host/lib/usrp/usrp2/codec_impl.cpp host/lib/usrp/usrp2/dboard_impl.cpp host/lib/usrp/usrp2/mboard_impl.cpp host/lib/usrp/usrp2/usrp2_iface.hpp host/lib/usrp/usrp2/usrp2_impl.hpp host/lib/usrp/usrp2/usrp2_regs.hpp host/test/CMakeLists.txt
Diffstat (limited to 'host/lib/usrp/simple_usrp.cpp')
-rw-r--r--host/lib/usrp/simple_usrp.cpp158
1 files changed, 93 insertions, 65 deletions
diff --git a/host/lib/usrp/simple_usrp.cpp b/host/lib/usrp/simple_usrp.cpp
index a8c20c439..5b4a58805 100644
--- a/host/lib/usrp/simple_usrp.cpp
+++ b/host/lib/usrp/simple_usrp.cpp
@@ -27,6 +27,7 @@
#include <boost/foreach.hpp>
#include <boost/format.hpp>
#include <stdexcept>
+#include <iostream>
using namespace uhd;
using namespace uhd::usrp;
@@ -43,21 +44,6 @@ class simple_usrp_impl : public simple_usrp{
public:
simple_usrp_impl(const device_addr_t &addr){
_dev = device::make(addr);
- _mboard = (*_dev)[DEVICE_PROP_MBOARD];
- _rx_dsp = _mboard[MBOARD_PROP_RX_DSP];
- _tx_dsp = _mboard[MBOARD_PROP_TX_DSP];
-
- //extract rx subdevice
- _rx_dboard = _mboard[MBOARD_PROP_RX_DBOARD];
- std::string rx_subdev_in_use = _rx_dboard[DBOARD_PROP_USED_SUBDEVS].as<prop_names_t>().at(0);
- _rx_subdev = _rx_dboard[named_prop_t(DBOARD_PROP_SUBDEV, rx_subdev_in_use)];
- _rx_gain_group = _rx_dboard[named_prop_t(DBOARD_PROP_GAIN_GROUP, rx_subdev_in_use)].as<gain_group::sptr>();
-
- //extract tx subdevice
- _tx_dboard = _mboard[MBOARD_PROP_TX_DBOARD];
- std::string tx_subdev_in_use = _tx_dboard[DBOARD_PROP_USED_SUBDEVS].as<prop_names_t>().at(0);
- _tx_subdev = _tx_dboard[named_prop_t(DBOARD_PROP_SUBDEV, tx_subdev_in_use)];
- _tx_gain_group = _tx_dboard[named_prop_t(DBOARD_PROP_GAIN_GROUP, tx_subdev_in_use)].as<gain_group::sptr>();
}
~simple_usrp_impl(void){
@@ -81,13 +67,13 @@ public:
" TX Subdev: %s\n"
)
% (*_dev)[DEVICE_PROP_NAME].as<std::string>()
- % _mboard[MBOARD_PROP_NAME].as<std::string>()
- % _rx_dsp[DSP_PROP_NAME].as<std::string>()
- % _rx_dboard[DBOARD_PROP_NAME].as<std::string>()
- % _rx_subdev[SUBDEV_PROP_NAME].as<std::string>()
- % _tx_dsp[DSP_PROP_NAME].as<std::string>()
- % _tx_dboard[DBOARD_PROP_NAME].as<std::string>()
- % _tx_subdev[SUBDEV_PROP_NAME].as<std::string>()
+ % _mboard()[MBOARD_PROP_NAME].as<std::string>()
+ % _rx_dsp()[DSP_PROP_NAME].as<std::string>()
+ % _rx_dboard()[DBOARD_PROP_NAME].as<std::string>()
+ % _rx_subdev()[SUBDEV_PROP_NAME].as<std::string>()
+ % _tx_dsp()[DSP_PROP_NAME].as<std::string>()
+ % _tx_dboard()[DBOARD_PROP_NAME].as<std::string>()
+ % _tx_subdev()[SUBDEV_PROP_NAME].as<std::string>()
);
}
@@ -95,137 +81,155 @@ public:
* Misc
******************************************************************/
time_spec_t get_time_now(void){
- return _mboard[MBOARD_PROP_TIME_NOW].as<time_spec_t>();
+ return _mboard()[MBOARD_PROP_TIME_NOW].as<time_spec_t>();
}
void set_time_now(const time_spec_t &time_spec){
- _mboard[MBOARD_PROP_TIME_NOW] = time_spec;
+ _mboard()[MBOARD_PROP_TIME_NOW] = time_spec;
}
void set_time_next_pps(const time_spec_t &time_spec){
- _mboard[MBOARD_PROP_TIME_NEXT_PPS] = time_spec;
+ _mboard()[MBOARD_PROP_TIME_NEXT_PPS] = time_spec;
}
void issue_stream_cmd(const stream_cmd_t &stream_cmd){
- _mboard[MBOARD_PROP_STREAM_CMD] = stream_cmd;
+ _mboard()[MBOARD_PROP_STREAM_CMD] = stream_cmd;
}
void set_clock_config(const clock_config_t &clock_config){
- _mboard[MBOARD_PROP_CLOCK_CONFIG] = clock_config;
+ _mboard()[MBOARD_PROP_CLOCK_CONFIG] = clock_config;
}
/*******************************************************************
* RX methods
******************************************************************/
+ void set_rx_subdev_spec(const subdev_spec_t &spec){
+ _mboard()[MBOARD_PROP_RX_SUBDEV_SPEC] = spec;
+ std::cout << "RX " << _mboard()[MBOARD_PROP_RX_SUBDEV_SPEC].as<subdev_spec_t>().to_pp_string() << std::endl;
+ }
+
+ subdev_spec_t get_rx_subdev_spec(void){
+ return _mboard()[MBOARD_PROP_RX_SUBDEV_SPEC].as<subdev_spec_t>();
+ }
+
void set_rx_rate(double rate){
- _rx_dsp[DSP_PROP_HOST_RATE] = rate;
+ _rx_dsp()[DSP_PROP_HOST_RATE] = rate;
}
double get_rx_rate(void){
- return _rx_dsp[DSP_PROP_HOST_RATE].as<double>();
+ return _rx_dsp()[DSP_PROP_HOST_RATE].as<double>();
}
tune_result_t set_rx_freq(double target_freq){
- return tune_rx_subdev_and_dsp(_rx_subdev, _rx_dsp, target_freq);
+ return tune_rx_subdev_and_dsp(_rx_subdev(), _rx_dsp(), target_freq);
}
tune_result_t set_rx_freq(double target_freq, double lo_off){
- return tune_rx_subdev_and_dsp(_rx_subdev, _rx_dsp, target_freq, lo_off);
+ return tune_rx_subdev_and_dsp(_rx_subdev(), _rx_dsp(), target_freq, lo_off);
}
double get_rx_freq(void){
- return derive_freq_from_rx_subdev_and_dsp(_rx_subdev, _rx_dsp);
+ return derive_freq_from_rx_subdev_and_dsp(_rx_subdev(), _rx_dsp());
}
freq_range_t get_rx_freq_range(void){
- return add_dsp_shift(_rx_subdev[SUBDEV_PROP_FREQ_RANGE].as<freq_range_t>(), _rx_dsp);
+ return add_dsp_shift(_rx_subdev()[SUBDEV_PROP_FREQ_RANGE].as<freq_range_t>(), _rx_dsp());
}
void set_rx_gain(float gain){
- _rx_gain_group->set_value(gain);
+ return _rx_gain_group()->set_value(gain);
}
float get_rx_gain(void){
- return _rx_gain_group->get_value();
+ return _rx_gain_group()->get_value();
}
gain_range_t get_rx_gain_range(void){
- return _rx_gain_group->get_range();
+ return _rx_gain_group()->get_range();
}
void set_rx_antenna(const std::string &ant){
- _rx_subdev[SUBDEV_PROP_ANTENNA] = ant;
+ _rx_subdev()[SUBDEV_PROP_ANTENNA] = ant;
}
std::string get_rx_antenna(void){
- return _rx_subdev[SUBDEV_PROP_ANTENNA].as<std::string>();
+ return _rx_subdev()[SUBDEV_PROP_ANTENNA].as<std::string>();
}
std::vector<std::string> get_rx_antennas(void){
- return _rx_subdev[SUBDEV_PROP_ANTENNA_NAMES].as<prop_names_t>();
+ return _rx_subdev()[SUBDEV_PROP_ANTENNA_NAMES].as<prop_names_t>();
}
bool get_rx_lo_locked(void){
- return _rx_subdev[SUBDEV_PROP_LO_LOCKED].as<bool>();
+ return _rx_subdev()[SUBDEV_PROP_LO_LOCKED].as<bool>();
}
float read_rssi(void){
- return _rx_subdev[SUBDEV_PROP_RSSI].as<float>();
+ return _rx_subdev()[SUBDEV_PROP_RSSI].as<float>();
}
/*******************************************************************
* TX methods
******************************************************************/
+ void set_tx_subdev_spec(const subdev_spec_t &spec){
+ _mboard()[MBOARD_PROP_TX_SUBDEV_SPEC] = spec;
+ std::cout << "TX " << _mboard()[MBOARD_PROP_TX_SUBDEV_SPEC].as<subdev_spec_t>().to_pp_string() << std::endl;
+ }
+
+ subdev_spec_t get_tx_subdev_spec(void){
+ return _mboard()[MBOARD_PROP_TX_SUBDEV_SPEC].as<subdev_spec_t>();
+ }
+
void set_tx_rate(double rate){
- _tx_dsp[DSP_PROP_HOST_RATE] = rate;
+ _tx_dsp()[DSP_PROP_HOST_RATE] = rate;
}
double get_tx_rate(void){
- return _tx_dsp[DSP_PROP_HOST_RATE].as<double>();
+ return _tx_dsp()[DSP_PROP_HOST_RATE].as<double>();
}
tune_result_t set_tx_freq(double target_freq){
- return tune_tx_subdev_and_dsp(_tx_subdev, _tx_dsp, target_freq);
+ return tune_tx_subdev_and_dsp(_tx_subdev(), _tx_dsp(), target_freq);
}
tune_result_t set_tx_freq(double target_freq, double lo_off){
- return tune_tx_subdev_and_dsp(_tx_subdev, _tx_dsp, target_freq, lo_off);
+ return tune_tx_subdev_and_dsp(_tx_subdev(), _tx_dsp(), target_freq, lo_off);
}
double get_tx_freq(void){
- return derive_freq_from_tx_subdev_and_dsp(_tx_subdev, _tx_dsp);
+ return derive_freq_from_tx_subdev_and_dsp(_tx_subdev(), _tx_dsp());
}
freq_range_t get_tx_freq_range(void){
- return add_dsp_shift(_tx_subdev[SUBDEV_PROP_FREQ_RANGE].as<freq_range_t>(), _tx_dsp);
+ return add_dsp_shift(_tx_subdev()[SUBDEV_PROP_FREQ_RANGE].as<freq_range_t>(), _tx_dsp());
}
void set_tx_gain(float gain){
- _tx_gain_group->set_value(gain);
+ return _tx_gain_group()->set_value(gain);
}
float get_tx_gain(void){
- return _tx_gain_group->get_value();
+ return _tx_gain_group()->get_value();
}
gain_range_t get_tx_gain_range(void){
- return _tx_gain_group->get_range();
+ return _tx_gain_group()->get_range();
}
void set_tx_antenna(const std::string &ant){
- _tx_subdev[SUBDEV_PROP_ANTENNA] = ant;
+ _tx_subdev()[SUBDEV_PROP_ANTENNA] = ant;
}
std::string get_tx_antenna(void){
- return _tx_subdev[SUBDEV_PROP_ANTENNA].as<std::string>();
+ return _tx_subdev()[SUBDEV_PROP_ANTENNA].as<std::string>();
}
std::vector<std::string> get_tx_antennas(void){
- return _tx_subdev[SUBDEV_PROP_ANTENNA_NAMES].as<prop_names_t>();
+ return _tx_subdev()[SUBDEV_PROP_ANTENNA_NAMES].as<prop_names_t>();
}
bool get_tx_lo_locked(void){
- return _tx_subdev[SUBDEV_PROP_LO_LOCKED].as<bool>();
+ return _tx_subdev()[SUBDEV_PROP_LO_LOCKED].as<bool>();
}
/*******************************************************************
@@ -233,24 +237,48 @@ public:
******************************************************************/
wax::obj get_rx_dboard_iface(void) {
- return _rx_dboard;
+ return _rx_dboard();
}
wax::obj get_tx_dboard_iface(void) {
- return _tx_dboard;
+ return _tx_dboard();
}
private:
device::sptr _dev;
- wax::obj _mboard;
- wax::obj _rx_dsp;
- wax::obj _tx_dsp;
- wax::obj _rx_dboard;
- wax::obj _tx_dboard;
- wax::obj _rx_subdev;
- wax::obj _tx_subdev;
- gain_group::sptr _rx_gain_group;
- gain_group::sptr _tx_gain_group;
+ wax::obj _mboard(void){
+ return (*_dev)[DEVICE_PROP_MBOARD];
+ }
+ wax::obj _rx_dsp(void){
+ return _mboard()[MBOARD_PROP_RX_DSP];
+ }
+ wax::obj _tx_dsp(void){
+ return _mboard()[MBOARD_PROP_TX_DSP];
+ }
+ wax::obj _rx_dboard(void){
+ std::string db_name = _mboard()[MBOARD_PROP_RX_SUBDEV_SPEC].as<subdev_spec_t>().front().db_name;
+ return _mboard()[named_prop_t(MBOARD_PROP_RX_DBOARD, db_name)];
+ }
+ wax::obj _tx_dboard(void){
+ std::string db_name = _mboard()[MBOARD_PROP_TX_SUBDEV_SPEC].as<subdev_spec_t>().front().db_name;
+ return _mboard()[named_prop_t(MBOARD_PROP_TX_DBOARD, db_name)];
+ }
+ wax::obj _rx_subdev(void){
+ std::string sd_name = _mboard()[MBOARD_PROP_RX_SUBDEV_SPEC].as<subdev_spec_t>().front().sd_name;
+ return _rx_dboard()[named_prop_t(DBOARD_PROP_SUBDEV, sd_name)];
+ }
+ wax::obj _tx_subdev(void){
+ std::string sd_name = _mboard()[MBOARD_PROP_TX_SUBDEV_SPEC].as<subdev_spec_t>().front().sd_name;
+ return _tx_dboard()[named_prop_t(DBOARD_PROP_SUBDEV, sd_name)];
+ }
+ gain_group::sptr _rx_gain_group(void){
+ std::string sd_name = _mboard()[MBOARD_PROP_RX_SUBDEV_SPEC].as<subdev_spec_t>().front().sd_name;
+ return _rx_dboard()[named_prop_t(DBOARD_PROP_GAIN_GROUP, sd_name)].as<gain_group::sptr>();
+ }
+ gain_group::sptr _tx_gain_group(void){
+ std::string sd_name = _mboard()[MBOARD_PROP_TX_SUBDEV_SPEC].as<subdev_spec_t>().front().sd_name;
+ return _tx_dboard()[named_prop_t(DBOARD_PROP_GAIN_GROUP, sd_name)].as<gain_group::sptr>();
+ }
};
/***********************************************************************