aboutsummaryrefslogtreecommitdiffstats
path: root/host
diff options
context:
space:
mode:
Diffstat (limited to 'host')
-rw-r--r--host/lib/usrp/usrp1/dboard_iface.cpp111
-rw-r--r--host/lib/usrp/usrp1/dsp_impl.cpp10
-rw-r--r--host/lib/usrp/usrp1/usrp1_impl.hpp2
3 files changed, 71 insertions, 52 deletions
diff --git a/host/lib/usrp/usrp1/dboard_iface.cpp b/host/lib/usrp/usrp1/dboard_iface.cpp
index 142907e57..f6fbab033 100644
--- a/host/lib/usrp/usrp1/dboard_iface.cpp
+++ b/host/lib/usrp/usrp1/dboard_iface.cpp
@@ -31,15 +31,6 @@ using namespace uhd;
using namespace uhd::usrp;
using namespace boost::assign;
-/***********************************************************************
- * TODO TODO TODO TODO TODO TODO TODO TODO TODO TODO TODO TODO TODO TODO
- * TODO TODO TODO TODO TODO TODO TODO TODO TODO TODO TODO TODO TODO TODO
- * TODO TODO TODO TODO TODO TODO TODO TODO TODO TODO TODO TODO TODO TODO
- * TODO TODO TODO TODO TODO TODO TODO TODO TODO TODO TODO TODO TODO TODO
- *
- * check the _dboard_slot and handle conditionally...
- **********************************************************************/
-
class usrp1_dboard_iface : public dboard_iface {
public:
@@ -161,13 +152,17 @@ void usrp1_dboard_iface::set_pin_ctrl(unit_t unit, boost::uint16_t value)
{
switch(unit) {
case UNIT_RX:
- _iface->poke32(FR_ATR_MASK_1, value);
- _iface->poke32(FR_ATR_MASK_3, 0x00000000);
- break;
+ if (_dboard_slot == usrp1_impl::DBOARD_SLOT_A)
+ _iface->poke32(FR_ATR_MASK_1, value);
+ else if (_dboard_slot == usrp1_impl::DBOARD_SLOT_B)
+ _iface->poke32(FR_ATR_MASK_3, value);
+ break;
case UNIT_TX:
- _iface->poke32(FR_ATR_MASK_0, value);
- _iface->poke32(FR_ATR_MASK_2, 0x00000000);
- break;
+ if (_dboard_slot == usrp1_impl::DBOARD_SLOT_A)
+ _iface->poke32(FR_ATR_MASK_0, value);
+ else if (_dboard_slot == usrp1_impl::DBOARD_SLOT_B)
+ _iface->poke32(FR_ATR_MASK_2, value);
+ break;
}
}
@@ -175,12 +170,16 @@ void usrp1_dboard_iface::set_gpio_ddr(unit_t unit, boost::uint16_t value)
{
switch(unit) {
case UNIT_RX:
- _iface->poke32(FR_OE_1, 0xffff0000 | value);
- _iface->poke32(FR_OE_3, 0xffff0000);
- break;
+ if (_dboard_slot == usrp1_impl::DBOARD_SLOT_A)
+ _iface->poke32(FR_OE_1, 0xffff0000 | value);
+ else if (_dboard_slot == usrp1_impl::DBOARD_SLOT_B)
+ _iface->poke32(FR_OE_3, 0xffff0000 | value);
+ break;
case UNIT_TX:
- _iface->poke32(FR_OE_0, 0xffff0000 | value);
- _iface->poke32(FR_OE_2, 0xffff0000);
+ if (_dboard_slot == usrp1_impl::DBOARD_SLOT_A)
+ _iface->poke32(FR_OE_0, 0xffff0000 | value);
+ else if (_dboard_slot == usrp1_impl::DBOARD_SLOT_B)
+ _iface->poke32(FR_OE_2, 0xffff0000 | value);
break;
}
}
@@ -189,10 +188,16 @@ void usrp1_dboard_iface::write_gpio(unit_t unit, boost::uint16_t value)
{
switch(unit) {
case UNIT_RX:
- _iface->poke32(FR_IO_1, 0xffff0000 | value);
+ if (_dboard_slot == usrp1_impl::DBOARD_SLOT_A)
+ _iface->poke32(FR_IO_1, 0xffff0000 | value);
+ else if (_dboard_slot == usrp1_impl::DBOARD_SLOT_B)
+ _iface->poke32(FR_IO_3, 0xffff0000 | value);
break;
case UNIT_TX:
- _iface->poke32(FR_IO_0, 0xffff0000 | value);
+ if (_dboard_slot == usrp1_impl::DBOARD_SLOT_A)
+ _iface->poke32(FR_IO_0, 0xffff0000 | value);
+ else if (_dboard_slot == usrp1_impl::DBOARD_SLOT_B)
+ _iface->poke32(FR_IO_2, 0xffff0000 | value);
break;
}
}
@@ -200,19 +205,19 @@ void usrp1_dboard_iface::write_gpio(unit_t unit, boost::uint16_t value)
boost::uint16_t usrp1_dboard_iface::read_gpio(unit_t unit)
{
boost::uint32_t out_value;
- boost::uint16_t ret_value;
+
+ if (_dboard_slot == usrp1_impl::DBOARD_SLOT_A)
+ out_value = _iface->peek32(1);
+ else if (_dboard_slot == usrp1_impl::DBOARD_SLOT_B)
+ out_value = _iface->peek32(2);
+ else
+ UHD_THROW_INVALID_CODE_PATH();
switch(unit) {
case UNIT_RX:
- //magic
- out_value = _iface->peek32(1);
- ret_value = (out_value >> 16) & 0x0000ffff;
- return ret_value;
+ return (boost::uint16_t)((out_value >> 16) & 0x0000ffff);
case UNIT_TX:
- //magic
- out_value = _iface->peek32(1);
- ret_value = (out_value >> 0) & 0x0000ffff;
- return ret_value;
+ return (boost::uint16_t)((out_value >> 0) & 0x0000ffff);
}
UHD_ASSERT_THROW(false);
}
@@ -220,21 +225,22 @@ boost::uint16_t usrp1_dboard_iface::read_gpio(unit_t unit)
void usrp1_dboard_iface::set_atr_reg(unit_t unit,
atr_reg_t atr, boost::uint16_t value)
{
- if ((atr == ATR_REG_IDLE) || (atr == ATR_REG_FULL_DUPLEX)) {
- //TODO probably just ignore these two atr settings because all dboards will try to set them
- std::cerr << "error: set_atr_reg(): unsupported state" << std::endl;
+ // Ignore unsupported states
+ if ((atr == ATR_REG_IDLE) || (atr == ATR_REG_FULL_DUPLEX))
return;
- }
switch(unit) {
case UNIT_RX:
- _iface->poke32(FR_ATR_RXVAL_1, value);
- _iface->poke32(FR_ATR_RXVAL_3, 0x0000);
+ if (_dboard_slot == usrp1_impl::DBOARD_SLOT_A)
+ _iface->poke32(FR_ATR_RXVAL_1, value);
+ else if (_dboard_slot == usrp1_impl::DBOARD_SLOT_B)
+ _iface->poke32(FR_ATR_RXVAL_3, value);
break;
case UNIT_TX:
- //_iface->poke32(FR_ATR_TXVAL_0, value);
- _iface->poke32(FR_ATR_TXVAL_0, 0x0000);
- _iface->poke32(FR_ATR_TXVAL_2, 0x0000);
+ if (_dboard_slot == usrp1_impl::DBOARD_SLOT_A)
+ _iface->poke32(FR_ATR_TXVAL_0, value);
+ else if (_dboard_slot == usrp1_impl::DBOARD_SLOT_B)
+ _iface->poke32(FR_ATR_TXVAL_2, value);
break;
}
}
@@ -244,16 +250,29 @@ void usrp1_dboard_iface::set_atr_reg(unit_t unit,
/*!
* Static function to convert a unit type to a spi slave device number.
* \param unit the dboard interface unit type enum
+ * \param slot the side (A or B) the dboard is attached
* \return the slave device number
*/
-static boost::uint32_t unit_to_otw_spi_dev(dboard_iface::unit_t unit)
+static boost::uint32_t unit_to_otw_spi_dev(dboard_iface::unit_t unit,
+ usrp1_impl::dboard_slot_t slot)
{
switch(unit) {
- case dboard_iface::UNIT_TX: return SPI_ENABLE_TX_A;
- case dboard_iface::UNIT_RX: return SPI_ENABLE_RX_A;
+ case dboard_iface::UNIT_TX:
+ if (slot == usrp1_impl::DBOARD_SLOT_A)
+ return SPI_ENABLE_TX_A;
+ else if (slot == usrp1_impl::DBOARD_SLOT_B)
+ return SPI_ENABLE_TX_B;
+ else
+ break;
+ case dboard_iface::UNIT_RX:
+ if (slot == usrp1_impl::DBOARD_SLOT_A)
+ return SPI_ENABLE_RX_A;
+ else if (slot == usrp1_impl::DBOARD_SLOT_B)
+ return SPI_ENABLE_RX_B;
+ else
+ break;
}
throw std::invalid_argument("unknown unit type");
-
}
void usrp1_dboard_iface::write_spi(unit_t unit,
@@ -261,7 +280,7 @@ void usrp1_dboard_iface::write_spi(unit_t unit,
boost::uint32_t data,
size_t num_bits)
{
- _iface->transact_spi(unit_to_otw_spi_dev(unit),
+ _iface->transact_spi(unit_to_otw_spi_dev(unit, _dboard_slot),
config, data, num_bits, false);
}
@@ -270,7 +289,7 @@ boost::uint32_t usrp1_dboard_iface::read_write_spi(unit_t unit,
boost::uint32_t data,
size_t num_bits)
{
- return _iface->transact_spi(unit_to_otw_spi_dev(unit),
+ return _iface->transact_spi(unit_to_otw_spi_dev(unit, _dboard_slot),
config, data, num_bits, true);
}
diff --git a/host/lib/usrp/usrp1/dsp_impl.cpp b/host/lib/usrp/usrp1/dsp_impl.cpp
index 260c01ea8..0db3cb473 100644
--- a/host/lib/usrp/usrp1/dsp_impl.cpp
+++ b/host/lib/usrp/usrp1/dsp_impl.cpp
@@ -36,7 +36,7 @@ void usrp1_impl::rx_dsp_init(void)
boost::bind(&usrp1_impl::rx_dsp_get, this, _1, _2),
boost::bind(&usrp1_impl::rx_dsp_set, this, _1, _2));
- rx_dsp_set(DSP_PROP_HOST_RATE, double(64e6/10)); //FIXME magic number
+ rx_dsp_set(DSP_PROP_HOST_RATE, _clock_ctrl->get_master_clock_freq() / 16);
}
/***********************************************************************
@@ -95,7 +95,9 @@ void usrp1_impl::rx_dsp_set(const wax::obj &key, const wax::obj &val)
switch(key.as<dsp_prop_t>()) {
case DSP_PROP_FREQ_SHIFT: {
double new_freq = val.as<double>();
- _iface->poke32(FR_RX_FREQ_0, compute_freq_word(64e6, new_freq)); //FIXME magic rate
+ boost::uint32_t hw_freq_word = compute_freq_word(
+ _clock_ctrl->get_master_clock_freq(), new_freq);
+ _iface->poke32(FR_RX_FREQ_0, hw_freq_word);
_tx_dsp_freq = new_freq;
return;
}
@@ -130,7 +132,7 @@ void usrp1_impl::tx_dsp_init(void)
boost::bind(&usrp1_impl::tx_dsp_set, this, _1, _2));
//initial config and update
- tx_dsp_set(DSP_PROP_HOST_RATE, double(64e6/10)); //FIXME magic number
+ tx_dsp_set(DSP_PROP_HOST_RATE, _clock_ctrl->get_master_clock_freq() * 2 / 16);
}
/***********************************************************************
@@ -152,7 +154,7 @@ void usrp1_impl::tx_dsp_get(const wax::obj &key, wax::obj &val)
return;
case DSP_PROP_CODEC_RATE:
- val = MASTER_CLOCK_RATE;
+ val = _clock_ctrl->get_master_clock_freq() * 2;
return;
case DSP_PROP_HOST_RATE:
diff --git a/host/lib/usrp/usrp1/usrp1_impl.hpp b/host/lib/usrp/usrp1/usrp1_impl.hpp
index 5166f989f..f57f9a09a 100644
--- a/host/lib/usrp/usrp1/usrp1_impl.hpp
+++ b/host/lib/usrp/usrp1/usrp1_impl.hpp
@@ -33,8 +33,6 @@
#ifndef INCLUDED_USRP1_IMPL_HPP
#define INCLUDED_USRP1_IMPL_HPP
-static const double MASTER_CLOCK_RATE = 64e6; //TODO get from clock control
-
/*!
* Simple wax obj proxy class:
* Provides a wax obj interface for a set and a get function.