diff options
author | Thomas Tsou <ttsou@vt.edu> | 2010-08-16 16:21:13 -0700 |
---|---|---|
committer | Thomas Tsou <ttsou@vt.edu> | 2010-08-16 18:35:09 -0700 |
commit | df74cfa4ad134faeafd9fb97420db8acb227d9af (patch) | |
tree | 2debb9597905ab9354085b4d2c4fdcca74b67cf7 /host/lib/usrp | |
parent | 564bfee0389d0274e7cd128d61dcbe50ca6a6cdd (diff) | |
download | uhd-df74cfa4ad134faeafd9fb97420db8acb227d9af.tar.gz uhd-df74cfa4ad134faeafd9fb97420db8acb227d9af.tar.bz2 uhd-df74cfa4ad134faeafd9fb97420db8acb227d9af.zip |
usrp1: Setup dboard interface duality
Diffstat (limited to 'host/lib/usrp')
-rw-r--r-- | host/lib/usrp/usrp1/dboard_iface.cpp | 105 |
1 files changed, 63 insertions, 42 deletions
diff --git a/host/lib/usrp/usrp1/dboard_iface.cpp b/host/lib/usrp/usrp1/dboard_iface.cpp index 142907e57..fe4ebe04c 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); } @@ -228,13 +233,16 @@ void usrp1_dboard_iface::set_atr_reg(unit_t unit, 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 +252,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 +282,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 +291,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); } |