summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJosh Blum <josh@joshknows.com>2010-08-15 12:40:37 -0700
committerJosh Blum <josh@joshknows.com>2010-08-15 12:40:37 -0700
commit2e978d8835b8f954b7c34c42138b64d3a5767f81 (patch)
tree22a6c6c94afa59697249fbc641cf398fe6c0b110
parenta8a4d6c0c81cdb7d7577b9e696a18580717d0324 (diff)
downloaduhd-2e978d8835b8f954b7c34c42138b64d3a5767f81.tar.gz
uhd-2e978d8835b8f954b7c34c42138b64d3a5767f81.tar.bz2
uhd-2e978d8835b8f954b7c34c42138b64d3a5767f81.zip
usrp1: compiling off next branch
made usb checking changes implemented named_prop_t::extract change copied the remainder of the codec pga gain control
-rw-r--r--host/lib/transport/CMakeLists.txt1
-rw-r--r--host/lib/transport/libusb1_control.cpp14
-rw-r--r--host/lib/usrp/usrp1/CMakeLists.txt56
-rw-r--r--host/lib/usrp/usrp1/codec_ctrl.cpp8
-rw-r--r--host/lib/usrp/usrp1/codec_ctrl.hpp16
-rw-r--r--host/lib/usrp/usrp1/codec_impl.cpp33
-rw-r--r--host/lib/usrp/usrp1/dboard_iface.cpp7
-rw-r--r--host/lib/usrp/usrp1/dboard_impl.cpp14
-rw-r--r--host/lib/usrp/usrp1/mboard_impl.cpp12
-rw-r--r--host/lib/usrp/usrp1/usrp1_impl.cpp5
10 files changed, 98 insertions, 68 deletions
diff --git a/host/lib/transport/CMakeLists.txt b/host/lib/transport/CMakeLists.txt
index d6e1ff7ba..627d2d806 100644
--- a/host/lib/transport/CMakeLists.txt
+++ b/host/lib/transport/CMakeLists.txt
@@ -30,6 +30,7 @@ IF(LIBUSB_FOUND)
${CMAKE_SOURCE_DIR}/lib/transport/libusb1_control.cpp
${CMAKE_SOURCE_DIR}/lib/transport/libusb1_zero_copy.cpp
)
+ SET(HAVE_USB_SUPPORT TRUE)
ENDIF(LIBUSB_FOUND)
########################################################################
diff --git a/host/lib/transport/libusb1_control.cpp b/host/lib/transport/libusb1_control.cpp
index 2903d943d..c2f7060e8 100644
--- a/host/lib/transport/libusb1_control.cpp
+++ b/host/lib/transport/libusb1_control.cpp
@@ -16,10 +16,10 @@
//
#include <uhd/types/usb_descriptor.hpp>
-#include <uhd/utils/exception.hpp>
#include <uhd/transport/usb_control.hpp>
#include <libusb-1.0/libusb.h>
#include <boost/asio.hpp>
+#include <stdexcept>
#include <iostream>
using namespace uhd::transport;
@@ -61,15 +61,15 @@ libusb_control_impl::libusb_control_impl(uhd::usb_descriptor_t descriptor)
: _descriptor(descriptor), _ctx(NULL), _dev_handle(NULL)
{
if (libusb_init(&_ctx) < 0)
- UHD_THROW_SITE_INFO("USB: failed to initialize libusb");
+ throw std::runtime_error("USB: failed to initialize libusb");
libusb_set_debug(_ctx, libusb_debug_level);
if (!open_device())
- UHD_THROW_SITE_INFO("USB: failed to open device");
+ throw std::runtime_error("USB: failed to open device");
if (!open_interface())
- UHD_THROW_SITE_INFO("USB: failed to open device interface");
+ throw std::runtime_error("USB: failed to open device interface");
}
@@ -85,7 +85,7 @@ uhd::usb_descriptor_t libusb_control_impl::create_descriptor(libusb_device *dev)
libusb_device_descriptor desc;
if (libusb_get_device_descriptor(dev, &desc) < 0)
- UHD_THROW_SITE_INFO("USB: failed to get device descriptor");
+ throw std::runtime_error("USB: failed to get device descriptor");
uhd::usb_descriptor_t descriptor;
@@ -217,12 +217,12 @@ uhd::usb_descriptors_t usb_control::get_device_list()
uhd::usb_descriptors_t descriptors;
if (libusb_init(NULL) < 0)
- UHD_THROW_SITE_INFO("USB: failed to initialize libusb");
+ throw std::runtime_error("USB: failed to initialize libusb");
ssize_t cnt = libusb_get_device_list(NULL, &list);
if (cnt < 0)
- UHD_THROW_SITE_INFO("USB: failed to get device list");
+ throw std::runtime_error("USB: failed to get device list");
ssize_t i = 0;
for (i = 0; i < cnt; i++) {
diff --git a/host/lib/usrp/usrp1/CMakeLists.txt b/host/lib/usrp/usrp1/CMakeLists.txt
index eb7bd4b06..229a4ce63 100644
--- a/host/lib/usrp/usrp1/CMakeLists.txt
+++ b/host/lib/usrp/usrp1/CMakeLists.txt
@@ -17,23 +17,41 @@
#This file will be included by cmake, use absolute paths!
-INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/../firmware/fx2/include)
+########################################################################
+# Conditionally configure the USRP1 support
+########################################################################
+MESSAGE(STATUS "Configuring usrp1 support...")
-LIBUHD_APPEND_SOURCES(
- ${CMAKE_SOURCE_DIR}/lib/usrp/usrp1/clock_ctrl.cpp
- ${CMAKE_SOURCE_DIR}/lib/usrp/usrp1/clock_ctrl.hpp
- ${CMAKE_SOURCE_DIR}/lib/usrp/usrp1/codec_ctrl.cpp
- ${CMAKE_SOURCE_DIR}/lib/usrp/usrp1/codec_ctrl.hpp
- ${CMAKE_SOURCE_DIR}/lib/usrp/usrp1/codec_impl.cpp
- ${CMAKE_SOURCE_DIR}/lib/usrp/usrp1/dboard_impl.cpp
- ${CMAKE_SOURCE_DIR}/lib/usrp/usrp1/dboard_iface.cpp
- ${CMAKE_SOURCE_DIR}/lib/usrp/usrp1/dsp_impl.cpp
- ${CMAKE_SOURCE_DIR}/lib/usrp/usrp1/io_impl.cpp
- ${CMAKE_SOURCE_DIR}/lib/usrp/usrp1/mboard_impl.cpp
- ${CMAKE_SOURCE_DIR}/lib/usrp/usrp1/usrp1_iface.cpp
- ${CMAKE_SOURCE_DIR}/lib/usrp/usrp1/usrp1_iface.hpp
- ${CMAKE_SOURCE_DIR}/lib/usrp/usrp1/usrp1_impl.cpp
- ${CMAKE_SOURCE_DIR}/lib/usrp/usrp1/usrp1_impl.hpp
- ${CMAKE_SOURCE_DIR}/lib/usrp/usrp1/usrp1_ctrl.cpp
- ${CMAKE_SOURCE_DIR}/lib/usrp/usrp1/usrp1_ctrl.hpp
-)
+IF(HAVE_USB_SUPPORT)
+ MESSAGE(STATUS "Has USB support - found")
+ELSE(HAVE_USB_SUPPORT)
+ MESSAGE(STATUS "Has USB support - not found")
+ENDIF(HAVE_USB_SUPPORT)
+
+#TODO check for usrp1 enable/disable option flag
+
+IF(HAVE_USB_SUPPORT)
+ MESSAGE(STATUS " Building usrp1 support.")
+ INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/../firmware/fx2/include)
+
+ LIBUHD_APPEND_SOURCES(
+ ${CMAKE_SOURCE_DIR}/lib/usrp/usrp1/clock_ctrl.cpp
+ ${CMAKE_SOURCE_DIR}/lib/usrp/usrp1/clock_ctrl.hpp
+ ${CMAKE_SOURCE_DIR}/lib/usrp/usrp1/codec_ctrl.cpp
+ ${CMAKE_SOURCE_DIR}/lib/usrp/usrp1/codec_ctrl.hpp
+ ${CMAKE_SOURCE_DIR}/lib/usrp/usrp1/codec_impl.cpp
+ ${CMAKE_SOURCE_DIR}/lib/usrp/usrp1/dboard_impl.cpp
+ ${CMAKE_SOURCE_DIR}/lib/usrp/usrp1/dboard_iface.cpp
+ ${CMAKE_SOURCE_DIR}/lib/usrp/usrp1/dsp_impl.cpp
+ ${CMAKE_SOURCE_DIR}/lib/usrp/usrp1/io_impl.cpp
+ ${CMAKE_SOURCE_DIR}/lib/usrp/usrp1/mboard_impl.cpp
+ ${CMAKE_SOURCE_DIR}/lib/usrp/usrp1/usrp1_iface.cpp
+ ${CMAKE_SOURCE_DIR}/lib/usrp/usrp1/usrp1_iface.hpp
+ ${CMAKE_SOURCE_DIR}/lib/usrp/usrp1/usrp1_impl.cpp
+ ${CMAKE_SOURCE_DIR}/lib/usrp/usrp1/usrp1_impl.hpp
+ ${CMAKE_SOURCE_DIR}/lib/usrp/usrp1/usrp1_ctrl.cpp
+ ${CMAKE_SOURCE_DIR}/lib/usrp/usrp1/usrp1_ctrl.hpp
+ )
+ELSE(HAVE_USB_SUPPORT)
+ MESSAGE(STATUS " Skipping usrp1 support.")
+ENDIF(HAVE_USB_SUPPORT)
diff --git a/host/lib/usrp/usrp1/codec_ctrl.cpp b/host/lib/usrp/usrp1/codec_ctrl.cpp
index 866650c2c..d0576a769 100644
--- a/host/lib/usrp/usrp1/codec_ctrl.cpp
+++ b/host/lib/usrp/usrp1/codec_ctrl.cpp
@@ -25,12 +25,12 @@
#include <uhd/utils/algorithm.hpp>
#include <uhd/utils/byteswap.hpp>
#include <boost/cstdint.hpp>
+#include <boost/format.hpp>
#include <boost/tuple/tuple.hpp>
#include <boost/math/special_functions/round.hpp>
#include <boost/assign/list_of.hpp>
#include <iostream>
#include <iomanip>
-#include <cstdio>
using namespace uhd;
@@ -335,9 +335,9 @@ unsigned int usrp1_codec_ctrl_impl::compute_freq_control_word_9862(
int v = (int) rint (fabs (target_freq) / master_freq * pow (2.0, 24.0));
*actual_freq = v * master_freq / pow (2.0, 24.0) * sign;
- fprintf(stdout,
- "compute_freq_control_word_9862: target = %g actual = %g delta = %g v = %8d\n",
- target_freq, *actual_freq, *actual_freq - target_freq, v);
+ std::cout << boost::format(
+ "compute_freq_control_word_9862: target = %g actual = %g delta = %g v = %8d\n"
+ ) % target_freq % *actual_freq % (*actual_freq - target_freq) % v;
return (unsigned int) v;
}
diff --git a/host/lib/usrp/usrp1/codec_ctrl.hpp b/host/lib/usrp/usrp1/codec_ctrl.hpp
index 51e29345a..0605e3228 100644
--- a/host/lib/usrp/usrp1/codec_ctrl.hpp
+++ b/host/lib/usrp/usrp1/codec_ctrl.hpp
@@ -19,6 +19,7 @@
#define INCLUDED_USRP1_CODEC_CTRL_HPP
#include "usrp1_iface.hpp"
+#include <uhd/types/ranges.hpp>
#include <boost/shared_ptr.hpp>
#include <boost/utility.hpp>
@@ -31,6 +32,9 @@ class usrp1_codec_ctrl : boost::noncopyable{
public:
typedef boost::shared_ptr<usrp1_codec_ctrl> sptr;
+ static const uhd::gain_range_t tx_pga_gain_range;
+ static const uhd::gain_range_t rx_pga_gain_range;
+
/*!
* Make a new clock control object.
* \param iface the usrp1 iface object
@@ -70,6 +74,18 @@ public:
*/
virtual void write_aux_dac(aux_dac_t which, float volts) = 0;
+ //! Set the TX PGA gain
+ virtual void set_tx_pga_gain(float gain) = 0;
+
+ //! Get the TX PGA gain
+ virtual float get_tx_pga_gain(void) = 0;
+
+ //! Set the RX PGA gain ('A' or 'B')
+ virtual void set_rx_pga_gain(float gain, char which) = 0;
+
+ //! Get the RX PGA gain ('A' or 'B')
+ virtual float get_rx_pga_gain(char which) = 0;
+
virtual bool set_duc_freq(double freq) = 0;
};
diff --git a/host/lib/usrp/usrp1/codec_impl.cpp b/host/lib/usrp/usrp1/codec_impl.cpp
index 9253c06ba..7bf5631fb 100644
--- a/host/lib/usrp/usrp1/codec_impl.cpp
+++ b/host/lib/usrp/usrp1/codec_impl.cpp
@@ -16,6 +16,7 @@
//
#include "usrp1_impl.hpp"
+#include <uhd/utils/assert.hpp>
#include <uhd/usrp/codec_props.hpp>
#include <boost/bind.hpp>
@@ -44,8 +45,7 @@ static const std::string ad9862_pga_gain_name = "ad9862 pga";
void usrp1_impl::rx_codec_get(const wax::obj &key_, wax::obj &val)
{
- wax::obj key; std::string name;
- boost::tie(key, name) = extract_named_prop(key_);
+ named_prop_t key = named_prop_t::extract(key_);
//handle the get request conditioned on the key
switch(key.as<codec_prop_t>()) {
@@ -62,17 +62,17 @@ void usrp1_impl::rx_codec_get(const wax::obj &key_, wax::obj &val)
return;
case CODEC_PROP_GAIN_RANGE:
- UHD_ASSERT_THROW(name == ad9862_pga_gain_name);
+ UHD_ASSERT_THROW(key.name == ad9862_pga_gain_name);
val = usrp1_codec_ctrl::rx_pga_gain_range;
return;
case CODEC_PROP_GAIN_I:
- UHD_ASSERT_THROW(name == ad9862_pga_gain_name);
+ UHD_ASSERT_THROW(key.name == ad9862_pga_gain_name);
val = _codec_ctrl->get_rx_pga_gain('A');
return;
case CODEC_PROP_GAIN_Q:
- UHD_ASSERT_THROW(name == ad9862_pga_gain_name);
+ UHD_ASSERT_THROW(key.name == ad9862_pga_gain_name);
val = _codec_ctrl->get_rx_pga_gain('B');
return;
@@ -80,20 +80,19 @@ void usrp1_impl::rx_codec_get(const wax::obj &key_, wax::obj &val)
}
}
-void usrp1_impl::rx_codec_set(const wax::obj &, const wax::obj &)
+void usrp1_impl::rx_codec_set(const wax::obj &key_, const wax::obj &val)
{
- wax::obj key; std::string name;
- boost::tie(key, name) = extract_named_prop(key_);
+ named_prop_t key = named_prop_t::extract(key_);
//handle the set request conditioned on the key
switch(key.as<codec_prop_t>()) {
case CODEC_PROP_GAIN_I:
- UHD_ASSERT_THROW(name == ad9862_pga_gain_name);
+ UHD_ASSERT_THROW(key.name == ad9862_pga_gain_name);
_codec_ctrl->set_rx_pga_gain(val.as<float>(), 'A');
return;
case CODEC_PROP_GAIN_Q:
- UHD_ASSERT_THROW(name == ad9862_pga_gain_name);
+ UHD_ASSERT_THROW(key.name == ad9862_pga_gain_name);
_codec_ctrl->set_rx_pga_gain(val.as<float>(), 'B');
return;
@@ -106,8 +105,7 @@ void usrp1_impl::rx_codec_set(const wax::obj &, const wax::obj &)
**********************************************************************/
void usrp1_impl::tx_codec_get(const wax::obj &key_, wax::obj &val)
{
- wax::obj key; std::string name;
- boost::tie(key, name) = extract_named_prop(key_);
+ named_prop_t key = named_prop_t::extract(key_);
//handle the get request conditioned on the key
switch(key.as<codec_prop_t>()) {
@@ -124,13 +122,13 @@ void usrp1_impl::tx_codec_get(const wax::obj &key_, wax::obj &val)
return;
case CODEC_PROP_GAIN_RANGE:
- UHD_ASSERT_THROW(name == ad9862_pga_gain_name);
+ UHD_ASSERT_THROW(key.name == ad9862_pga_gain_name);
val = usrp1_codec_ctrl::tx_pga_gain_range;
return;
case CODEC_PROP_GAIN_I: //only one gain for I and Q
case CODEC_PROP_GAIN_Q:
- UHD_ASSERT_THROW(name == ad9862_pga_gain_name);
+ UHD_ASSERT_THROW(key.name == ad9862_pga_gain_name);
val = _codec_ctrl->get_tx_pga_gain();
return;
@@ -138,16 +136,15 @@ void usrp1_impl::tx_codec_get(const wax::obj &key_, wax::obj &val)
}
}
-void usrp1_impl::tx_codec_set(const wax::obj &, const wax::obj &)
+void usrp1_impl::tx_codec_set(const wax::obj &key_, const wax::obj &val)
{
- wax::obj key; std::string name;
- boost::tie(key, name) = extract_named_prop(key_);
+ named_prop_t key = named_prop_t::extract(key_);
//handle the set request conditioned on the key
switch(key.as<codec_prop_t>()){
case CODEC_PROP_GAIN_I: //only one gain for I and Q
case CODEC_PROP_GAIN_Q:
- UHD_ASSERT_THROW(name == ad9862_pga_gain_name);
+ UHD_ASSERT_THROW(key.name == ad9862_pga_gain_name);
_codec_ctrl->set_tx_pga_gain(val.as<float>());
return;
diff --git a/host/lib/usrp/usrp1/dboard_iface.cpp b/host/lib/usrp/usrp1/dboard_iface.cpp
index 11ad3fe8a..ef6a1e67b 100644
--- a/host/lib/usrp/usrp1/dboard_iface.cpp
+++ b/host/lib/usrp/usrp1/dboard_iface.cpp
@@ -51,9 +51,12 @@ public:
/* NOP */
}
- std::string get_mboard_name()
+ special_props_t get_special_props()
{
- return "usrp1";
+ special_props_t props;
+ props.soft_clock_divider = true;
+ props.mangle_i2c_addrs = false; //TODO true on side B
+ return props;
}
void write_aux_dac(unit_t, aux_dac_t, float);
diff --git a/host/lib/usrp/usrp1/dboard_impl.cpp b/host/lib/usrp/usrp1/dboard_impl.cpp
index 4f2836ea9..9df87432d 100644
--- a/host/lib/usrp/usrp1/dboard_impl.cpp
+++ b/host/lib/usrp/usrp1/dboard_impl.cpp
@@ -82,8 +82,7 @@ void usrp1_impl::dboard_init(void)
**********************************************************************/
void usrp1_impl::rx_dboard_get(const wax::obj &key_, wax::obj &val)
{
- wax::obj key; std::string name;
- boost::tie(key, name) = extract_named_prop(key_);
+ named_prop_t key = named_prop_t::extract(key_);
//handle the get request conditioned on the key
switch(key.as<dboard_prop_t>()){
@@ -92,7 +91,7 @@ void usrp1_impl::rx_dboard_get(const wax::obj &key_, wax::obj &val)
return;
case DBOARD_PROP_SUBDEV:
- val = _dboard_manager->get_rx_subdev(name);
+ val = _dboard_manager->get_rx_subdev(key.name);
return;
case DBOARD_PROP_SUBDEV_NAMES:
@@ -112,7 +111,7 @@ void usrp1_impl::rx_dboard_get(const wax::obj &key_, wax::obj &val)
return;
case DBOARD_PROP_GAIN_GROUP:
- val = make_gain_group(_dboard_manager->get_rx_subdev(name),
+ val = make_gain_group(_dboard_manager->get_rx_subdev(key.name),
_rx_codec_proxy->get_link());
return;
@@ -142,8 +141,7 @@ void usrp1_impl::rx_dboard_set(const wax::obj &key, const wax::obj &val)
**********************************************************************/
void usrp1_impl::tx_dboard_get(const wax::obj &key_, wax::obj &val)
{
- wax::obj key; std::string name;
- boost::tie(key, name) = extract_named_prop(key_);
+ named_prop_t key = named_prop_t::extract(key_);
//handle the get request conditioned on the key
switch(key.as<dboard_prop_t>()){
@@ -152,7 +150,7 @@ void usrp1_impl::tx_dboard_get(const wax::obj &key_, wax::obj &val)
return;
case DBOARD_PROP_SUBDEV:
- val = _dboard_manager->get_tx_subdev(name);
+ val = _dboard_manager->get_tx_subdev(key.name);
return;
case DBOARD_PROP_SUBDEV_NAMES:
@@ -172,7 +170,7 @@ void usrp1_impl::tx_dboard_get(const wax::obj &key_, wax::obj &val)
return;
case DBOARD_PROP_GAIN_GROUP:
- val = make_gain_group(_dboard_manager->get_tx_subdev(name),
+ val = make_gain_group(_dboard_manager->get_tx_subdev(key.name),
_tx_codec_proxy->get_link());
return;
diff --git a/host/lib/usrp/usrp1/mboard_impl.cpp b/host/lib/usrp/usrp1/mboard_impl.cpp
index ee1ba305b..2514072e0 100644
--- a/host/lib/usrp/usrp1/mboard_impl.cpp
+++ b/host/lib/usrp/usrp1/mboard_impl.cpp
@@ -111,9 +111,7 @@ void usrp1_impl::issue_stream_cmd(const stream_cmd_t &stream_cmd)
**********************************************************************/
void usrp1_impl::mboard_get(const wax::obj &key_, wax::obj &val)
{
- wax::obj key;
- std::string name;
- boost::tie(key, name) = extract_named_prop(key_);
+ named_prop_t key = named_prop_t::extract(key_);
//handle the get request conditioned on the key
switch(key.as<mboard_prop_t>()){
@@ -126,7 +124,7 @@ void usrp1_impl::mboard_get(const wax::obj &key_, wax::obj &val)
return;
case MBOARD_PROP_RX_DBOARD:
- UHD_ASSERT_THROW(name == "");
+ UHD_ASSERT_THROW(key.name == "");
val = _rx_dboard_proxy->get_link();
return;
@@ -135,7 +133,7 @@ void usrp1_impl::mboard_get(const wax::obj &key_, wax::obj &val)
return;
case MBOARD_PROP_TX_DBOARD:
- UHD_ASSERT_THROW(name == "");
+ UHD_ASSERT_THROW(key.name == "");
val = _tx_dboard_proxy->get_link();
return;
@@ -144,7 +142,7 @@ void usrp1_impl::mboard_get(const wax::obj &key_, wax::obj &val)
return;
case MBOARD_PROP_RX_DSP:
- UHD_ASSERT_THROW(name == "");
+ UHD_ASSERT_THROW(key.name == "");
val = _rx_ddc_proxy->get_link();
return;
@@ -153,7 +151,7 @@ void usrp1_impl::mboard_get(const wax::obj &key_, wax::obj &val)
return;
case MBOARD_PROP_TX_DSP:
- UHD_ASSERT_THROW(name == "");
+ UHD_ASSERT_THROW(key.name == "");
val = _tx_duc_proxy->get_link();
return;
diff --git a/host/lib/usrp/usrp1/usrp1_impl.cpp b/host/lib/usrp/usrp1/usrp1_impl.cpp
index 4cb286354..1435b981c 100644
--- a/host/lib/usrp/usrp1/usrp1_impl.cpp
+++ b/host/lib/usrp/usrp1/usrp1_impl.cpp
@@ -165,8 +165,7 @@ usrp1_impl::~usrp1_impl(void){
**********************************************************************/
void usrp1_impl::get(const wax::obj &key_, wax::obj &val)
{
- wax::obj key; std::string name;
- boost::tie(key, name) = extract_named_prop(key_);
+ named_prop_t key = named_prop_t::extract(key_);
//handle the get request conditioned on the key
switch(key.as<device_prop_t>()){
@@ -175,7 +174,7 @@ void usrp1_impl::get(const wax::obj &key_, wax::obj &val)
return;
case DEVICE_PROP_MBOARD:
- UHD_ASSERT_THROW(name == "");
+ UHD_ASSERT_THROW(key.name == "");
val = _mboard_proxy->get_link();
return;