diff options
Diffstat (limited to 'host')
26 files changed, 511 insertions, 317 deletions
diff --git a/host/CMakeLists.txt b/host/CMakeLists.txt index 75331ddfc..efc439af0 100644 --- a/host/CMakeLists.txt +++ b/host/CMakeLists.txt @@ -22,6 +22,7 @@ ENABLE_TESTING() ######################################################################## # Config Files (include order is important) ######################################################################## +INCLUDE(${CMAKE_SOURCE_DIR}/config/Component.cmake) INCLUDE(${CMAKE_SOURCE_DIR}/config/Python.cmake) INCLUDE(${CMAKE_SOURCE_DIR}/config/Version.cmake) INCLUDE(${CMAKE_SOURCE_DIR}/config/CPack.cmake) @@ -34,7 +35,6 @@ SET(LIBRARY_DIR lib${LIB_SUFFIX}) SET(INCLUDE_DIR include) SET(PKG_DATA_DIR share/uhd) SET(PKG_DOC_DIR share/doc/uhd) -MESSAGE(STATUS "Using install prefix: ${CMAKE_INSTALL_PREFIX}") ######################################################################## # Local Include Dir @@ -134,11 +134,38 @@ INSTALL(FILES ) ######################################################################## +# Register top level components +######################################################################## +SET(ENABLE_LIBUHD ON) #always enabled +LIBUHD_REGISTER_COMPONENT("Examples" ENABLE_EXAMPLES ON "ENABLE_LIBUHD" OFF) +LIBUHD_REGISTER_COMPONENT("Utils" ENABLE_UTILS ON "ENABLE_LIBUHD" OFF) +LIBUHD_REGISTER_COMPONENT("Tests" ENABLE_TESTS ON "ENABLE_LIBUHD" OFF) + +######################################################################## # Add the subdirectories ######################################################################## ADD_SUBDIRECTORY(docs) -ADD_SUBDIRECTORY(examples) + +IF(ENABLE_EXAMPLES) + ADD_SUBDIRECTORY(examples) +ENDIF(ENABLE_EXAMPLES) + ADD_SUBDIRECTORY(include) -ADD_SUBDIRECTORY(lib) -ADD_SUBDIRECTORY(test) -ADD_SUBDIRECTORY(utils) + +IF(ENABLE_LIBUHD) + ADD_SUBDIRECTORY(lib) +ENDIF(ENABLE_LIBUHD) + +IF(ENABLE_TESTS) + ADD_SUBDIRECTORY(test) +ENDIF(ENABLE_TESTS) + +IF(ENABLE_UTILS) + ADD_SUBDIRECTORY(utils) +ENDIF(ENABLE_UTILS) + +######################################################################## +# Print Summary +######################################################################## +UHD_PRINT_COMPONENT_SUMMARY() +MESSAGE(STATUS "Using install prefix: ${CMAKE_INSTALL_PREFIX}") diff --git a/host/config/Component.cmake b/host/config/Component.cmake new file mode 100644 index 000000000..0263b071f --- /dev/null +++ b/host/config/Component.cmake @@ -0,0 +1,86 @@ +# +# Copyright 2010 Ettus Research LLC +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +# + +######################################################################## +SET(_uhd_enabled_components "" CACHE INTERNAL "" FORCE) +SET(_uhd_disabled_components "" CACHE INTERNAL "" FORCE) + +######################################################################## +# Register a component into the system +# - name the component string name +# - var the global enable variable +# - enb the default enable setting +# - deps a list of dependencies +# - dis the default disable setting +######################################################################## +FUNCTION(LIBUHD_REGISTER_COMPONENT name var enb deps dis) + INCLUDE(CMakeDependentOption) + MESSAGE(STATUS "") + MESSAGE(STATUS "Configuring ${name} support...") + IF(DEFINED ${var}) + MESSAGE(STATUS "${name} support configured ${var}=${${var}}") + ELSE(DEFINED ${var}) #not defined: automatic enabling of component + MESSAGE(STATUS "${name} support configured automatically") + ENDIF(DEFINED ${var}) + + #setup the dependent option for this component + CMAKE_DEPENDENT_OPTION(${var} "enable ${name} support" ${enb} "${deps}" ${dis}) + + #remove previous occurrence of component in either list + IF(DEFINED _uhd_enabled_components) + LIST(REMOVE_ITEM _uhd_enabled_components ${name}) + ENDIF(DEFINED _uhd_enabled_components) + IF(DEFINED _uhd_disabled_components) + LIST(REMOVE_ITEM _uhd_disabled_components ${name}) + ENDIF(DEFINED _uhd_disabled_components) + + #append the component into one of the lists + IF(${var}) + MESSAGE(STATUS " Enabling ${name} support.") + LIST(APPEND _uhd_enabled_components ${name}) + ELSE(${var}) + MESSAGE(STATUS " Disabling ${name} support.") + LIST(APPEND _uhd_disabled_components ${name}) + ENDIF(${var}) + + #make components lists into global variables + SET(_uhd_enabled_components ${_uhd_enabled_components} CACHE INTERNAL "" FORCE) + SET(_uhd_disabled_components ${_uhd_disabled_components} CACHE INTERNAL "" FORCE) +ENDFUNCTION(LIBUHD_REGISTER_COMPONENT) + +######################################################################## +# Print the registered component summary +######################################################################## +FUNCTION(UHD_PRINT_COMPONENT_SUMMARY) + MESSAGE(STATUS "") + MESSAGE(STATUS "######################################################") + MESSAGE(STATUS "# LibUHD enabled components ") + MESSAGE(STATUS "######################################################") + FOREACH(comp ${_uhd_enabled_components}) + MESSAGE(STATUS " * ${comp}") + ENDFOREACH(comp) + + MESSAGE(STATUS "") + MESSAGE(STATUS "######################################################") + MESSAGE(STATUS "# LibUHD disabled components ") + MESSAGE(STATUS "######################################################") + FOREACH(comp ${_uhd_disabled_components}) + MESSAGE(STATUS " * ${comp}") + ENDFOREACH(comp) + + MESSAGE(STATUS "") +ENDFUNCTION(UHD_PRINT_COMPONENT_SUMMARY) diff --git a/host/docs/CMakeLists.txt b/host/docs/CMakeLists.txt index 296ce9922..d6a7801bf 100644 --- a/host/docs/CMakeLists.txt +++ b/host/docs/CMakeLists.txt @@ -41,10 +41,16 @@ FIND_PROGRAM(RST2HTML rst2html) IF(${RST2HTML} STREQUAL "RST2HTML-NOTFOUND") MESSAGE(STATUS "Checking for rst2html (docutils) - not found") MESSAGE(STATUS " Disabled generation of HTML manual.") + SET(HAVE_RST2HTML FALSE) ELSE(${RST2HTML} STREQUAL "RST2HTML-NOTFOUND") MESSAGE(STATUS "Checking for rst2html (docutils) - found") MESSAGE(STATUS " Enabled generation of HTML manual.") + SET(HAVE_RST2HTML TRUE) +ENDIF(${RST2HTML} STREQUAL "RST2HTML-NOTFOUND") + +LIBUHD_REGISTER_COMPONENT("Manual" ENABLE_MANUAL ON "HAVE_RST2HTML" OFF) +IF(ENABLE_MANUAL) #setup rst2html options SET(stylesheet ${CMAKE_CURRENT_SOURCE_DIR}/style.css) SET(rst2html_options @@ -73,7 +79,7 @@ ELSE(${RST2HTML} STREQUAL "RST2HTML-NOTFOUND") #make the html manual a build-time dependency ADD_CUSTOM_TARGET(manual_html ALL DEPENDS ${manual_html_files}) -ENDIF(${RST2HTML} STREQUAL "RST2HTML-NOTFOUND") +ENDIF(ENABLE_MANUAL) INSTALL(FILES ${manual_sources} DESTINATION ${PKG_DOC_DIR}/manual/rst) @@ -84,7 +90,9 @@ MESSAGE(STATUS "") MESSAGE(STATUS "Checking for doxygen") INCLUDE(FindDoxygen) -IF(DOXYGEN_FOUND) +LIBUHD_REGISTER_COMPONENT("Doxygen" ENABLE_DOXYGEN ON "DOXYGEN_FOUND" OFF) + +IF(ENABLE_DOXYGEN) MESSAGE(STATUS " Enabled generation of Doxygen documentation.") #generate the doxygen configuration file @@ -105,6 +113,6 @@ IF(DOXYGEN_FOUND) #make the doxygen generation a built-time dependency ADD_CUSTOM_TARGET(doxygen_docs ALL DEPENDS ${CMAKE_CURRENT_BINARY_DIR_DOXYGEN}) INSTALL(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR_DOXYGEN} DESTINATION ${PKG_DOC_DIR}) -ELSE(DOXYGEN_FOUND) +ELSE(ENABLE_DOXYGEN) MESSAGE(STATUS " Disabled generation of Doxygen documentation.") -ENDIF(DOXYGEN_FOUND) +ENDIF(ENABLE_DOXYGEN) diff --git a/host/docs/build.rst b/host/docs/build.rst index a41ce8331..812b5c1a9 100644 --- a/host/docs/build.rst +++ b/host/docs/build.rst @@ -39,7 +39,7 @@ Other compilers have not been tested yet or confirmed working. CMake ^^^^^^^^^^^^^^^^ * **Purpose:** generates project build files -* **Version:** at least 2.8 +* **Version:** at least 2.6 * **Usage:** build time (required) * **Download URL:** http://www.cmake.org/cmake/resources/software.html diff --git a/host/docs/usrp2.rst b/host/docs/usrp2.rst index 8e5743102..3031a0075 100644 --- a/host/docs/usrp2.rst +++ b/host/docs/usrp2.rst @@ -101,7 +101,7 @@ On some systems, the firewall will block UDP broadcast packets. It is recommended that you change or disable your firewall settings. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -Multiple device configuration +Multiple devices per host ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ For maximum throughput, one ethernet interface per USRP2 is recommended, although multiple devices may be connected via a gigabit ethernet switch. @@ -210,6 +210,66 @@ Example device address string representation for 2 USRP2s with IPv4 addresses 19 addr0=192.168.10.2, addr1=192.168.20.2 ------------------------------------------------------------------------ +Using the MIMO Cable +------------------------------------------------------------------------ +The MIMO cable allows two USRP devices to share reference clocks, +time synchronization, and the ethernet interface. + +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +Shared ethernet mode +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +In shared ethernet mode, +only one device in the configuration can be attached to the ethernet. +This device will be referred to as the master, and the other device, the slave. + +* The master provides reference clock and time synchronization to the slave. +* All data passing between the host and the slave is routed over the MIMO cable. +* Both master and slave must have different IPv4 addresses in the same subnet. +* The master and slave may be used individually or in a multi-device configuration. +* External clocking is optional, and should only be supplied to the master device. +* The role of slave and master may be switched with the "mimo_mode" device address (see dual ethernet mode). + +Example device address string representation for 2 USRP2s with IPv4 addresses 192.168.10.2 (master) and 192.168.10.3 (slave) +:: + + -- Multi-device example -- + + addr0=192.168.10.2, addr1=192.168.10.3 + + -- Two single devices example -- + + addr=192.168.10.2 + + addr=192.168.10.3 + +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +Dual ethernet mode +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +In dual ethernet mode, +both devices in the configuration must be attached to the ethernet. +One of the devices in the configuration will be configured to provide synchronization. +This device will be referred to as the master, and the other device, the slave. + +* The master provides reference clock and time synchronization to the slave. +* The devices require the special device address argument "mimo_mode" set. +* Both master and slave must have different IPv4 addresses in different subnets. +* The master and slave may be used individually or in a multi-device configuration. +* External clocking is optional, and should only be supplied to the master device. + +Example device address string representation for 2 USRP2s with IPv4 addresses 192.168.10.2 (master) and 192.168.20.2 (slave) +:: + + -- Multi-device example -- + + addr0=192.168.10.2, mimo_mode0=master, addr1=192.168.20.2, mimo_mode1=slave + + -- Two single devices example -- + + addr=192.168.10.2, mimo_mode=master + + addr=192.168.20.2, mimo_mode=slave + +------------------------------------------------------------------------ Hardware setup notes ------------------------------------------------------------------------ @@ -220,7 +280,7 @@ The LEDs on the front panel can be useful in debugging hardware and software iss The LEDs reveal the following about the state of the device: * **LED A:** transmitting -* **LED B:** serdes link +* **LED B:** mimo cable link * **LED C:** receiving * **LED D:** firmware loaded * **LED E:** reference lock diff --git a/host/include/uhd/types/clock_config.hpp b/host/include/uhd/types/clock_config.hpp index 9342fbb7b..5966dcf3a 100644 --- a/host/include/uhd/types/clock_config.hpp +++ b/host/include/uhd/types/clock_config.hpp @@ -32,12 +32,10 @@ namespace uhd{ REF_AUTO = 'a', //automatic (device specific) REF_INT = 'i', //internal reference REF_SMA = 's', //external sma port - REF_MIMO = 'm' //mimo cable (usrp2 only) } ref_source; enum pps_source_t { PPS_INT = 'i', //there is no internal PPS_SMA = 's', //external sma port - PPS_MIMO = 'm' //mimo cable (usrp2 only) } pps_source; enum pps_polarity_t { PPS_NEG = 'n', //negative edge diff --git a/host/lib/CMakeLists.txt b/host/lib/CMakeLists.txt index a198b476a..28e4bcca2 100644 --- a/host/lib/CMakeLists.txt +++ b/host/lib/CMakeLists.txt @@ -61,32 +61,35 @@ MACRO(LIBUHD_PYTHON_GEN_SOURCE pyfile outfile) LIBUHD_APPEND_SOURCES(${outfile}) ENDMACRO(LIBUHD_PYTHON_GEN_SOURCE) -MACRO(LIBUHD_REGISTER_COMPONENT name var auto) - MESSAGE(STATUS "") - MESSAGE(STATUS "Configuring ${name} support...") - IF(DEFINED ${var}) - MESSAGE(STATUS "${name} support configured ${var}=${${var}}") - ELSE(DEFINED ${var}) #not defined: automatic enabling of component - SET(${var} ${auto}) - MESSAGE(STATUS "${name} support configured automatically") - ENDIF(DEFINED ${var}) - OPTION(${var} "enable ${name} support" ${${var}}) - IF(${var}) - MESSAGE(STATUS " Enabling ${name} support.") - LIST(APPEND _libuhd_enabled_components ${name}) - ELSE(${var}) - MESSAGE(STATUS " Disabling ${name} support.") - LIST(APPEND _libuhd_disabled_components ${name}) - ENDIF(${var}) -ENDMACRO(LIBUHD_REGISTER_COMPONENT) +MACRO(INCLUDE_SUBDIRECTORY subdir) + #insert the current directories on the front of the list + LIST(INSERT _cmake_source_dirs 0 ${CMAKE_CURRENT_SOURCE_DIR}) + LIST(INSERT _cmake_binary_dirs 0 ${CMAKE_CURRENT_BINARY_DIR}) + + #set the current directories to the names of the subdirs + SET(CMAKE_CURRENT_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/${subdir}) + SET(CMAKE_CURRENT_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/${subdir}) + + #include the subdirectory CMakeLists to run it + FILE(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) + INCLUDE(${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt) + + #reset the value of the current directories + LIST(GET _cmake_source_dirs 0 CMAKE_CURRENT_SOURCE_DIR) + LIST(GET _cmake_binary_dirs 0 CMAKE_CURRENT_BINARY_DIR) + + #pop the subdir names of the front of the list + LIST(REMOVE_AT _cmake_source_dirs 0) + LIST(REMOVE_AT _cmake_binary_dirs 0) +ENDMACRO(INCLUDE_SUBDIRECTORY) ######################################################################## -# Include CMakeLists.txt from subdirectories +# Include subdirectories (different than add) ######################################################################## -INCLUDE(${CMAKE_CURRENT_SOURCE_DIR}/ic_reg_maps/CMakeLists.txt) -INCLUDE(${CMAKE_CURRENT_SOURCE_DIR}/transport/CMakeLists.txt) -INCLUDE(${CMAKE_CURRENT_SOURCE_DIR}/usrp/CMakeLists.txt) -INCLUDE(${CMAKE_CURRENT_SOURCE_DIR}/utils/CMakeLists.txt) +INCLUDE_SUBDIRECTORY(ic_reg_maps) +INCLUDE_SUBDIRECTORY(transport) +INCLUDE_SUBDIRECTORY(usrp) +INCLUDE_SUBDIRECTORY(utils) ######################################################################## # Append to the list of sources for lib uhd @@ -128,24 +131,3 @@ INSTALL(TARGETS uhd ARCHIVE DESTINATION ${LIBRARY_DIR} # .lib file RUNTIME DESTINATION ${LIBRARY_DIR} # .dll file ) - -######################################################################## -# Print configuration summary -######################################################################## -MESSAGE(STATUS "") -MESSAGE(STATUS "######################################################") -MESSAGE(STATUS "# LibUHD enabled components ") -MESSAGE(STATUS "######################################################") -FOREACH(comp ${_libuhd_enabled_components}) - MESSAGE(STATUS " * ${comp}") -ENDFOREACH(comp) - -MESSAGE(STATUS "") -MESSAGE(STATUS "######################################################") -MESSAGE(STATUS "# LibUHD disabled components ") -MESSAGE(STATUS "######################################################") -FOREACH(comp ${_libuhd_disabled_components}) - MESSAGE(STATUS " * ${comp}") -ENDFOREACH(comp) - -MESSAGE(STATUS "") diff --git a/host/lib/ic_reg_maps/CMakeLists.txt b/host/lib/ic_reg_maps/CMakeLists.txt index ac051b843..67a63c32b 100644 --- a/host/lib/ic_reg_maps/CMakeLists.txt +++ b/host/lib/ic_reg_maps/CMakeLists.txt @@ -15,76 +15,78 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. # -#This file will be included by cmake, use absolute paths! +######################################################################## +# This file included, use CMake directory variables +######################################################################## -INCLUDE_DIRECTORIES(${CMAKE_BINARY_DIR}/lib/ic_reg_maps) +INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}) LIBUHD_PYTHON_GEN_SOURCE( - ${CMAKE_SOURCE_DIR}/lib/ic_reg_maps/gen_adf4350_regs.py - ${CMAKE_BINARY_DIR}/lib/ic_reg_maps/adf4350_regs.hpp + ${CMAKE_CURRENT_SOURCE_DIR}/gen_adf4350_regs.py + ${CMAKE_CURRENT_BINARY_DIR}/adf4350_regs.hpp ) LIBUHD_PYTHON_GEN_SOURCE( - ${CMAKE_SOURCE_DIR}/lib/ic_reg_maps/gen_adf4360_regs.py - ${CMAKE_BINARY_DIR}/lib/ic_reg_maps/adf4360_regs.hpp + ${CMAKE_CURRENT_SOURCE_DIR}/gen_adf4360_regs.py + ${CMAKE_CURRENT_BINARY_DIR}/adf4360_regs.hpp ) LIBUHD_PYTHON_GEN_SOURCE( - ${CMAKE_SOURCE_DIR}/lib/ic_reg_maps/gen_ad9510_regs.py - ${CMAKE_BINARY_DIR}/lib/ic_reg_maps/ad9510_regs.hpp + ${CMAKE_CURRENT_SOURCE_DIR}/gen_ad9510_regs.py + ${CMAKE_CURRENT_BINARY_DIR}/ad9510_regs.hpp ) LIBUHD_PYTHON_GEN_SOURCE( - ${CMAKE_SOURCE_DIR}/lib/ic_reg_maps/gen_ad9777_regs.py - ${CMAKE_BINARY_DIR}/lib/ic_reg_maps/ad9777_regs.hpp + ${CMAKE_CURRENT_SOURCE_DIR}/gen_ad9777_regs.py + ${CMAKE_CURRENT_BINARY_DIR}/ad9777_regs.hpp ) LIBUHD_PYTHON_GEN_SOURCE( - ${CMAKE_SOURCE_DIR}/lib/ic_reg_maps/gen_ad5623_regs.py - ${CMAKE_BINARY_DIR}/lib/ic_reg_maps/ad5623_regs.hpp + ${CMAKE_CURRENT_SOURCE_DIR}/gen_ad5623_regs.py + ${CMAKE_CURRENT_BINARY_DIR}/ad5623_regs.hpp ) LIBUHD_PYTHON_GEN_SOURCE( - ${CMAKE_SOURCE_DIR}/lib/ic_reg_maps/gen_ad7922_regs.py - ${CMAKE_BINARY_DIR}/lib/ic_reg_maps/ad7922_regs.hpp + ${CMAKE_CURRENT_SOURCE_DIR}/gen_ad7922_regs.py + ${CMAKE_CURRENT_BINARY_DIR}/ad7922_regs.hpp ) LIBUHD_PYTHON_GEN_SOURCE( - ${CMAKE_SOURCE_DIR}/lib/ic_reg_maps/gen_max2829_regs.py - ${CMAKE_BINARY_DIR}/lib/ic_reg_maps/max2829_regs.hpp + ${CMAKE_CURRENT_SOURCE_DIR}/gen_max2829_regs.py + ${CMAKE_CURRENT_BINARY_DIR}/max2829_regs.hpp ) LIBUHD_PYTHON_GEN_SOURCE( - ${CMAKE_SOURCE_DIR}/lib/ic_reg_maps/gen_max2118_regs.py - ${CMAKE_BINARY_DIR}/lib/ic_reg_maps/max2118_regs.hpp + ${CMAKE_CURRENT_SOURCE_DIR}/gen_max2118_regs.py + ${CMAKE_CURRENT_BINARY_DIR}/max2118_regs.hpp ) LIBUHD_PYTHON_GEN_SOURCE( - ${CMAKE_SOURCE_DIR}/lib/ic_reg_maps/gen_max2112_regs.py - ${CMAKE_BINARY_DIR}/lib/ic_reg_maps/max2112_regs.hpp + ${CMAKE_CURRENT_SOURCE_DIR}/gen_max2112_regs.py + ${CMAKE_CURRENT_BINARY_DIR}/max2112_regs.hpp ) LIBUHD_PYTHON_GEN_SOURCE( - ${CMAKE_SOURCE_DIR}/lib/ic_reg_maps/gen_max2112_regs.py - ${CMAKE_BINARY_DIR}/lib/ic_reg_maps/max2112_regs.hpp + ${CMAKE_CURRENT_SOURCE_DIR}/gen_max2112_regs.py + ${CMAKE_CURRENT_BINARY_DIR}/max2112_regs.hpp ) LIBUHD_PYTHON_GEN_SOURCE( - ${CMAKE_SOURCE_DIR}/lib/ic_reg_maps/gen_ad9862_regs.py - ${CMAKE_BINARY_DIR}/lib/ic_reg_maps/ad9862_regs.hpp + ${CMAKE_CURRENT_SOURCE_DIR}/gen_ad9862_regs.py + ${CMAKE_CURRENT_BINARY_DIR}/ad9862_regs.hpp ) LIBUHD_PYTHON_GEN_SOURCE( - ${CMAKE_SOURCE_DIR}/lib/ic_reg_maps/gen_ad9522_regs.py - ${CMAKE_BINARY_DIR}/lib/ic_reg_maps/ad9522_regs.hpp + ${CMAKE_CURRENT_SOURCE_DIR}/gen_ad9522_regs.py + ${CMAKE_CURRENT_BINARY_DIR}/ad9522_regs.hpp ) LIBUHD_PYTHON_GEN_SOURCE( - ${CMAKE_SOURCE_DIR}/lib/ic_reg_maps/gen_ads62p44_regs.py - ${CMAKE_BINARY_DIR}/lib/ic_reg_maps/ads62p44_regs.hpp - ) + ${CMAKE_CURRENT_SOURCE_DIR}/gen_ads62p44_regs.py + ${CMAKE_CURRENT_BINARY_DIR}/ads62p44_regs.hpp +) LIBUHD_PYTHON_GEN_SOURCE( - ${CMAKE_SOURCE_DIR}/lib/ic_reg_maps/gen_tuner_4937di5_regs.py - ${CMAKE_BINARY_DIR}/lib/ic_reg_maps/tuner_4937di5_regs.hpp + ${CMAKE_CURRENT_SOURCE_DIR}/gen_tuner_4937di5_regs.py + ${CMAKE_CURRENT_BINARY_DIR}/tuner_4937di5_regs.hpp ) diff --git a/host/lib/transport/CMakeLists.txt b/host/lib/transport/CMakeLists.txt index b5f1fc940..de2f1fdd0 100644 --- a/host/lib/transport/CMakeLists.txt +++ b/host/lib/transport/CMakeLists.txt @@ -15,37 +15,36 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. # -#This file will be included by cmake, use absolute paths! +######################################################################## +# This file included, use CMake directory variables +######################################################################## ######################################################################## # Setup libusb ######################################################################## -MESSAGE(STATUS "") -MESSAGE(STATUS "Configuring USB support...") -LIST(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/lib/transport) +LIST(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}) FIND_PACKAGE(USB1 REQUIRED) -IF(LIBUSB_FOUND) +LIBUHD_REGISTER_COMPONENT("USB" ENABLE_USB ON "ENABLE_LIBUHD;LIBUSB_FOUND" OFF) + +IF(ENABLE_USB) MESSAGE(STATUS "USB support enabled via libusb.") INCLUDE_DIRECTORIES(${LIBUSB_INCLUDE_DIR}) LIBUHD_APPEND_LIBS(${LIBUSB_LIBRARIES}) LIBUHD_APPEND_SOURCES( - ${CMAKE_SOURCE_DIR}/lib/transport/libusb1_control.cpp - ${CMAKE_SOURCE_DIR}/lib/transport/libusb1_zero_copy.cpp - ${CMAKE_SOURCE_DIR}/lib/transport/libusb1_base.cpp - ${CMAKE_SOURCE_DIR}/lib/transport/libusb1_base.hpp + ${CMAKE_CURRENT_SOURCE_DIR}/libusb1_control.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/libusb1_zero_copy.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/libusb1_base.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/libusb1_base.hpp ) IF(MSVC) #include our custom stdint for libusb - INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/lib/transport/msvc) + INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/msvc) ENDIF(MSVC) - SET(HAVE_USB_SUPPORT TRUE) -ELSE(LIBUSB_FOUND) - MESSAGE(STATUS "USB support disabled.") +ELSE(ENABLE_USB) LIBUHD_APPEND_SOURCES( - ${CMAKE_SOURCE_DIR}/lib/transport/usb_dummy_impl.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/usb_dummy_impl.cpp ) - SET(HAVE_USB_SUPPORT FALSE) -ENDIF(LIBUSB_FOUND) +ENDIF(ENABLE_USB) ######################################################################## # Check for SIMD headers @@ -90,29 +89,29 @@ ENDIF(HAVE_IFADDRS_H) # Append to the list of sources for lib uhd ######################################################################## LIBUHD_PYTHON_GEN_SOURCE( - ${CMAKE_SOURCE_DIR}/lib/transport/gen_vrt_if_packet.py - ${CMAKE_BINARY_DIR}/lib/transport/vrt_if_packet.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/gen_vrt_if_packet.py + ${CMAKE_CURRENT_BINARY_DIR}/vrt_if_packet.cpp ) LIBUHD_PYTHON_GEN_SOURCE( - ${CMAKE_SOURCE_DIR}/lib/transport/gen_convert_types.py - ${CMAKE_BINARY_DIR}/lib/transport/convert_types.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/gen_convert_types.py + ${CMAKE_CURRENT_BINARY_DIR}/convert_types.cpp ) # append this directory to the include path so the generated convert types # can include the implementation convert types file in the source directory -INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/lib/transport) +INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}) # make the generated convert types depend on the implementation header SET_SOURCE_FILES_PROPERTIES( - ${CMAKE_BINARY_DIR}/lib/transport/convert_types.cpp PROPERTIES - OBJECT_DEPENDS ${CMAKE_SOURCE_DIR}/lib/transport/convert_types_impl.hpp + ${CMAKE_CURRENT_BINARY_DIR}/convert_types.cpp PROPERTIES + OBJECT_DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/convert_types_impl.hpp ) LIBUHD_APPEND_SOURCES( - ${CMAKE_SOURCE_DIR}/lib/transport/if_addrs.cpp - ${CMAKE_SOURCE_DIR}/lib/transport/udp_simple.cpp - ${CMAKE_SOURCE_DIR}/lib/transport/udp_zero_copy_asio.cpp - ${CMAKE_SOURCE_DIR}/lib/transport/vrt_packet_handler.hpp - ${CMAKE_SOURCE_DIR}/lib/transport/zero_copy.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/if_addrs.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/udp_simple.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/udp_zero_copy_asio.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/vrt_packet_handler.hpp + ${CMAKE_CURRENT_SOURCE_DIR}/zero_copy.cpp ) diff --git a/host/lib/usrp/CMakeLists.txt b/host/lib/usrp/CMakeLists.txt index bd26d29a1..9dc74a5fe 100644 --- a/host/lib/usrp/CMakeLists.txt +++ b/host/lib/usrp/CMakeLists.txt @@ -15,25 +15,26 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. # -#This file will be included by cmake, use absolute paths! - +######################################################################## +# This file included, use CMake directory variables +######################################################################## LIBUHD_APPEND_SOURCES( - ${CMAKE_SOURCE_DIR}/lib/usrp/dboard_base.cpp - ${CMAKE_SOURCE_DIR}/lib/usrp/dboard_eeprom.cpp - ${CMAKE_SOURCE_DIR}/lib/usrp/dboard_id.cpp - ${CMAKE_SOURCE_DIR}/lib/usrp/dboard_iface.cpp - ${CMAKE_SOURCE_DIR}/lib/usrp/dboard_manager.cpp - ${CMAKE_SOURCE_DIR}/lib/usrp/dsp_utils.cpp - ${CMAKE_SOURCE_DIR}/lib/usrp/mboard_eeprom.cpp - ${CMAKE_SOURCE_DIR}/lib/usrp/misc_utils.cpp - ${CMAKE_SOURCE_DIR}/lib/usrp/multi_usrp.cpp - ${CMAKE_SOURCE_DIR}/lib/usrp/single_usrp.cpp - ${CMAKE_SOURCE_DIR}/lib/usrp/subdev_spec.cpp - ${CMAKE_SOURCE_DIR}/lib/usrp/tune_helper.cpp - ${CMAKE_SOURCE_DIR}/lib/usrp/wrapper_utils.hpp + ${CMAKE_CURRENT_SOURCE_DIR}/dboard_base.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/dboard_eeprom.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/dboard_id.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/dboard_iface.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/dboard_manager.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/dsp_utils.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/mboard_eeprom.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/misc_utils.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/multi_usrp.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/single_usrp.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/subdev_spec.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/tune_helper.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/wrapper_utils.hpp ) -INCLUDE(${CMAKE_SOURCE_DIR}/lib/usrp/dboard/CMakeLists.txt) -INCLUDE(${CMAKE_SOURCE_DIR}/lib/usrp/usrp1/CMakeLists.txt) -INCLUDE(${CMAKE_SOURCE_DIR}/lib/usrp/usrp2/CMakeLists.txt) -INCLUDE(${CMAKE_SOURCE_DIR}/lib/usrp/usrp_e100/CMakeLists.txt) +INCLUDE_SUBDIRECTORY(dboard) +INCLUDE_SUBDIRECTORY(usrp1) +INCLUDE_SUBDIRECTORY(usrp2) +INCLUDE_SUBDIRECTORY(usrp_e100) diff --git a/host/lib/usrp/dboard/CMakeLists.txt b/host/lib/usrp/dboard/CMakeLists.txt index 79cd42d18..7bd201294 100644 --- a/host/lib/usrp/dboard/CMakeLists.txt +++ b/host/lib/usrp/dboard/CMakeLists.txt @@ -15,16 +15,18 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. # -#This file will be included by cmake, use absolute paths! +######################################################################## +# This file included, use CMake directory variables +######################################################################## LIBUHD_APPEND_SOURCES( - ${CMAKE_SOURCE_DIR}/lib/usrp/dboard/db_basic_and_lf.cpp - ${CMAKE_SOURCE_DIR}/lib/usrp/dboard/db_rfx.cpp - ${CMAKE_SOURCE_DIR}/lib/usrp/dboard/db_xcvr2450.cpp - ${CMAKE_SOURCE_DIR}/lib/usrp/dboard/db_wbx.cpp - ${CMAKE_SOURCE_DIR}/lib/usrp/dboard/db_dbsrx.cpp - ${CMAKE_SOURCE_DIR}/lib/usrp/dboard/db_unknown.cpp - ${CMAKE_SOURCE_DIR}/lib/usrp/dboard/db_tvrx.cpp - ${CMAKE_SOURCE_DIR}/lib/usrp/dboard/db_dbsrx2.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/db_basic_and_lf.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/db_rfx.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/db_xcvr2450.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/db_wbx.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/db_dbsrx.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/db_unknown.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/db_tvrx.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/db_dbsrx2.cpp ) diff --git a/host/lib/usrp/dboard/db_dbsrx.cpp b/host/lib/usrp/dboard/db_dbsrx.cpp index 7edc1822c..7250136f5 100644 --- a/host/lib/usrp/dboard/db_dbsrx.cpp +++ b/host/lib/usrp/dboard/db_dbsrx.cpp @@ -376,7 +376,7 @@ void dbsrx::set_lo_freq(double target_freq){ read_reg(0x0, 0x0); //allow for setup time before checking condition again - boost::this_thread::sleep(boost::posix_time::milliseconds(1)); + boost::this_thread::sleep(boost::posix_time::milliseconds(10)); } if(dbsrx_debug) std::cerr << boost::format( diff --git a/host/lib/usrp/usrp1/CMakeLists.txt b/host/lib/usrp/usrp1/CMakeLists.txt index 8b6ba78d2..519e17bfa 100644 --- a/host/lib/usrp/usrp1/CMakeLists.txt +++ b/host/lib/usrp/usrp1/CMakeLists.txt @@ -15,37 +15,34 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. # -#This file will be included by cmake, use absolute paths! +######################################################################## +# This file included, use CMake directory variables +######################################################################## ######################################################################## # Conditionally configure the USRP1 support ######################################################################## -LIBUHD_REGISTER_COMPONENT("USRP1" ENABLE_USRP1 ${HAVE_USB_SUPPORT}) - -#sanity check when USRP1 support enabled -IF(ENABLE_USRP1 AND NOT HAVE_USB_SUPPORT) - MESSAGE(FATAL_ERROR "USRP1 support enabled without USB support") -ENDIF(ENABLE_USRP1 AND NOT HAVE_USB_SUPPORT) +LIBUHD_REGISTER_COMPONENT("USRP1" ENABLE_USRP1 ON "ENABLE_LIBUHD;ENABLE_USB" OFF) IF(ENABLE_USRP1) INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/../firmware/fx2/common) LIBUHD_APPEND_SOURCES( - ${CMAKE_SOURCE_DIR}/lib/usrp/usrp1/clock_ctrl.cpp - ${CMAKE_SOURCE_DIR}/lib/usrp/usrp1/clock_ctrl.hpp - ${CMAKE_SOURCE_DIR}/lib/usrp/usrp1/codec_ctrl.cpp - ${CMAKE_SOURCE_DIR}/lib/usrp/usrp1/codec_ctrl.hpp - ${CMAKE_SOURCE_DIR}/lib/usrp/usrp1/codec_impl.cpp - ${CMAKE_SOURCE_DIR}/lib/usrp/usrp1/dboard_impl.cpp - ${CMAKE_SOURCE_DIR}/lib/usrp/usrp1/dboard_iface.cpp - ${CMAKE_SOURCE_DIR}/lib/usrp/usrp1/dsp_impl.cpp - ${CMAKE_SOURCE_DIR}/lib/usrp/usrp1/io_impl.cpp - ${CMAKE_SOURCE_DIR}/lib/usrp/usrp1/mboard_impl.cpp - ${CMAKE_SOURCE_DIR}/lib/usrp/usrp1/usrp1_iface.cpp - ${CMAKE_SOURCE_DIR}/lib/usrp/usrp1/usrp1_iface.hpp - ${CMAKE_SOURCE_DIR}/lib/usrp/usrp1/usrp1_impl.cpp - ${CMAKE_SOURCE_DIR}/lib/usrp/usrp1/usrp1_impl.hpp - ${CMAKE_SOURCE_DIR}/lib/usrp/usrp1/usrp1_ctrl.cpp - ${CMAKE_SOURCE_DIR}/lib/usrp/usrp1/usrp1_ctrl.hpp + ${CMAKE_CURRENT_SOURCE_DIR}/clock_ctrl.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/clock_ctrl.hpp + ${CMAKE_CURRENT_SOURCE_DIR}/codec_ctrl.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/codec_ctrl.hpp + ${CMAKE_CURRENT_SOURCE_DIR}/codec_impl.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/dboard_impl.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/dboard_iface.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/dsp_impl.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/io_impl.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/mboard_impl.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/usrp1_iface.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/usrp1_iface.hpp + ${CMAKE_CURRENT_SOURCE_DIR}/usrp1_impl.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/usrp1_impl.hpp + ${CMAKE_CURRENT_SOURCE_DIR}/usrp1_ctrl.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/usrp1_ctrl.hpp ) ENDIF(ENABLE_USRP1) diff --git a/host/lib/usrp/usrp1/dsp_impl.cpp b/host/lib/usrp/usrp1/dsp_impl.cpp index e9a5e60a6..370f4831f 100644 --- a/host/lib/usrp/usrp1/dsp_impl.cpp +++ b/host/lib/usrp/usrp1/dsp_impl.cpp @@ -102,7 +102,7 @@ void usrp1_impl::rx_dsp_set(const wax::obj &key_, const wax::obj &val){ ("0", FR_RX_FREQ_0) ("1", FR_RX_FREQ_1) ("2", FR_RX_FREQ_2) ("3", FR_RX_FREQ_3) ; - _iface->poke32(freq_name_to_reg_val[key.name], reg_word); + _iface->poke32(freq_name_to_reg_val[key.name], ~reg_word + 1); _rx_dsp_freqs[key.name] = new_freq; return; } diff --git a/host/lib/usrp/usrp2/CMakeLists.txt b/host/lib/usrp/usrp2/CMakeLists.txt index afd69cae9..d83c82063 100644 --- a/host/lib/usrp/usrp2/CMakeLists.txt +++ b/host/lib/usrp/usrp2/CMakeLists.txt @@ -15,34 +15,34 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. # -#This file will be included by cmake, use absolute paths! +######################################################################## +# This file included, use CMake directory variables +######################################################################## ######################################################################## # Conditionally configure the USRP2 support ######################################################################## -LIBUHD_REGISTER_COMPONENT("USRP2" ENABLE_USRP2 TRUE) +LIBUHD_REGISTER_COMPONENT("USRP2" ENABLE_USRP2 ON "ENABLE_LIBUHD" OFF) IF(ENABLE_USRP2) LIBUHD_APPEND_SOURCES( - ${CMAKE_SOURCE_DIR}/lib/usrp/usrp2/clock_ctrl.cpp - ${CMAKE_SOURCE_DIR}/lib/usrp/usrp2/clock_ctrl.hpp - ${CMAKE_SOURCE_DIR}/lib/usrp/usrp2/codec_ctrl.cpp - ${CMAKE_SOURCE_DIR}/lib/usrp/usrp2/codec_ctrl.hpp - ${CMAKE_SOURCE_DIR}/lib/usrp/usrp2/codec_impl.cpp - ${CMAKE_SOURCE_DIR}/lib/usrp/usrp2/dboard_impl.cpp - ${CMAKE_SOURCE_DIR}/lib/usrp/usrp2/dboard_iface.cpp - ${CMAKE_SOURCE_DIR}/lib/usrp/usrp2/dsp_impl.cpp - ${CMAKE_SOURCE_DIR}/lib/usrp/usrp2/gps_ctrl.hpp - ${CMAKE_SOURCE_DIR}/lib/usrp/usrp2/gps_ctrl.cpp - ${CMAKE_SOURCE_DIR}/lib/usrp/usrp2/io_impl.cpp - ${CMAKE_SOURCE_DIR}/lib/usrp/usrp2/mboard_impl.cpp - ${CMAKE_SOURCE_DIR}/lib/usrp/usrp2/serdes_ctrl.cpp - ${CMAKE_SOURCE_DIR}/lib/usrp/usrp2/serdes_ctrl.hpp - ${CMAKE_SOURCE_DIR}/lib/usrp/usrp2/usrp2_iface.cpp - ${CMAKE_SOURCE_DIR}/lib/usrp/usrp2/usrp2_iface.hpp - ${CMAKE_SOURCE_DIR}/lib/usrp/usrp2/usrp2_impl.cpp - ${CMAKE_SOURCE_DIR}/lib/usrp/usrp2/usrp2_impl.hpp - ${CMAKE_SOURCE_DIR}/lib/usrp/usrp2/usrp2_regs.hpp - ${CMAKE_SOURCE_DIR}/lib/usrp/usrp2/usrp2_regs.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/clock_ctrl.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/clock_ctrl.hpp + ${CMAKE_CURRENT_SOURCE_DIR}/codec_ctrl.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/codec_ctrl.hpp + ${CMAKE_CURRENT_SOURCE_DIR}/codec_impl.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/dboard_impl.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/dboard_iface.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/dsp_impl.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/gps_ctrl.hpp + ${CMAKE_CURRENT_SOURCE_DIR}/gps_ctrl.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/io_impl.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/mboard_impl.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/usrp2_iface.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/usrp2_iface.hpp + ${CMAKE_CURRENT_SOURCE_DIR}/usrp2_impl.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/usrp2_impl.hpp + ${CMAKE_CURRENT_SOURCE_DIR}/usrp2_regs.hpp + ${CMAKE_CURRENT_SOURCE_DIR}/usrp2_regs.cpp ) ENDIF(ENABLE_USRP2) diff --git a/host/lib/usrp/usrp2/clock_ctrl.cpp b/host/lib/usrp/usrp2/clock_ctrl.cpp index 428d5539b..27ccefb2b 100644 --- a/host/lib/usrp/usrp2/clock_ctrl.cpp +++ b/host/lib/usrp/usrp2/clock_ctrl.cpp @@ -22,10 +22,13 @@ #include <uhd/utils/assert.hpp> #include <boost/cstdint.hpp> #include <boost/lexical_cast.hpp> +#include <boost/math/special_functions/round.hpp> #include <iostream> using namespace uhd; +static const bool enb_test_clk = false; + /*! * A usrp2 clock control specific to the ad9510 ic. */ @@ -66,13 +69,12 @@ public: this->enable_external_ref(false); this->enable_rx_dboard_clock(false); this->enable_tx_dboard_clock(false); + this->enable_mimo_clock_out(false); /* private clock enables, must be set here */ this->enable_dac_clock(true); this->enable_adc_clock(true); - - /* always driving the mimo reference */ - this->enable_mimo_clock_out(true); + this->enable_test_clock(enb_test_clk); } ~usrp2_clock_ctrl_impl(void){ @@ -83,6 +85,7 @@ public: this->enable_dac_clock(false); this->enable_adc_clock(false); this->enable_mimo_clock_out(false); + this->enable_test_clock(false); } void enable_mimo_clock_out(bool enb){ @@ -246,6 +249,54 @@ public: double get_master_clock_rate(void){ return 100e6; } + + void set_mimo_clock_delay(double delay) { + //delay_val is a 5-bit value (0-31) for fine control + //the equations below determine delay for a given ramp current, # of caps and fine delay register + //delay range: + //range_ns = 200*((caps+3)/i_ramp_ua)*1.3286 + //offset (zero delay): + //offset_ns = 0.34 + (1600 - i_ramp_ua)*1e-4 + ((caps-1)/ramp)*6 + //delay_ns = offset_ns + range_ns * delay / 31 + + int delay_val = boost::math::iround(delay/9.744e-9*31); + + if(delay_val == 0) { + switch(clk_regs.exp) { + case 5: + _ad9510_regs.delay_control_out5 = 1; + break; + case 6: + _ad9510_regs.delay_control_out6 = 1; + break; + default: + break; //delay not supported on U2 rev 3 + } + } else { + switch(clk_regs.exp) { + case 5: + _ad9510_regs.delay_control_out5 = 0; + _ad9510_regs.ramp_current_out5 = ad9510_regs_t::RAMP_CURRENT_OUT5_200UA; + _ad9510_regs.ramp_capacitor_out5 = ad9510_regs_t::RAMP_CAPACITOR_OUT5_4CAPS; + _ad9510_regs.delay_fine_adjust_out5 = delay_val; + this->write_reg(0x34); + this->write_reg(0x35); + this->write_reg(0x36); + break; + case 6: + _ad9510_regs.delay_control_out6 = 0; + _ad9510_regs.ramp_current_out6 = ad9510_regs_t::RAMP_CURRENT_OUT6_200UA; + _ad9510_regs.ramp_capacitor_out6 = ad9510_regs_t::RAMP_CAPACITOR_OUT6_4CAPS; + _ad9510_regs.delay_fine_adjust_out6 = delay_val; + this->write_reg(0x38); + this->write_reg(0x39); + this->write_reg(0x3A); + break; + default: + break; + } + } + } private: /*! diff --git a/host/lib/usrp/usrp2/clock_ctrl.hpp b/host/lib/usrp/usrp2/clock_ctrl.hpp index db6c52c83..9ccbc959e 100644 --- a/host/lib/usrp/usrp2/clock_ctrl.hpp +++ b/host/lib/usrp/usrp2/clock_ctrl.hpp @@ -91,8 +91,18 @@ public: virtual void enable_test_clock(bool enb) = 0; /*! - * TODO other clock control api here.... + * Enable/disable the ref clock output over the serdes cable. + * \param enb true to enable + */ + virtual void enable_mimo_clock_out(bool enb) = 0; + + /*! + * Set the output delay of the mimo clock + * Used to synchronise daisy-chained USRPs over the MIMO cable + * Can also be used to adjust delay for uneven reference cable lengths + * \param delay the clock delay in seconds */ + virtual void set_mimo_clock_delay(double delay) = 0; }; diff --git a/host/lib/usrp/usrp2/fw_common.h b/host/lib/usrp/usrp2/fw_common.h index 29c2a8484..ee7fc3882 100644 --- a/host/lib/usrp/usrp2/fw_common.h +++ b/host/lib/usrp/usrp2/fw_common.h @@ -33,8 +33,8 @@ extern "C" { #endif //fpga and firmware compatibility numbers -#define USRP2_FPGA_COMPAT_NUM 3 -#define USRP2_FW_COMPAT_NUM 7 +#define USRP2_FPGA_COMPAT_NUM 4 +#define USRP2_FW_COMPAT_NUM 8 //used to differentiate control packets over data port #define USRP2_INVALID_VRT_HEADER 0 diff --git a/host/lib/usrp/usrp2/mboard_impl.cpp b/host/lib/usrp/usrp2/mboard_impl.cpp index 9afa6eda7..72d1c9d03 100644 --- a/host/lib/usrp/usrp2/mboard_impl.cpp +++ b/host/lib/usrp/usrp2/mboard_impl.cpp @@ -27,6 +27,10 @@ #include <iostream> #include <boost/date_time/posix_time/posix_time.hpp> +static const double mimo_clock_delay_usrp2_rev4 = 4.18e-9; +static const double mimo_clock_delay_usrp_n2xx = 0; //TODO +static const int mimo_clock_sync_delay_cycles = 134; + using namespace uhd; using namespace uhd::usrp; using namespace boost::posix_time; @@ -122,6 +126,20 @@ usrp2_mboard_impl::usrp2_mboard_impl( init_duc_config(); //initialize the clock configuration + if (device_args.has_key("mimo_mode")){ + if (device_args["mimo_mode"] == "master"){ + _mimo_clocking_mode_is_master = true; + } + else if (device_args["mimo_mode"] == "slave"){ + _mimo_clocking_mode_is_master = false; + } + else throw std::runtime_error( + "mimo_mode must be set to master or slave" + ); + } + else { + _mimo_clocking_mode_is_master = bool(_iface->peek32(_iface->regs.status) & (1 << 8)); + } init_clock_config(); //init the codec before the dboard @@ -196,6 +214,36 @@ void usrp2_mboard_impl::update_clock_config(void){ case usrp2_iface::USRP_NXXX: break; } + + //Handle the serdes clocking based on master/slave mode: + // - Masters always drive the clock over serdes. + // - Slaves always lock to this serdes clock. + // - Slaves lock their time over the serdes. + if (_mimo_clocking_mode_is_master){ + _clock_ctrl->enable_mimo_clock_out(true); + switch(_iface->get_rev()){ + case usrp2_iface::USRP_N200: + case usrp2_iface::USRP_N210: + _clock_ctrl->set_mimo_clock_delay(mimo_clock_delay_usrp_n2xx); + break; + + case usrp2_iface::USRP2_REV4: + _clock_ctrl->set_mimo_clock_delay(mimo_clock_delay_usrp2_rev4); + break; + + default: break; //not handled + } + _iface->poke32(_iface->regs.time64_mimo_sync, 0); + } + else{ + _iface->poke32(_iface->regs.misc_ctrl_clock, 0x15); + _clock_ctrl->enable_external_ref(true); + _clock_ctrl->enable_mimo_clock_out(false); + _iface->poke32(_iface->regs.time64_mimo_sync, + (1 << 8) | (mimo_clock_sync_delay_cycles & 0xff) + ); + } + } void usrp2_mboard_impl::set_time_spec(const time_spec_t &time_spec, bool now){ diff --git a/host/lib/usrp/usrp2/serdes_ctrl.cpp b/host/lib/usrp/usrp2/serdes_ctrl.cpp deleted file mode 100644 index 1cda22f45..000000000 --- a/host/lib/usrp/usrp2/serdes_ctrl.cpp +++ /dev/null @@ -1,46 +0,0 @@ -// -// Copyright 2010 Ettus Research LLC -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see <http://www.gnu.org/licenses/>. -// - -#include "serdes_ctrl.hpp" -#include "usrp2_regs.hpp" - -using namespace uhd; - -/*! - * A usrp2 serdes control implementation - */ -class usrp2_serdes_ctrl_impl : public usrp2_serdes_ctrl{ -public: - usrp2_serdes_ctrl_impl(usrp2_iface::sptr iface){ - _iface = iface; - _iface->poke32(_iface->regs.misc_ctrl_serdes, U2_FLAG_MISC_CTRL_SERDES_ENABLE | U2_FLAG_MISC_CTRL_SERDES_RXEN); - } - - ~usrp2_serdes_ctrl_impl(void){ - _iface->poke32(_iface->regs.misc_ctrl_serdes, 0); //power-down - } - -private: - usrp2_iface::sptr _iface; -}; - -/*********************************************************************** - * Public make function for the usrp2 serdes control - **********************************************************************/ -usrp2_serdes_ctrl::sptr usrp2_serdes_ctrl::make(usrp2_iface::sptr iface){ - return sptr(new usrp2_serdes_ctrl_impl(iface)); -} diff --git a/host/lib/usrp/usrp2/serdes_ctrl.hpp b/host/lib/usrp/usrp2/serdes_ctrl.hpp deleted file mode 100644 index 3c909c531..000000000 --- a/host/lib/usrp/usrp2/serdes_ctrl.hpp +++ /dev/null @@ -1,40 +0,0 @@ -// -// Copyright 2010 Ettus Research LLC -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see <http://www.gnu.org/licenses/>. -// - -#ifndef INCLUDED_SERDES_CTRL_HPP -#define INCLUDED_SERDES_CTRL_HPP - -#include "usrp2_iface.hpp" -#include <boost/shared_ptr.hpp> -#include <boost/utility.hpp> - -class usrp2_serdes_ctrl : boost::noncopyable{ -public: - typedef boost::shared_ptr<usrp2_serdes_ctrl> sptr; - - /*! - * Make a serdes control object for the usrp2 serdes port. - * \param _iface a pointer to the usrp2 interface object - * \return a new serdes control object - */ - static sptr make(usrp2_iface::sptr iface); - - //TODO fill me in with virtual methods - -}; - -#endif /* INCLUDED_SERDES_CTRL_HPP */ diff --git a/host/lib/usrp/usrp2/usrp2_impl.hpp b/host/lib/usrp/usrp2/usrp2_impl.hpp index be97e1121..9cd27ee41 100644 --- a/host/lib/usrp/usrp2/usrp2_impl.hpp +++ b/host/lib/usrp/usrp2/usrp2_impl.hpp @@ -100,6 +100,7 @@ public: private: size_t _index; bool _continuous_streaming; + bool _mimo_clocking_mode_is_master; //interfaces usrp2_iface::sptr _iface; diff --git a/host/lib/usrp/usrp2/usrp2_regs.cpp b/host/lib/usrp/usrp2/usrp2_regs.cpp index dd0433816..82ad30f08 100644 --- a/host/lib/usrp/usrp2/usrp2_regs.cpp +++ b/host/lib/usrp/usrp2/usrp2_regs.cpp @@ -57,6 +57,8 @@ usrp2_regs_t usrp2_get_regs(bool use_n2xx_map) { x.time64_flags = sr_addr(misc_output_base, x.sr_time64 + 2); x.time64_imm = sr_addr(misc_output_base, x.sr_time64 + 3); x.time64_tps = sr_addr(misc_output_base, x.sr_time64 + 4); + x.time64_mimo_sync = sr_addr(misc_output_base, x.sr_time64 + 5); + x.status = bp_base + 4*8; x.time64_secs_rb = bp_base + 4*10; x.time64_ticks_rb = bp_base + 4*11; x.compat_num_rb = bp_base + 4*12; diff --git a/host/lib/usrp/usrp2/usrp2_regs.hpp b/host/lib/usrp/usrp2/usrp2_regs.hpp index 9936d634a..56e64029e 100644 --- a/host/lib/usrp/usrp2/usrp2_regs.hpp +++ b/host/lib/usrp/usrp2/usrp2_regs.hpp @@ -25,10 +25,10 @@ #define USRP2_ATR_BASE 0xE400 #define USRP2_BP_STATUS_BASE 0xCC00 -#define USRP2P_MISC_OUTPUT_BASE 0x2000 -#define USRP2P_GPIO_BASE 0x3200 -#define USRP2P_ATR_BASE 0x3800 -#define USRP2P_BP_STATUS_BASE 0x3300 +#define USRP2P_MISC_OUTPUT_BASE 0x5000 +#define USRP2P_GPIO_BASE 0x6200 +#define USRP2P_ATR_BASE 0x6800 +#define USRP2P_BP_STATUS_BASE 0x6300 typedef struct { int sr_misc; @@ -57,6 +57,8 @@ typedef struct { int time64_flags; // flags -- see chart below int time64_imm; // set immediate (0=latch on next pps, 1=latch immediate, default=0) int time64_tps; // ticks per second rollover count + int time64_mimo_sync; + int status; int time64_secs_rb; int time64_ticks_rb; int compat_num_rb; diff --git a/host/lib/usrp/usrp_e100/CMakeLists.txt b/host/lib/usrp/usrp_e100/CMakeLists.txt index 3c5c58ee0..5d8a9791d 100644 --- a/host/lib/usrp/usrp_e100/CMakeLists.txt +++ b/host/lib/usrp/usrp_e100/CMakeLists.txt @@ -15,33 +15,35 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. # -#This file will be included by cmake, use absolute paths! +######################################################################## +# This file included, use CMake directory variables +######################################################################## ######################################################################## # Conditionally configure the USRP-E100 support ######################################################################## -LIBUHD_REGISTER_COMPONENT("USRP-E100" ENABLE_USRP_E100 FALSE) +LIBUHD_REGISTER_COMPONENT("USRP-E100" ENABLE_USRP_E100 OFF "ENABLE_LIBUHD" ON) IF(ENABLE_USRP_E100) - INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/lib/usrp/usrp_e100/include) + INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/include) LIBUHD_APPEND_SOURCES( - ${CMAKE_SOURCE_DIR}/lib/usrp/usrp_e100/clock_ctrl.cpp - ${CMAKE_SOURCE_DIR}/lib/usrp/usrp_e100/clock_ctrl.hpp - ${CMAKE_SOURCE_DIR}/lib/usrp/usrp_e100/codec_ctrl.cpp - ${CMAKE_SOURCE_DIR}/lib/usrp/usrp_e100/codec_ctrl.hpp - ${CMAKE_SOURCE_DIR}/lib/usrp/usrp_e100/codec_impl.cpp - ${CMAKE_SOURCE_DIR}/lib/usrp/usrp_e100/dboard_impl.cpp - ${CMAKE_SOURCE_DIR}/lib/usrp/usrp_e100/dboard_iface.cpp - ${CMAKE_SOURCE_DIR}/lib/usrp/usrp_e100/dsp_impl.cpp - ${CMAKE_SOURCE_DIR}/lib/usrp/usrp_e100/fpga-downloader.cc - ${CMAKE_SOURCE_DIR}/lib/usrp/usrp_e100/io_impl.cpp - ${CMAKE_SOURCE_DIR}/lib/usrp/usrp_e100/mboard_impl.cpp - ${CMAKE_SOURCE_DIR}/lib/usrp/usrp_e100/usrp_e100_impl.cpp - ${CMAKE_SOURCE_DIR}/lib/usrp/usrp_e100/usrp_e100_impl.hpp - ${CMAKE_SOURCE_DIR}/lib/usrp/usrp_e100/usrp_e100_iface.cpp - ${CMAKE_SOURCE_DIR}/lib/usrp/usrp_e100/usrp_e100_iface.hpp - ${CMAKE_SOURCE_DIR}/lib/usrp/usrp_e100/usrp_e100_mmap_zero_copy.cpp - ${CMAKE_SOURCE_DIR}/lib/usrp/usrp_e100/usrp_e100_regs.hpp + ${CMAKE_CURRENT_SOURCE_DIR}/clock_ctrl.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/clock_ctrl.hpp + ${CMAKE_CURRENT_SOURCE_DIR}/codec_ctrl.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/codec_ctrl.hpp + ${CMAKE_CURRENT_SOURCE_DIR}/codec_impl.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/dboard_impl.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/dboard_iface.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/dsp_impl.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/fpga-downloader.cc + ${CMAKE_CURRENT_SOURCE_DIR}/io_impl.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/mboard_impl.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/usrp_e100_impl.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/usrp_e100_impl.hpp + ${CMAKE_CURRENT_SOURCE_DIR}/usrp_e100_iface.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/usrp_e100_iface.hpp + ${CMAKE_CURRENT_SOURCE_DIR}/usrp_e100_mmap_zero_copy.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/usrp_e100_regs.hpp ) ENDIF(ENABLE_USRP_E100) diff --git a/host/lib/utils/CMakeLists.txt b/host/lib/utils/CMakeLists.txt index aecd3a4b0..60df24eef 100644 --- a/host/lib/utils/CMakeLists.txt +++ b/host/lib/utils/CMakeLists.txt @@ -15,7 +15,9 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. # -#This file will be included by cmake, use absolute paths! +######################################################################## +# This file included, use CMake directory variables +######################################################################## ######################################################################## # Setup defines for process scheduling @@ -79,12 +81,12 @@ ENDIF(HAVE_DLFCN_H) # Append sources ######################################################################## LIBUHD_APPEND_SOURCES( - ${CMAKE_SOURCE_DIR}/lib/utils/assert.cpp - ${CMAKE_SOURCE_DIR}/lib/utils/gain_group.cpp - ${CMAKE_SOURCE_DIR}/lib/utils/images.cpp - ${CMAKE_SOURCE_DIR}/lib/utils/load_modules.cpp - ${CMAKE_SOURCE_DIR}/lib/utils/paths.cpp - ${CMAKE_SOURCE_DIR}/lib/utils/props.cpp - ${CMAKE_SOURCE_DIR}/lib/utils/thread_priority.cpp - ${CMAKE_SOURCE_DIR}/lib/utils/warning.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/assert.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/gain_group.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/images.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/load_modules.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/paths.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/props.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/thread_priority.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/warning.cpp ) |