diff options
Diffstat (limited to 'host/lib')
-rw-r--r-- | host/lib/usrp/usrp_e/clock_ctrl.cpp | 14 | ||||
-rw-r--r-- | host/lib/usrp/usrp_e/dboard_impl.cpp | 6 | ||||
-rw-r--r-- | host/lib/usrp/usrp_e/usrp_e_iface.hpp | 9 | ||||
-rw-r--r-- | host/lib/usrp/usrp_e/usrp_e_impl.cpp | 6 | ||||
-rw-r--r-- | host/lib/usrp/usrp_e/usrp_e_impl.hpp | 3 | ||||
-rw-r--r-- | host/lib/usrp/usrp_e/usrp_e_regs.hpp | 14 |
6 files changed, 38 insertions, 14 deletions
diff --git a/host/lib/usrp/usrp_e/clock_ctrl.cpp b/host/lib/usrp/usrp_e/clock_ctrl.cpp index 5f6fb4bfb..fa4028cc5 100644 --- a/host/lib/usrp/usrp_e/clock_ctrl.cpp +++ b/host/lib/usrp/usrp_e/clock_ctrl.cpp @@ -22,6 +22,7 @@ #include <boost/assign/list_of.hpp> #include <boost/foreach.hpp> #include <utility> +#include <iostream> using namespace uhd; @@ -97,6 +98,14 @@ clock_ctrl_impl::clock_ctrl_impl(usrp_e_iface::sptr iface){ } } this->latch_regs(); + //test read: + //boost::uint32_t reg = _ad9522_regs.get_read_reg(0x01b); + //boost::uint32_t result = _iface->transact_spi( + // UE_SPI_SS_AD9522, + // spi_config_t::EDGE_RISE, + // reg, 24, true /*no*/ + //); + //std::cout << "result " << std::hex << result << std::endl; } clock_ctrl_impl::~clock_ctrl_impl(void){ @@ -113,11 +122,12 @@ void clock_ctrl_impl::enable_tx_dboard_clock(bool enb){ } void clock_ctrl_impl::send_reg(boost::uint16_t addr){ + boost::uint32_t reg = _ad9522_regs.get_write_reg(addr); + std::cout << "clock control write reg: " << std::hex << reg << std::endl; _iface->transact_spi( UE_SPI_SS_AD9522, spi_config_t::EDGE_RISE, - _ad9522_regs.get_write_reg(addr), - 24, false /*no rb*/ + reg, 24, false /*no rb*/ ); } diff --git a/host/lib/usrp/usrp_e/dboard_impl.cpp b/host/lib/usrp/usrp_e/dboard_impl.cpp index e87a2c0a5..00b5d77d7 100644 --- a/host/lib/usrp/usrp_e/dboard_impl.cpp +++ b/host/lib/usrp/usrp_e/dboard_impl.cpp @@ -24,15 +24,15 @@ using namespace uhd::usrp; * Dboard Initialization **********************************************************************/ void usrp_e_impl::dboard_init(void){ - dboard_id_t rx_dboard_id = dboard_id::NONE; //TODO get these from the eeprom - dboard_id_t tx_dboard_id = dboard_id::NONE; + _rx_db_eeprom = dboard_eeprom_t(_iface->read_eeprom(I2C_ADDR_RX_DB, 0, dboard_eeprom_t::num_bytes())); + _tx_db_eeprom = dboard_eeprom_t(_iface->read_eeprom(I2C_ADDR_TX_DB, 0, dboard_eeprom_t::num_bytes())); //create a new dboard interface and manager dboard_iface::sptr dboard_iface( make_usrp_e_dboard_iface(_iface) ); _dboard_manager = dboard_manager::make( - rx_dboard_id, tx_dboard_id, dboard_iface + _rx_db_eeprom.id, _tx_db_eeprom.id, dboard_iface ); //setup the dboard proxies diff --git a/host/lib/usrp/usrp_e/usrp_e_iface.hpp b/host/lib/usrp/usrp_e/usrp_e_iface.hpp index 763d19581..016d7448f 100644 --- a/host/lib/usrp/usrp_e/usrp_e_iface.hpp +++ b/host/lib/usrp/usrp_e/usrp_e_iface.hpp @@ -24,6 +24,15 @@ #include <boost/utility.hpp> #include <boost/cstdint.hpp> +//////////////////////////////////////////////////////////////////////// +// I2C addresses +//////////////////////////////////////////////////////////////////////// +#define I2C_DEV_EEPROM 0x50 // 24LC02[45]: 7-bits 1010xxx +#define I2C_ADDR_MBOARD (I2C_DEV_EEPROM | 0x0) +#define I2C_ADDR_TX_DB (I2C_DEV_EEPROM | 0x4) +#define I2C_ADDR_RX_DB (I2C_DEV_EEPROM | 0x5) +//////////////////////////////////////////////////////////////////////// + /*! * The usrp-e interface class: * Provides a set of functions to implementation layer. diff --git a/host/lib/usrp/usrp_e/usrp_e_impl.cpp b/host/lib/usrp/usrp_e/usrp_e_impl.cpp index 211b939ee..52bbcdd32 100644 --- a/host/lib/usrp/usrp_e/usrp_e_impl.cpp +++ b/host/lib/usrp/usrp_e/usrp_e_impl.cpp @@ -21,7 +21,9 @@ #include <uhd/utils/static.hpp> #include <boost/format.hpp> #include <boost/filesystem.hpp> +#include <iostream> #include <fcntl.h> //open +#include "clock_ctrl.hpp" using namespace uhd; using namespace uhd::usrp; @@ -73,6 +75,8 @@ device::sptr usrp_e::make(const device_addr_t &device_addr){ * Structors **********************************************************************/ usrp_e_impl::usrp_e_impl(const std::string &node){ + std::cout << boost::format("Opening USRP-E on %s") % node << std::endl; + //open the device node and check file descriptor if ((_node_fd = ::open(node.c_str(), O_RDWR)) < 0){ throw std::runtime_error(str( @@ -82,6 +86,8 @@ usrp_e_impl::usrp_e_impl(const std::string &node){ _iface = usrp_e_iface::make(_node_fd); + clock_ctrl::sptr my_clk_ctrl = clock_ctrl::make(_iface); + //initialize the mboard mboard_init(); diff --git a/host/lib/usrp/usrp_e/usrp_e_impl.hpp b/host/lib/usrp/usrp_e/usrp_e_impl.hpp index 08ace2ffb..23e36ed05 100644 --- a/host/lib/usrp/usrp_e/usrp_e_impl.hpp +++ b/host/lib/usrp/usrp_e/usrp_e_impl.hpp @@ -17,6 +17,7 @@ #include "usrp_e_iface.hpp" #include <uhd/usrp/usrp_e.hpp> +#include <uhd/usrp/dboard_eeprom.hpp> #include <uhd/types/clock_config.hpp> #include <uhd/usrp/dboard_manager.hpp> @@ -105,11 +106,13 @@ private: uhd::usrp::dboard_manager::sptr _dboard_manager; //rx dboard functions and settings + uhd::usrp::dboard_eeprom_t _rx_db_eeprom; void rx_dboard_get(const wax::obj &, wax::obj &); void rx_dboard_set(const wax::obj &, const wax::obj &); wax_obj_proxy::sptr _rx_dboard_proxy; //tx dboard functions and settings + uhd::usrp::dboard_eeprom_t _tx_db_eeprom; void tx_dboard_get(const wax::obj &, wax::obj &); void tx_dboard_set(const wax::obj &, const wax::obj &); wax_obj_proxy::sptr _tx_dboard_proxy; diff --git a/host/lib/usrp/usrp_e/usrp_e_regs.hpp b/host/lib/usrp/usrp_e/usrp_e_regs.hpp index 46df8d089..7f35212f4 100644 --- a/host/lib/usrp/usrp_e/usrp_e_regs.hpp +++ b/host/lib/usrp/usrp_e/usrp_e_regs.hpp @@ -50,15 +50,11 @@ #define UE_REG_SPI_BASE UE_REG_SLAVE(2) -//spi slave constants (copied from usrp2, TODO FIXME) -#define UE_SPI_SS_AD9522 1 -#define UE_SPI_SS_AD9777 2 -#define UE_SPI_SS_RX_DAC 4 -#define UE_SPI_SS_RX_ADC 8 -#define UE_SPI_SS_RX_DB 16 -#define UE_SPI_SS_TX_DAC 32 -#define UE_SPI_SS_TX_ADC 64 -#define UE_SPI_SS_TX_DB 128 +//spi slave constants +#define UE_SPI_SS_AD9522 (1 << 3) +#define UE_SPI_SS_AD9862 (1 << 2) +#define UE_SPI_SS_TX_DB (1 << 1) +#define UE_SPI_SS_RX_DB (1 << 0) //////////////////////////////////////////////// // Slave 3 -- I2C Core |