diff options
Diffstat (limited to 'host/lib/usrp')
-rw-r--r-- | host/lib/usrp/dboard/db_basic_and_lf.cpp | 40 | ||||
-rw-r--r-- | host/lib/usrp/usrp2/dboard_interface.cpp | 25 | ||||
-rw-r--r-- | host/lib/usrp/usrp2/usrp2_regs.hpp | 22 |
3 files changed, 39 insertions, 48 deletions
diff --git a/host/lib/usrp/dboard/db_basic_and_lf.cpp b/host/lib/usrp/dboard/db_basic_and_lf.cpp index 930646f76..3c14e473e 100644 --- a/host/lib/usrp/dboard/db_basic_and_lf.cpp +++ b/host/lib/usrp/dboard/db_basic_and_lf.cpp @@ -87,8 +87,6 @@ UHD_STATIC_BLOCK(reg_dboards){ **********************************************************************/ basic_rx::basic_rx(ctor_args_t const& args, double max_freq) : rx_dboard_base(args){ _max_freq = max_freq; - // set the gpios to safe values (all inputs) - get_interface()->set_gpio_ddr(dboard_interface::GPIO_BANK_RX, 0x0000); } basic_rx::~basic_rx(void){ @@ -149,7 +147,13 @@ void basic_rx::rx_get(const wax::obj &key_, wax::obj &val){ return; case SUBDEV_PROP_IQ_SWAPPED: + val = false; + return; + case SUBDEV_PROP_SPECTRUM_INVERTED: + val = false; + return; + case SUBDEV_PROP_USE_LO_OFFSET: val = false; return; @@ -177,17 +181,7 @@ void basic_rx::rx_set(const wax::obj &key_, const wax::obj &val){ case SUBDEV_PROP_FREQ: return; // it wont do you much good, but you can set it - case SUBDEV_PROP_NAME: - case SUBDEV_PROP_OTHERS: - case SUBDEV_PROP_GAIN_RANGE: - case SUBDEV_PROP_GAIN_NAMES: - case SUBDEV_PROP_FREQ_RANGE: - case SUBDEV_PROP_ANTENNA_NAMES: - case SUBDEV_PROP_QUADRATURE: - case SUBDEV_PROP_IQ_SWAPPED: - case SUBDEV_PROP_SPECTRUM_INVERTED: - case SUBDEV_PROP_USE_LO_OFFSET: - throw std::runtime_error(str(boost::format( + default: throw std::runtime_error(str(boost::format( "Error: trying to set read-only property on %s subdev" ) % dboard_id::to_string(get_rx_id()))); } @@ -198,8 +192,6 @@ void basic_rx::rx_set(const wax::obj &key_, const wax::obj &val){ **********************************************************************/ basic_tx::basic_tx(ctor_args_t const& args, double max_freq) : tx_dboard_base(args){ _max_freq = max_freq; - // set the gpios to safe values (all inputs) - get_interface()->set_gpio_ddr(dboard_interface::GPIO_BANK_TX, 0x0000); } basic_tx::~basic_tx(void){ @@ -257,7 +249,13 @@ void basic_tx::tx_get(const wax::obj &key_, wax::obj &val){ return; case SUBDEV_PROP_IQ_SWAPPED: + val = false; + return; + case SUBDEV_PROP_SPECTRUM_INVERTED: + val = false; + return; + case SUBDEV_PROP_USE_LO_OFFSET: val = false; return; @@ -285,17 +283,7 @@ void basic_tx::tx_set(const wax::obj &key_, const wax::obj &val){ case SUBDEV_PROP_FREQ: return; // it wont do you much good, but you can set it - case SUBDEV_PROP_NAME: - case SUBDEV_PROP_OTHERS: - case SUBDEV_PROP_GAIN_RANGE: - case SUBDEV_PROP_GAIN_NAMES: - case SUBDEV_PROP_FREQ_RANGE: - case SUBDEV_PROP_ANTENNA_NAMES: - case SUBDEV_PROP_QUADRATURE: - case SUBDEV_PROP_IQ_SWAPPED: - case SUBDEV_PROP_SPECTRUM_INVERTED: - case SUBDEV_PROP_USE_LO_OFFSET: - throw std::runtime_error(str(boost::format( + default: throw std::runtime_error(str(boost::format( "Error: trying to set read-only property on %s subdev" ) % dboard_id::to_string(get_tx_id()))); } diff --git a/host/lib/usrp/usrp2/dboard_interface.cpp b/host/lib/usrp/usrp2/dboard_interface.cpp index d7c18983a..6dd756420 100644 --- a/host/lib/usrp/usrp2/dboard_interface.cpp +++ b/host/lib/usrp/usrp2/dboard_interface.cpp @@ -48,6 +48,7 @@ private: ); usrp2_impl *_impl; + boost::uint32_t _ddr_shadow; }; /*********************************************************************** @@ -62,6 +63,7 @@ dboard_interface::sptr make_usrp2_dboard_interface(usrp2_impl *impl){ **********************************************************************/ usrp2_dboard_interface::usrp2_dboard_interface(usrp2_impl *impl){ _impl = impl; + _ddr_shadow = 0; //set the selection mux to use atr boost::uint32_t new_sels = 0x0; @@ -90,20 +92,23 @@ double usrp2_dboard_interface::get_tx_clock_rate(void){ /*********************************************************************** * GPIO **********************************************************************/ +static int bank_to_shift(dboard_interface::gpio_bank_t bank){ + switch(bank){ + case dboard_interface::GPIO_BANK_RX: return 0; + case dboard_interface::GPIO_BANK_TX: return 16; + } + throw std::runtime_error("unknown gpio bank type"); +} + void usrp2_dboard_interface::set_gpio_ddr(gpio_bank_t bank, boost::uint16_t value){ - static const uhd::dict<gpio_bank_t, boost::uint32_t> bank_to_addr = boost::assign::map_list_of - (GPIO_BANK_RX, FR_GPIO_RX_DDR) - (GPIO_BANK_TX, FR_GPIO_TX_DDR) - ; - _impl->poke16(bank_to_addr[bank], value); + _ddr_shadow = \ + (_ddr_shadow & ~(0xffff << bank_to_shift(bank))) | + (boost::uint32_t(value) << bank_to_shift(bank)); + _impl->poke32(FR_GPIO_DDR, _ddr_shadow); } boost::uint16_t usrp2_dboard_interface::read_gpio(gpio_bank_t bank){ - static const uhd::dict<gpio_bank_t, boost::uint32_t> bank_to_addr = boost::assign::map_list_of - (GPIO_BANK_RX, FR_GPIO_RX_IO) - (GPIO_BANK_TX, FR_GPIO_TX_IO) - ; - return _impl->peek16(bank_to_addr[bank]); + return boost::uint16_t(_impl->peek32(FR_GPIO_IO) >> bank_to_shift(bank)); } void usrp2_dboard_interface::set_atr_reg(gpio_bank_t bank, atr_reg_t atr, boost::uint16_t value){ diff --git a/host/lib/usrp/usrp2/usrp2_regs.hpp b/host/lib/usrp/usrp2/usrp2_regs.hpp index 0a2de2c6d..77d9f4ad9 100644 --- a/host/lib/usrp/usrp2/usrp2_regs.hpp +++ b/host/lib/usrp/usrp2/usrp2_regs.hpp @@ -177,10 +177,8 @@ // #define FR_GPIO_BASE 0xC800 -#define FR_GPIO_RX_IO FR_GPIO_BASE + 0 // 16 io data pins -#define FR_GPIO_TX_IO FR_GPIO_BASE + 2 // 16 io data pins -#define FR_GPIO_RX_DDR FR_GPIO_BASE + 4 // 16 ddr pins, 1 means output -#define FR_GPIO_TX_DDR FR_GPIO_BASE + 6 // 16 ddr pins, 1 means output +#define FR_GPIO_IO FR_GPIO_BASE + 0 // 32 bits, gpio io pins (tx high 16 bits, rx low 16 bits) +#define FR_GPIO_DDR FR_GPIO_BASE + 4 // 32 bits, gpio ddr, 1 means output (tx high 16 bits, rx low 16 bits) #define FR_GPIO_TX_SEL FR_GPIO_BASE + 8 // 16 2-bit fields select which source goes to TX DB #define FR_GPIO_RX_SEL FR_GPIO_BASE + 12 // 16 2-bit fields select which source goes to RX DB @@ -195,13 +193,13 @@ //////////////////////////////////////////////// #define FR_ATR_BASE 0xE400 -#define FR_ATR_IDLE_RXSIDE FR_ATR_BASE + 0 -#define FR_ATR_IDLE_TXSIDE FR_ATR_BASE + 2 -#define FR_ATR_INTX_RXSIDE FR_ATR_BASE + 4 -#define FR_ATR_INTX_TXSIDE FR_ATR_BASE + 6 -#define FR_ATR_INRX_RXSIDE FR_ATR_BASE + 8 -#define FR_ATR_INRX_TXSIDE FR_ATR_BASE + 10 -#define FR_ATR_FULL_RXSIDE FR_ATR_BASE + 12 -#define FR_ATR_FULL_TXSIDE FR_ATR_BASE + 14 +#define FR_ATR_IDLE_TXSIDE FR_ATR_BASE + 0 +#define FR_ATR_IDLE_RXSIDE FR_ATR_BASE + 2 +#define FR_ATR_INTX_TXSIDE FR_ATR_BASE + 4 +#define FR_ATR_INTX_RXSIDE FR_ATR_BASE + 6 +#define FR_ATR_INRX_TXSIDE FR_ATR_BASE + 8 +#define FR_ATR_INRX_RXSIDE FR_ATR_BASE + 10 +#define FR_ATR_FULL_TXSIDE FR_ATR_BASE + 12 +#define FR_ATR_FULL_RXSIDE FR_ATR_BASE + 14 #endif /* INCLUDED_USRP2_REGS_HPP */ |