summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJosh Blum <josh@joshknows.com>2010-03-16 13:49:39 -0700
committerJosh Blum <josh@joshknows.com>2010-03-16 13:49:39 -0700
commit8be3b883f5b1a889f4f07611e8954449cc07c2b3 (patch)
tree0622e8702105a6e43569b902b16700a0072d4cbd
parentfc40ff2f1327d01c72c4d7dbc07a14e473251981 (diff)
downloaduhd-8be3b883f5b1a889f4f07611e8954449cc07c2b3.tar.gz
uhd-8be3b883f5b1a889f4f07611e8954449cc07c2b3.tar.bz2
uhd-8be3b883f5b1a889f4f07611e8954449cc07c2b3.zip
Added ability to set the subdevices in use for rx and tx dboards.
This is used to calculate and set the ddc and duc muxes. Also, minor fix for burning addrs (wrong pointer....)
-rw-r--r--firmware/microblaze/apps/txrx.c11
-rw-r--r--firmware/microblaze/lib/ethernet.c4
-rw-r--r--host/include/uhd/props.hpp7
-rw-r--r--host/lib/usrp/dboard/basic.cpp2
-rw-r--r--host/lib/usrp/dboard_manager.cpp4
-rw-r--r--host/lib/usrp/usrp2/dboard_impl.cpp82
-rw-r--r--host/lib/usrp/usrp2/dboard_interface.cpp39
-rw-r--r--host/lib/usrp/usrp2/dboard_interface.hpp63
-rw-r--r--host/lib/usrp/usrp2/fw_common.h7
-rw-r--r--host/lib/usrp/usrp2/usrp2_impl.hpp12
10 files changed, 141 insertions, 90 deletions
diff --git a/firmware/microblaze/apps/txrx.c b/firmware/microblaze/apps/txrx.c
index 97376ffbd..8949f1263 100644
--- a/firmware/microblaze/apps/txrx.c
+++ b/firmware/microblaze/apps/txrx.c
@@ -427,7 +427,6 @@ void handle_udp_ctrl_packet(
case USRP2_CTRL_ID_SETUP_THIS_DDC_FOR_ME_BRO:
dsp_rx_regs->freq = ctrl_data_in->data.ddc_args.freq_word;
dsp_rx_regs->scale_iq = ctrl_data_in->data.ddc_args.scale_iq;
- dsp_rx_regs->rx_mux = 0x00 | (0x01 << 2); //TODO fill in from control
//setup the interp and half band filters
{
@@ -471,7 +470,6 @@ void handle_udp_ctrl_packet(
case USRP2_CTRL_ID_SETUP_THIS_DUC_FOR_ME_BRO:
dsp_tx_regs->freq = ctrl_data_in->data.duc_args.freq_word;
dsp_tx_regs->scale_iq = ctrl_data_in->data.duc_args.scale_iq;
- dsp_tx_regs->tx_mux = 0x01; //TODO fill in from control
//setup the interp and half band filters
{
@@ -504,6 +502,15 @@ void handle_udp_ctrl_packet(
ctrl_data_out.id = USRP2_CTRL_ID_SWEET_I_GOT_THAT_TIME_DUDE;
break;
+ /*******************************************************************
+ * MUX Config
+ ******************************************************************/
+ case USRP2_CTRL_ID_UPDATE_THOSE_MUX_SETTINGS_BRO:
+ dsp_rx_regs->rx_mux = ctrl_data_in->data.mux_args.rx_mux;
+ dsp_tx_regs->tx_mux = ctrl_data_in->data.mux_args.tx_mux;
+ ctrl_data_out.id = USRP2_CTRL_ID_UPDATED_THE_MUX_SETTINGS_DUDE;
+ break;
+
default:
ctrl_data_out.id = USRP2_CTRL_ID_HUH_WHAT;
diff --git a/firmware/microblaze/lib/ethernet.c b/firmware/microblaze/lib/ethernet.c
index 757a36ce4..0e731c68c 100644
--- a/firmware/microblaze/lib/ethernet.c
+++ b/firmware/microblaze/lib/ethernet.c
@@ -316,7 +316,7 @@ ethernet_mac_addr(void)
bool
ethernet_set_mac_addr(const eth_mac_addr_t *t)
{
- bool ok = eeprom_write(I2C_ADDR_MBOARD, MBOARD_MAC_ADDR, &t, sizeof(eth_mac_addr_t));
+ bool ok = eeprom_write(I2C_ADDR_MBOARD, MBOARD_MAC_ADDR, t, sizeof(eth_mac_addr_t));
if (ok){
src_mac_addr = *t;
src_mac_addr_initialized = true;
@@ -356,7 +356,7 @@ const struct ip_addr *get_ip_addr(void)
}
bool set_ip_addr(const struct ip_addr *t){
- bool ok = eeprom_write(I2C_ADDR_MBOARD, MBOARD_IP_ADDR, &t, sizeof(struct ip_addr));
+ bool ok = eeprom_write(I2C_ADDR_MBOARD, MBOARD_IP_ADDR, t, sizeof(struct ip_addr));
if (ok){
src_ip_addr = *t;
src_ip_addr_initialized = true;
diff --git a/host/include/uhd/props.hpp b/host/include/uhd/props.hpp
index 0dddba647..6d4414d3a 100644
--- a/host/include/uhd/props.hpp
+++ b/host/include/uhd/props.hpp
@@ -122,7 +122,8 @@ namespace uhd{
enum dboard_prop_t{
DBOARD_PROP_NAME, //ro, std::string
DBOARD_PROP_SUBDEV, //ro, wax::obj
- DBOARD_PROP_SUBDEV_NAMES //ro, prop_names_t
+ DBOARD_PROP_SUBDEV_NAMES, //ro, prop_names_t
+ DBOARD_PROP_USED_SUBDEVS //ro, prop_names_t
//DBOARD_PROP_CODEC //ro, wax::obj //----> not sure, dont have to deal with yet
};
@@ -135,9 +136,7 @@ namespace uhd{
CODEC_PROP_NAME, //ro, std::string
CODEC_PROP_OTHERS, //ro, prop_names_t
CODEC_PROP_GAIN, //rw, gain_t
- CODEC_PROP_GAIN_MAX, //ro, gain_t
- CODEC_PROP_GAIN_MIN, //ro, gain_t
- CODEC_PROP_GAIN_STEP, //ro, gain_t
+ CODEC_PROP_GAIN_RANGE, //ro, gain_range_t
CODEC_PROP_GAIN_NAMES, //ro, prop_names_t
//CODEC_PROP_CLOCK_RATE //ro, freq_t //----> not sure we care to know
};*/
diff --git a/host/lib/usrp/dboard/basic.cpp b/host/lib/usrp/dboard/basic.cpp
index 095b77ce1..5a82bf145 100644
--- a/host/lib/usrp/dboard/basic.cpp
+++ b/host/lib/usrp/dboard/basic.cpp
@@ -100,7 +100,7 @@ void basic_rx::rx_get(const wax::obj &key_, wax::obj &val){
//handle the get request conditioned on the key
switch(key.as<subdev_prop_t>()){
case SUBDEV_PROP_NAME:
- val = std::string(str(boost::format("%s:%s")
+ val = std::string(str(boost::format("%s - %s")
% dboard_id::to_string(get_rx_id())
% get_subdev_name()
));
diff --git a/host/lib/usrp/dboard_manager.cpp b/host/lib/usrp/dboard_manager.cpp
index eeabbda99..6ca15e98c 100644
--- a/host/lib/usrp/dboard_manager.cpp
+++ b/host/lib/usrp/dboard_manager.cpp
@@ -46,7 +46,7 @@ void dboard_manager::register_dboard(
//std::cout << "registering: " << name << std::endl;
if (get_id_to_args_map().has_key(dboard_id)){
throw std::runtime_error(str(boost::format(
- "The dboard id 0x%.4x is already registered to %s."
+ "The dboard id 0x%04x is already registered to %s."
) % dboard_id % dboard_id::to_string(dboard_id)));
}
get_id_to_args_map()[dboard_id] = args_t(dboard_ctor, name, subdev_names);
@@ -54,7 +54,7 @@ void dboard_manager::register_dboard(
std::string dboard_id::to_string(const dboard_id_t &id){
std::string name = (get_id_to_args_map().has_key(id))? get_id_to_args_map()[id].get<1>() : "unknown";
- return str(boost::format("%s (0x%.4x)") % name % id);
+ return str(boost::format("%s (0x%04x)") % name % id);
}
/***********************************************************************
diff --git a/host/lib/usrp/usrp2/dboard_impl.cpp b/host/lib/usrp/usrp2/dboard_impl.cpp
index 6d957436e..502a7daa0 100644
--- a/host/lib/usrp/usrp2/dboard_impl.cpp
+++ b/host/lib/usrp/usrp2/dboard_impl.cpp
@@ -18,7 +18,6 @@
#include <uhd/utils.hpp>
#include <boost/format.hpp>
#include "usrp2_impl.hpp"
-#include "dboard_interface.hpp"
using namespace uhd;
using namespace uhd::usrp;
@@ -32,23 +31,16 @@ void usrp2_impl::dboard_init(void){
out_data.id = htonl(USRP2_CTRL_ID_GIVE_ME_YOUR_DBOARD_IDS_BRO);
usrp2_ctrl_data_t in_data = ctrl_send_and_recv(out_data);
ASSERT_THROW(htonl(in_data.id) == USRP2_CTRL_ID_THESE_ARE_MY_DBOARD_IDS_DUDE);
- std::cout << boost::format("rx id 0x%.2x, tx id 0x%.2x")
- % ntohs(in_data.data.dboard_ids.rx_id)
- % ntohs(in_data.data.dboard_ids.tx_id) << std::endl;
- //extract the dboard ids an convert them to enums
- dboard_id_t rx_dboard_id = static_cast<dboard_id_t>(
- ntohs(in_data.data.dboard_ids.rx_id)
- );
- dboard_id_t tx_dboard_id = static_cast<dboard_id_t>(
- ntohs(in_data.data.dboard_ids.tx_id)
- );
+ //extract the dboard ids an convert them
+ dboard_id_t rx_dboard_id = ntohs(in_data.data.dboard_ids.rx_id);
+ dboard_id_t tx_dboard_id = ntohs(in_data.data.dboard_ids.tx_id);
//create a new dboard interface and manager
dboard_interface::sptr _dboard_interface(
- new usrp2_dboard_interface(this)
+ make_usrp2_dboard_interface(this)
);
- dboard_manager::sptr _dboard_manager = dboard_manager::make(
+ _dboard_manager = dboard_manager::make(
rx_dboard_id, tx_dboard_id, _dboard_interface
);
@@ -61,6 +53,46 @@ void usrp2_impl::dboard_init(void){
boost::bind(&usrp2_impl::tx_dboard_get, this, _1, _2),
boost::bind(&usrp2_impl::tx_dboard_set, this, _1, _2)
);
+
+ //init the subdevs in use (use the first subdevice)
+ _rx_subdevs_in_use = prop_names_t(1, _dboard_manager->get_rx_subdev_names().at(0));
+ _tx_subdevs_in_use = prop_names_t(1, _dboard_manager->get_tx_subdev_names().at(0));
+ update_mux_config();
+}
+
+void usrp2_impl::update_mux_config(void){
+ //calculate the rx mux
+ uint32_t rx_mux = 0;
+ ASSERT_THROW(_rx_subdevs_in_use.size() == 1);
+ wax::obj rx_subdev = _dboard_manager->get_rx_subdev(_rx_subdevs_in_use.at(0));
+ std::cout << "Using: " << rx_subdev[SUBDEV_PROP_NAME].as<std::string>() << std::endl;
+ if (rx_subdev[SUBDEV_PROP_QUADRATURE].as<bool>()){
+ rx_mux = (0x01 << 2) | (0x00 << 0); //Q=ADC1, I=ADC0
+ }else{
+ rx_mux = 0x00; //ADC0
+ }
+ if (rx_subdev[SUBDEV_PROP_IQ_SWAPPED].as<bool>()){
+ rx_mux = (((rx_mux >> 0) & 0x3) << 2) | (((rx_mux >> 2) & 0x3) << 0);
+ }
+
+ //calculate the tx mux
+ uint32_t tx_mux = 0x10;
+ ASSERT_THROW(_tx_subdevs_in_use.size() == 1);
+ wax::obj tx_subdev = _dboard_manager->get_tx_subdev(_tx_subdevs_in_use.at(0));
+ std::cout << "Using: " << tx_subdev[SUBDEV_PROP_NAME].as<std::string>() << std::endl;
+ if (tx_subdev[SUBDEV_PROP_IQ_SWAPPED].as<bool>()){
+ tx_mux = (((tx_mux >> 0) & 0x1) << 1) | (((tx_mux >> 1) & 0x1) << 0);
+ }
+
+ //setup the out data
+ usrp2_ctrl_data_t out_data;
+ out_data.id = htonl(USRP2_CTRL_ID_UPDATE_THOSE_MUX_SETTINGS_BRO);
+ out_data.data.mux_args.rx_mux = htonl(rx_mux);
+ out_data.data.mux_args.tx_mux = htonl(tx_mux);
+
+ //send and recv
+ usrp2_ctrl_data_t in_data = ctrl_send_and_recv(out_data);
+ ASSERT_THROW(htonl(in_data.id) == USRP2_CTRL_ID_UPDATED_THE_MUX_SETTINGS_DUDE);
}
/***********************************************************************
@@ -84,12 +116,22 @@ void usrp2_impl::rx_dboard_get(const wax::obj &key_, wax::obj &val){
val = _dboard_manager->get_rx_subdev_names();
return;
+ case DBOARD_PROP_USED_SUBDEVS:
+ val = _rx_subdevs_in_use;
+ return;
+
//case DBOARD_PROP_CODEC:
// throw std::runtime_error("unhandled prop in usrp2 dboard");
}
}
-void usrp2_impl::rx_dboard_set(const wax::obj &, const wax::obj &){
+void usrp2_impl::rx_dboard_set(const wax::obj &key, const wax::obj &val){
+ if (key.as<dboard_prop_t>() == DBOARD_PROP_USED_SUBDEVS){
+ _rx_subdevs_in_use = val.as<prop_names_t>();
+ update_mux_config(); //if the val is bad, this will throw
+ return;
+ }
+
throw std::runtime_error("Cannot set on usrp2 dboard");
}
@@ -114,11 +156,21 @@ void usrp2_impl::tx_dboard_get(const wax::obj &key_, wax::obj &val){
val = _dboard_manager->get_tx_subdev_names();
return;
+ case DBOARD_PROP_USED_SUBDEVS:
+ val = _tx_subdevs_in_use;
+ return;
+
//case DBOARD_PROP_CODEC:
// throw std::runtime_error("unhandled prop in usrp2 dboard");
}
}
-void usrp2_impl::tx_dboard_set(const wax::obj &, const wax::obj &){
+void usrp2_impl::tx_dboard_set(const wax::obj &key, const wax::obj &val){
+ if (key.as<dboard_prop_t>() == DBOARD_PROP_USED_SUBDEVS){
+ _tx_subdevs_in_use = val.as<prop_names_t>();
+ update_mux_config(); //if the val is bad, this will throw
+ return;
+ }
+
throw std::runtime_error("Cannot set on usrp2 dboard");
}
diff --git a/host/lib/usrp/usrp2/dboard_interface.cpp b/host/lib/usrp/usrp2/dboard_interface.cpp
index f12b101f3..cefd69ba9 100644
--- a/host/lib/usrp/usrp2/dboard_interface.cpp
+++ b/host/lib/usrp/usrp2/dboard_interface.cpp
@@ -16,11 +16,48 @@
//
#include <uhd/utils.hpp>
-#include "dboard_interface.hpp"
#include "usrp2_impl.hpp"
using namespace uhd::usrp;
+class usrp2_dboard_interface : public dboard_interface{
+public:
+ usrp2_dboard_interface(usrp2_impl *impl);
+ ~usrp2_dboard_interface(void);
+
+ void write_aux_dac(unit_type_t, int, int);
+ int read_aux_adc(unit_type_t, int);
+
+ void set_atr_reg(gpio_bank_t, uint16_t, uint16_t, uint16_t);
+ void set_gpio_ddr(gpio_bank_t, uint16_t, uint16_t);
+ void write_gpio(gpio_bank_t, uint16_t, uint16_t);
+ uint16_t read_gpio(gpio_bank_t);
+
+ void write_i2c(int, const byte_vector_t &);
+ byte_vector_t read_i2c(int, size_t);
+
+ double get_rx_clock_rate(void);
+ double get_tx_clock_rate(void);
+
+private:
+ byte_vector_t transact_spi(
+ spi_dev_t dev,
+ spi_latch_t latch,
+ spi_push_t push,
+ const byte_vector_t &buf,
+ bool readback
+ );
+
+ usrp2_impl *_impl;
+};
+
+/***********************************************************************
+ * Make Function
+ **********************************************************************/
+dboard_interface::sptr make_usrp2_dboard_interface(usrp2_impl *impl){
+ return dboard_interface::sptr(new usrp2_dboard_interface(impl));
+}
+
/***********************************************************************
* Structors
**********************************************************************/
diff --git a/host/lib/usrp/usrp2/dboard_interface.hpp b/host/lib/usrp/usrp2/dboard_interface.hpp
deleted file mode 100644
index a06359e5e..000000000
--- a/host/lib/usrp/usrp2/dboard_interface.hpp
+++ /dev/null
@@ -1,63 +0,0 @@
-//
-// Copyright 2010 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
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program. If not, see <http://www.gnu.org/licenses/>.
-//
-
-#include <uhd/usrp/dboard_interface.hpp>
-
-#ifndef INCLUDED_DBOARD_INTERFACE_HPP
-#define INCLUDED_DBOARD_INTERFACE_HPP
-
-class usrp2_impl; //dummy class declaration
-
-class usrp2_dboard_interface : public uhd::usrp::dboard_interface{
-public:
- usrp2_dboard_interface(usrp2_impl *impl);
-
- ~usrp2_dboard_interface(void);
-
- void write_aux_dac(unit_type_t, int, int);
-
- int read_aux_adc(unit_type_t, int);
-
- void set_atr_reg(gpio_bank_t, uint16_t, uint16_t, uint16_t);
-
- void set_gpio_ddr(gpio_bank_t, uint16_t, uint16_t);
-
- void write_gpio(gpio_bank_t, uint16_t, uint16_t);
-
- uint16_t read_gpio(gpio_bank_t);
-
- void write_i2c(int, const byte_vector_t &);
-
- byte_vector_t read_i2c(int, size_t);
-
- double get_rx_clock_rate(void);
-
- double get_tx_clock_rate(void);
-
-private:
- byte_vector_t transact_spi(
- spi_dev_t dev,
- spi_latch_t latch,
- spi_push_t push,
- const byte_vector_t &buf,
- bool readback
- );
-
- usrp2_impl *_impl;
-};
-
-#endif /* INCLUDED_DBOARD_INTERFACE_HPP */
diff --git a/host/lib/usrp/usrp2/fw_common.h b/host/lib/usrp/usrp2/fw_common.h
index 10c1ef8cf..03e8d3a37 100644
--- a/host/lib/usrp/usrp2/fw_common.h
+++ b/host/lib/usrp/usrp2/fw_common.h
@@ -94,6 +94,9 @@ typedef enum{
USRP2_CTRL_ID_GOT_A_NEW_TIME_FOR_YOU_BRO,
USRP2_CTRL_ID_SWEET_I_GOT_THAT_TIME_DUDE,
+ USRP2_CTRL_ID_UPDATE_THOSE_MUX_SETTINGS_BRO,
+ USRP2_CTRL_ID_UPDATED_THE_MUX_SETTINGS_DUDE,
+
USRP2_CTRL_ID_PEACE_OUT
} usrp2_ctrl_id_t;
@@ -194,6 +197,10 @@ typedef struct{
uint32_t ticks;
uint8_t now;
} time_args;
+ struct {
+ uint32_t rx_mux;
+ uint32_t tx_mux;
+ } mux_args;
} data;
} usrp2_ctrl_data_t;
diff --git a/host/lib/usrp/usrp2/usrp2_impl.hpp b/host/lib/usrp/usrp2/usrp2_impl.hpp
index fc713c2bf..2c6b6f8c9 100644
--- a/host/lib/usrp/usrp2/usrp2_impl.hpp
+++ b/host/lib/usrp/usrp2/usrp2_impl.hpp
@@ -31,6 +31,15 @@
#ifndef INCLUDED_USRP2_IMPL_HPP
#define INCLUDED_USRP2_IMPL_HPP
+class usrp2_impl; //dummy class declaration
+
+/*!
+ * Make a usrp2 dboard interface.
+ * \param impl a pointer to the usrp2 impl object
+ * \return a sptr to a new dboard interface
+ */
+uhd::usrp::dboard_interface::sptr make_usrp2_dboard_interface(usrp2_impl *impl);
+
/*!
* Simple wax obj proxy class:
* Provides a wax obj interface for a set and a get function.
@@ -156,11 +165,14 @@ private:
void rx_dboard_get(const wax::obj &, wax::obj &);
void rx_dboard_set(const wax::obj &, const wax::obj &);
uhd::dict<std::string, wax_obj_proxy> _rx_dboards;
+ uhd::prop_names_t _rx_subdevs_in_use;
//properties interface for tx dboard
void tx_dboard_get(const wax::obj &, wax::obj &);
void tx_dboard_set(const wax::obj &, const wax::obj &);
uhd::dict<std::string, wax_obj_proxy> _tx_dboards;
+ uhd::prop_names_t _tx_subdevs_in_use;
+ void update_mux_config(void);
//methods and shadows for the ddc dsp
std::vector<size_t> _allowed_decim_and_interp_rates;