aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJosh Blum <josh@joshknows.com>2010-05-03 11:30:17 +0000
committerJosh Blum <josh@joshknows.com>2010-05-03 11:30:17 +0000
commit2e222f4a77df389551d08b42a1bf947487d1442f (patch)
treee2c9018e3471591e0a912955a16a030d59f808bd
parentf92582169e35f96a945f745ce46326230b25888d (diff)
downloaduhd-2e222f4a77df389551d08b42a1bf947487d1442f.tar.gz
uhd-2e222f4a77df389551d08b42a1bf947487d1442f.tar.bz2
uhd-2e222f4a77df389551d08b42a1bf947487d1442f.zip
spi working, talked to ad9522
-rw-r--r--host/include/uhd/utils/assert.hpp9
-rw-r--r--host/lib/usrp/usrp_e/clock_ctrl.cpp14
-rw-r--r--host/lib/usrp/usrp_e/dboard_impl.cpp6
-rw-r--r--host/lib/usrp/usrp_e/usrp_e_iface.hpp9
-rw-r--r--host/lib/usrp/usrp_e/usrp_e_impl.cpp6
-rw-r--r--host/lib/usrp/usrp_e/usrp_e_impl.hpp3
-rw-r--r--host/lib/usrp/usrp_e/usrp_e_regs.hpp14
-rw-r--r--host/test/error_test.cpp5
-rw-r--r--host/utils/uhd_find_devices.cpp2
9 files changed, 50 insertions, 18 deletions
diff --git a/host/include/uhd/utils/assert.hpp b/host/include/uhd/utils/assert.hpp
index 6aca64f8c..577050aff 100644
--- a/host/include/uhd/utils/assert.hpp
+++ b/host/include/uhd/utils/assert.hpp
@@ -29,7 +29,14 @@
#include <string>
#ifndef BOOST_THROW_EXCEPTION
-#define BOOST_THROW_EXCEPTION(x) throw std::runtime_error("")
+ #include <boost/exception/exception.hpp>
+ #include <boost/current_function.hpp>
+ #define BOOST_THROW_EXCEPTION(x)\
+ ::boost::throw_exception( ::boost::enable_error_info(x) <<\
+ ::boost::throw_function(BOOST_CURRENT_FUNCTION) <<\
+ ::boost::throw_file(__FILE__) <<\
+ ::boost::throw_line((int)__LINE__) )
+
#endif
namespace uhd{
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
diff --git a/host/test/error_test.cpp b/host/test/error_test.cpp
index c5b0af45e..3f2479f99 100644
--- a/host/test/error_test.cpp
+++ b/host/test/error_test.cpp
@@ -17,7 +17,7 @@
#include <boost/test/unit_test.hpp>
#include <uhd/utils/assert.hpp>
-#include <boost/exception/diagnostic_information.hpp>
+//#include <boost/exception/diagnostic_information.hpp>
#include <vector>
#include <iostream>
@@ -30,11 +30,12 @@ BOOST_AUTO_TEST_CASE(test_assert_has){
//verify the std::has utility
BOOST_CHECK(std::has(vec, 2));
BOOST_CHECK(not std::has(vec, 1));
-
+/*
std::cout << "The output of the assert_has error:" << std::endl;
try{
uhd::assert_has(vec, 1, "prime");
}catch(const boost::exception &e){
std::cout << boost::diagnostic_information(e) << std::endl;
}
+*/
}
diff --git a/host/utils/uhd_find_devices.cpp b/host/utils/uhd_find_devices.cpp
index b778eeb68..8281c92bc 100644
--- a/host/utils/uhd_find_devices.cpp
+++ b/host/utils/uhd_find_devices.cpp
@@ -53,7 +53,7 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){
std::cout << "-- UHD Device " << i << std::endl;
std::cout << "--------------------------------------------------" << std::endl;
std::cout << device_addrs[i].to_pp_string() << std::endl << std::endl;
- //uhd::device::make(device_addrs[i]); //test make
+ uhd::device::make(device_addrs[i]); //test make
}
return 0;