From 010fff783bf658e79b0b32ad64a44af4e3f22b1e Mon Sep 17 00:00:00 2001 From: Thomas Tsou Date: Wed, 16 Oct 2013 00:31:18 -0400 Subject: Transceiver52M: Move reference select from compile time to database Enabling the external reference on UHD devices through the configure time switch is awkward. Use a database variable "TRX.Reference" with '0' or '1' value for internal and external references respectively. Use internal reference is no entry is defined. Signed-off-by: Thomas Tsou --- Transceiver52M/UHDDevice.cpp | 10 +++++----- Transceiver52M/USRPDevice.cpp | 2 +- Transceiver52M/USRPDevice.h | 2 +- Transceiver52M/USRPping.cpp | 2 +- Transceiver52M/radioDevice.h | 2 +- Transceiver52M/runTransceiver.cpp | 13 +++++++++++-- configure.ac | 9 --------- 7 files changed, 20 insertions(+), 20 deletions(-) diff --git a/Transceiver52M/UHDDevice.cpp b/Transceiver52M/UHDDevice.cpp index 03ff0ca..a392222 100644 --- a/Transceiver52M/UHDDevice.cpp +++ b/Transceiver52M/UHDDevice.cpp @@ -214,7 +214,7 @@ public: uhd_device(int sps, bool skip_rx); ~uhd_device(); - int open(const std::string &args); + int open(const std::string &args, bool extref); bool start(); bool stop(); void restart(uhd::time_spec_t ts); @@ -519,7 +519,7 @@ bool uhd_device::parse_dev_type() return true; } -int uhd_device::open(const std::string &args) +int uhd_device::open(const std::string &args, bool extref) { // Find UHD devices uhd::device_addr_t addr(args); @@ -542,9 +542,9 @@ int uhd_device::open(const std::string &args) if (!parse_dev_type()) return -1; -#ifdef EXTREF - set_ref_clk(true); -#endif + if (extref) + set_ref_clk(true); + // Create TX and RX streamers uhd::stream_args_t stream_args("sc16"); tx_stream = usrp_dev->get_tx_stream(stream_args); diff --git a/Transceiver52M/USRPDevice.cpp b/Transceiver52M/USRPDevice.cpp index 3a61e64..1fff124 100644 --- a/Transceiver52M/USRPDevice.cpp +++ b/Transceiver52M/USRPDevice.cpp @@ -90,7 +90,7 @@ USRPDevice::USRPDevice(int sps, bool skipRx) #endif } -int USRPDevice::open(const std::string &) +int USRPDevice::open(const std::string &, bool) { writeLock.unlock(); diff --git a/Transceiver52M/USRPDevice.h b/Transceiver52M/USRPDevice.h index f74db47..dc86f0e 100644 --- a/Transceiver52M/USRPDevice.h +++ b/Transceiver52M/USRPDevice.h @@ -105,7 +105,7 @@ private: USRPDevice(int sps, bool skipRx); /** Instantiate the USRP */ - int open(const std::string &); + int open(const std::string &, bool); /** Start the USRP */ bool start(); diff --git a/Transceiver52M/USRPping.cpp b/Transceiver52M/USRPping.cpp index 0ac5565..3c6289c 100644 --- a/Transceiver52M/USRPping.cpp +++ b/Transceiver52M/USRPping.cpp @@ -43,7 +43,7 @@ int main(int argc, char *argv[]) { RadioDevice *usrp = RadioDevice::make(52.0e6/192.0, 1); - usrp->open(""); + usrp->open(); TIMESTAMP timestamp; diff --git a/Transceiver52M/radioDevice.h b/Transceiver52M/radioDevice.h index 07ffd63..e08904b 100644 --- a/Transceiver52M/radioDevice.h +++ b/Transceiver52M/radioDevice.h @@ -39,7 +39,7 @@ class RadioDevice { static RadioDevice *make(int sps, bool skipRx = false); /** Initialize the USRP */ - virtual int open(const std::string &args)=0; + virtual int open(const std::string &args = "", bool extref = false)=0; /** Start the USRP */ virtual bool start()=0; diff --git a/Transceiver52M/runTransceiver.cpp b/Transceiver52M/runTransceiver.cpp index 775424a..6a7cc53 100644 --- a/Transceiver52M/runTransceiver.cpp +++ b/Transceiver52M/runTransceiver.cpp @@ -108,7 +108,7 @@ int testConfig(const char *filename) int main(int argc, char *argv[]) { - int trxPort, fail = 0; + int trxPort, radioType, extref = 0, fail = 0; std::string deviceArgs, logLevel, trxAddr; RadioDevice *usrp = NULL; RadioInterface *radio = NULL; @@ -138,12 +138,21 @@ int main(int argc, char *argv[]) logLevel = gConfig.getStr("Log.Level"); trxPort = gConfig.getNum("TRX.Port"); trxAddr = gConfig.getStr("TRX.IP"); + + if (gConfig.defines("TRX.Reference")) + extref = gConfig.getNum("TRX.Reference"); + + if (extref) + std::cout << "Using external clock reference" << std::endl; + else + std::cout << "Using internal clock reference" << std::endl; + gLogInit("transceiver", logLevel.c_str(), LOG_LOCAL7); srandom(time(NULL)); usrp = RadioDevice::make(SPS); - int radioType = usrp->open(deviceArgs); + radioType = usrp->open(deviceArgs, extref); if (radioType < 0) { LOG(ALERT) << "Transceiver exiting..." << std::endl; return EXIT_FAILURE; diff --git a/configure.ac b/configure.ac index 1fc58ea..42fcde6 100644 --- a/configure.ac +++ b/configure.ac @@ -73,11 +73,6 @@ AC_ARG_WITH(singledb, [ [enable single daughterboard use on USRP1]) ]) -AC_ARG_WITH(extref, [ - AS_HELP_STRING([--with-extref], - [enable external reference on UHD devices]) -]) - AS_IF([test "x$with_usrp1" = "xyes"], [ PKG_CHECK_MODULES(USRP, usrp >= 3.3) # Find and define supported SIMD extensions @@ -90,10 +85,6 @@ AS_IF([test "x$with_uhd" = "xyes"],[ AX_EXT ]) -AS_IF([test "x$with_extref" = "xyes"], [ - AC_DEFINE(EXTREF, 1, Define to 1 for external reference) -]) - AS_IF([test "x$with_singledb" = "xyes"], [ AC_DEFINE(SINGLEDB, 1, Define to 1 for single daughterboard) ]) -- cgit v1.2.3