summaryrefslogtreecommitdiffstats
path: root/host/lib
diff options
context:
space:
mode:
authorJosh Blum <josh@joshknows.com>2010-06-10 17:11:12 +0000
committerJosh Blum <josh@joshknows.com>2010-06-10 17:11:12 +0000
commit28ecca40d3e032393eb028cea9d6812b8ff80851 (patch)
tree8a923f5994ee81e600722644e08ed865d1873b8b /host/lib
parenta2fb45081530fa247bd5a4c0be441fa77da0ed1b (diff)
parent126444c564d30d65116be5f772bdf47594d62884 (diff)
downloaduhd-28ecca40d3e032393eb028cea9d6812b8ff80851.tar.gz
uhd-28ecca40d3e032393eb028cea9d6812b8ff80851.tar.bz2
uhd-28ecca40d3e032393eb028cea9d6812b8ff80851.zip
Merge branch 'master' of ettus.sourcerepo.com:ettus/uhdpriv into usrp_e
Diffstat (limited to 'host/lib')
-rw-r--r--host/lib/usrp/dboard/db_basic_and_lf.cpp4
-rw-r--r--host/lib/usrp/dsp_utils.hpp35
-rw-r--r--host/lib/usrp/usrp2/dboard_impl.cpp64
-rw-r--r--host/lib/usrp/usrp2/usrp2_impl.hpp2
4 files changed, 59 insertions, 46 deletions
diff --git a/host/lib/usrp/dboard/db_basic_and_lf.cpp b/host/lib/usrp/dboard/db_basic_and_lf.cpp
index 23ac98872..766deac78 100644
--- a/host/lib/usrp/dboard/db_basic_and_lf.cpp
+++ b/host/lib/usrp/dboard/db_basic_and_lf.cpp
@@ -127,7 +127,7 @@ void basic_rx::rx_get(const wax::obj &key_, wax::obj &val){
return;
case SUBDEV_PROP_FREQ_RANGE:
- val = freq_range_t(+_max_freq, -_max_freq);
+ val = freq_range_t(-_max_freq, +_max_freq);
return;
case SUBDEV_PROP_ANTENNA:
@@ -226,7 +226,7 @@ void basic_tx::tx_get(const wax::obj &key_, wax::obj &val){
return;
case SUBDEV_PROP_FREQ_RANGE:
- val = freq_range_t(+_max_freq, -_max_freq);
+ val = freq_range_t(-_max_freq, +_max_freq);
return;
case SUBDEV_PROP_ANTENNA:
diff --git a/host/lib/usrp/dsp_utils.hpp b/host/lib/usrp/dsp_utils.hpp
index cfe5375f8..e0ec46184 100644
--- a/host/lib/usrp/dsp_utils.hpp
+++ b/host/lib/usrp/dsp_utils.hpp
@@ -32,6 +32,41 @@ namespace dsp_type1{
}
/*!
+ * Calculate the rx mux word from properties.
+ * \param is_quadrature true if the subdev is complex
+ * \param is_iq_swapped true if the i and q are reversed
+ * \param the 32-bit rx mux control word
+ */
+ static inline boost::uint32_t calc_rx_mux_word(
+ bool is_quadrature,
+ bool is_iq_swapped
+ ){
+ boost::uint32_t rx_mux = 0;
+ if (is_quadrature){
+ rx_mux = (0x01 << 2) | (0x00 << 0); //Q=ADC1, I=ADC0
+ }else{
+ rx_mux = (0x11 << 2) | (0x00 << 0); //Q=ZERO, I=ADC0
+ }
+ if (is_iq_swapped){
+ rx_mux = (rx_mux << 2) | (rx_mux >> 2);
+ }
+ return rx_mux;
+ }
+
+ /*!
+ * Calculate the tx mux word from properties.
+ * \param is_iq_swapped true if the i and q are reversed
+ * \param the 32-bit tx mux control word
+ */
+ static inline boost::uint32_t calc_tx_mux_word(bool is_iq_swapped){
+ boost::uint32_t tx_mux = 0x10;
+ if (is_iq_swapped){
+ tx_mux = (tx_mux << 4) | (tx_mux >> 4);
+ }
+ return tx_mux;
+ }
+
+ /*!
* Calculate the cordic word from the frequency and clock rate.
* The frequency will be set to the actual (possible) frequency.
*
diff --git a/host/lib/usrp/usrp2/dboard_impl.cpp b/host/lib/usrp/usrp2/dboard_impl.cpp
index 4a3a70467..fef486771 100644
--- a/host/lib/usrp/usrp2/dboard_impl.cpp
+++ b/host/lib/usrp/usrp2/dboard_impl.cpp
@@ -18,6 +18,7 @@
#include "usrp2_impl.hpp"
#include "usrp2_regs.hpp"
+#include "../dsp_utils.hpp"
#include <uhd/usrp/subdev_props.hpp>
#include <uhd/usrp/dboard_props.hpp>
#include <uhd/utils/assert.hpp>
@@ -54,42 +55,8 @@ void usrp2_impl::dboard_init(void){
);
//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));
- update_rx_mux_config();
-
- _tx_subdevs_in_use = prop_names_t(1, _dboard_manager->get_tx_subdev_names().at(0));
- update_tx_mux_config();
-}
-
-void usrp2_impl::update_rx_mux_config(void){
- //calculate the rx mux
- boost::uint32_t rx_mux = 0;
- UHD_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);
- }
-
- _iface->poke32(U2_REG_DSP_RX_MUX, rx_mux);
-}
-
-void usrp2_impl::update_tx_mux_config(void){
- //calculate the tx mux
- boost::uint32_t tx_mux = 0x10;
- UHD_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) & 0xf) << 4) | (((tx_mux >> 4) & 0xf) << 0);
- }
-
- _iface->poke32(U2_REG_DSP_TX_MUX, tx_mux);
+ rx_dboard_set(DBOARD_PROP_USED_SUBDEVS, prop_names_t(1, _dboard_manager->get_rx_subdev_names().at(0)));
+ tx_dboard_set(DBOARD_PROP_USED_SUBDEVS, prop_names_t(1, _dboard_manager->get_tx_subdev_names().at(0)));
}
/***********************************************************************
@@ -131,9 +98,16 @@ void usrp2_impl::rx_dboard_get(const wax::obj &key_, wax::obj &val){
void usrp2_impl::rx_dboard_set(const wax::obj &key, const wax::obj &val){
switch(key.as<dboard_prop_t>()){
- case DBOARD_PROP_USED_SUBDEVS:
- _rx_subdevs_in_use = val.as<prop_names_t>();
- update_rx_mux_config(); //if the val is bad, this will throw
+ case DBOARD_PROP_USED_SUBDEVS:{
+ _rx_subdevs_in_use = val.as<prop_names_t>();
+ UHD_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;
+ _iface->poke32(U2_REG_DSP_RX_MUX, dsp_type1::calc_rx_mux_word(
+ rx_subdev[SUBDEV_PROP_QUADRATURE].as<bool>(),
+ rx_subdev[SUBDEV_PROP_IQ_SWAPPED].as<bool>()
+ ));
+ }
return;
case DBOARD_PROP_DBOARD_ID:
@@ -184,9 +158,15 @@ void usrp2_impl::tx_dboard_get(const wax::obj &key_, wax::obj &val){
void usrp2_impl::tx_dboard_set(const wax::obj &key, const wax::obj &val){
switch(key.as<dboard_prop_t>()){
- case DBOARD_PROP_USED_SUBDEVS:
- _tx_subdevs_in_use = val.as<prop_names_t>();
- update_tx_mux_config(); //if the val is bad, this will throw
+ case DBOARD_PROP_USED_SUBDEVS:{
+ _tx_subdevs_in_use = val.as<prop_names_t>();
+ UHD_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;
+ _iface->poke32(U2_REG_DSP_TX_MUX, dsp_type1::calc_tx_mux_word(
+ tx_subdev[SUBDEV_PROP_IQ_SWAPPED].as<bool>()
+ ));
+ }
return;
case DBOARD_PROP_DBOARD_ID:
diff --git a/host/lib/usrp/usrp2/usrp2_impl.hpp b/host/lib/usrp/usrp2/usrp2_impl.hpp
index 77148ee62..ccc09003e 100644
--- a/host/lib/usrp/usrp2/usrp2_impl.hpp
+++ b/host/lib/usrp/usrp2/usrp2_impl.hpp
@@ -190,8 +190,6 @@ private:
wax_obj_proxy::sptr _tx_dboard_proxy;
uhd::prop_names_t _tx_subdevs_in_use;
uhd::usrp::dboard_eeprom_t _tx_db_eeprom;
- void update_rx_mux_config(void);
- void update_tx_mux_config(void);
//methods and shadows for the ddc dsp
std::vector<size_t> _allowed_decim_and_interp_rates;