aboutsummaryrefslogtreecommitdiffstats
path: root/host
diff options
context:
space:
mode:
authorJosh Blum <josh@joshknows.com>2011-01-23 18:48:16 +0000
committerJosh Blum <josh@joshknows.com>2011-01-23 18:48:16 +0000
commitb3df6a0ebfa288d032d917b48b69f036444e57b6 (patch)
tree244ddbd86e71bd40dd4a1ed81e168ed4627cc95d /host
parent3db02acdfd44b22c05eaafe66e751f8fbfb29dcd (diff)
downloaduhd-b3df6a0ebfa288d032d917b48b69f036444e57b6.tar.gz
uhd-b3df6a0ebfa288d032d917b48b69f036444e57b6.tar.bz2
uhd-b3df6a0ebfa288d032d917b48b69f036444e57b6.zip
usrp-e100: created component for stand-alone usrp-e utils and added wb test util
Diffstat (limited to 'host')
-rw-r--r--host/CMakeLists.txt2
-rw-r--r--host/usrp_e_utils/CMakeLists.txt50
-rw-r--r--host/usrp_e_utils/clkgen-config.cpp (renamed from host/utils/clkgen-config.cpp)0
-rw-r--r--host/usrp_e_utils/fpga-downloader.cpp (renamed from host/utils/fpga-downloader.cpp)0
-rw-r--r--host/usrp_e_utils/usrp-e-debug-pins.c (renamed from host/utils/usrp-e-debug-pins.c)0
-rw-r--r--host/usrp_e_utils/usrp-e-i2c.c (renamed from host/utils/usrp-e-i2c.c)0
-rw-r--r--host/usrp_e_utils/usrp-e-loopback.c (renamed from host/utils/usrp-e-loopback.c)0
-rw-r--r--host/usrp_e_utils/usrp-e-spi.c (renamed from host/utils/usrp-e-spi.c)0
-rw-r--r--host/usrp_e_utils/usrp-e-wb-test.cpp111
-rw-r--r--host/utils/CMakeLists.txt16
10 files changed, 164 insertions, 15 deletions
diff --git a/host/CMakeLists.txt b/host/CMakeLists.txt
index e64c1031f..6b2ac4e64 100644
--- a/host/CMakeLists.txt
+++ b/host/CMakeLists.txt
@@ -183,6 +183,8 @@ IF(ENABLE_UTILS)
ADD_SUBDIRECTORY(utils)
ENDIF(ENABLE_UTILS)
+ADD_SUBDIRECTORY(usrp_e_utils)
+
########################################################################
# Print Summary
########################################################################
diff --git a/host/usrp_e_utils/CMakeLists.txt b/host/usrp_e_utils/CMakeLists.txt
new file mode 100644
index 000000000..1330aed75
--- /dev/null
+++ b/host/usrp_e_utils/CMakeLists.txt
@@ -0,0 +1,50 @@
+#
+# Copyright 2011 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/>.
+#
+
+########################################################################
+# USRP embedded utilities that get installed into the share path
+########################################################################
+IF(CMAKE_SYSTEM_NAME STREQUAL "Linux")
+ SET(LINUX_TARGET TRUE)
+ENDIF(CMAKE_SYSTEM_NAME STREQUAL "Linux")
+
+LIBUHD_REGISTER_COMPONENT("USRP-E Utils" ENABLE_USRP_E_UTILS OFF "LINUX_TARGET" OFF)
+
+IF(ENABLE_USRP_E_UTILS)
+ ENABLE_LANGUAGE(C)
+ INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/lib/usrp/usrp_e100)
+ INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/lib/usrp/usrp_e100/include)
+
+ SET(usrp_e_utils_sources
+ fpga-downloader.cpp
+ clkgen-config.cpp
+ usrp-e-loopback.c
+ usrp-e-wb-test.cpp
+ usrp-e-debug-pins.c
+ usrp-e-i2c.c
+ usrp-e-spi.c
+ )
+
+ #for each source: build an executable and install
+ FOREACH(util_source ${usrp_e_utils_sources})
+ GET_FILENAME_COMPONENT(util_name ${util_source} NAME_WE)
+ ADD_EXECUTABLE(${util_name} ${util_source})
+ TARGET_LINK_LIBRARIES(${util_name} -lpthread)
+ INSTALL(TARGETS ${util_name} RUNTIME DESTINATION ${PKG_DATA_DIR}/usrp_e_utils)
+ ENDFOREACH(util_source)
+
+ENDIF(ENABLE_USRP_E_UTILS)
diff --git a/host/utils/clkgen-config.cpp b/host/usrp_e_utils/clkgen-config.cpp
index e8279b4ae..e8279b4ae 100644
--- a/host/utils/clkgen-config.cpp
+++ b/host/usrp_e_utils/clkgen-config.cpp
diff --git a/host/utils/fpga-downloader.cpp b/host/usrp_e_utils/fpga-downloader.cpp
index 80ee71600..80ee71600 100644
--- a/host/utils/fpga-downloader.cpp
+++ b/host/usrp_e_utils/fpga-downloader.cpp
diff --git a/host/utils/usrp-e-debug-pins.c b/host/usrp_e_utils/usrp-e-debug-pins.c
index 94f898b67..94f898b67 100644
--- a/host/utils/usrp-e-debug-pins.c
+++ b/host/usrp_e_utils/usrp-e-debug-pins.c
diff --git a/host/utils/usrp-e-i2c.c b/host/usrp_e_utils/usrp-e-i2c.c
index c6fd4c632..c6fd4c632 100644
--- a/host/utils/usrp-e-i2c.c
+++ b/host/usrp_e_utils/usrp-e-i2c.c
diff --git a/host/utils/usrp-e-loopback.c b/host/usrp_e_utils/usrp-e-loopback.c
index 454d81ba7..454d81ba7 100644
--- a/host/utils/usrp-e-loopback.c
+++ b/host/usrp_e_utils/usrp-e-loopback.c
diff --git a/host/utils/usrp-e-spi.c b/host/usrp_e_utils/usrp-e-spi.c
index 5203f56a8..5203f56a8 100644
--- a/host/utils/usrp-e-spi.c
+++ b/host/usrp_e_utils/usrp-e-spi.c
diff --git a/host/usrp_e_utils/usrp-e-wb-test.cpp b/host/usrp_e_utils/usrp-e-wb-test.cpp
new file mode 100644
index 000000000..871cc46cc
--- /dev/null
+++ b/host/usrp_e_utils/usrp-e-wb-test.cpp
@@ -0,0 +1,111 @@
+//
+// Copyright 2011 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 <cstdlib>
+#include <cstdio>
+#include <ctime>
+#include <iostream>
+
+#include <sys/ioctl.h> //ioctl
+#include <fcntl.h> //open, close
+
+#include <linux/usrp_e.h>
+#include "usrp_e100_regs.hpp"
+
+static const size_t num_test_iters = 432;
+
+static int fp;
+
+static int peek16(int reg){
+ int ret;
+ struct usrp_e_ctl16 d;
+
+ d.offset = reg;
+ d.count = 1;
+ ret = ioctl(fp, USRP_E_READ_CTL16, &d);
+ return d.buf[0];
+}
+
+static void poke16(int reg, int val){
+ int ret;
+ struct usrp_e_ctl16 d;
+
+ d.offset = reg;
+ d.count = 1;
+ d.buf[0] = val;
+ ret = ioctl(fp, USRP_E_WRITE_CTL16, &d);
+}
+
+static int peek32(int reg){
+ int ret;
+ struct usrp_e_ctl32 d;
+
+ d.offset = reg;
+ d.count = 1;
+ ret = ioctl(fp, USRP_E_READ_CTL32, &d);
+ return d.buf[0];
+}
+
+static void poke32(int reg, int val){
+ int ret;
+ struct usrp_e_ctl32 d;
+
+ d.offset = reg;
+ d.count = 1;
+ d.buf[0] = val;
+ ret = ioctl(fp, USRP_E_WRITE_CTL32, &d);
+}
+
+int main(int, char *[]){
+
+ srandom(time(NULL)); //seed random()
+
+ if ((fp = ::open("/dev/usrp_e0", O_RDWR)) < 0){
+ std::cerr << "Open failed" << std::endl;
+ return -1;
+ }
+
+ size_t num_pass = 0, num_fail = 0;
+ for (size_t i = 0; i < num_test_iters; i++){
+ //make random values
+ int random_test32 = ::random();
+ int random_test16 = ::random() & 0xffff;
+ int random_secs = ::random();
+
+ //set a bunch of registers
+ poke16(UE_REG_MISC_TEST, random_test16);
+ poke32(UE_REG_SR_MISC_TEST32, random_test32);
+ poke32(UE_REG_TIME64_TICKS, 0);
+ poke32(UE_REG_TIME64_IMM, 1); //immediate
+ poke32(UE_REG_TIME64_SECS, random_secs);
+
+ //read a bunch of registers
+ if (
+ (peek16(UE_REG_MISC_TEST) == random_test16) and
+ (peek32(UE_REG_RB_MISC_TEST32) == random_test32) and
+ (peek32(UE_REG_RB_TIME_NOW_SECS) == random_secs) and
+ (peek32(UE_REG_RB_TIME_NOW_TICKS) < 1000000) and
+ true) num_pass++;
+ else num_fail++;
+ }
+
+ std::cout << "num pass: " << num_pass << std::endl;
+ std::cout << "num fail: " << num_fail << std::endl;
+
+ ::close(fp);
+ return 0;
+}
diff --git a/host/utils/CMakeLists.txt b/host/utils/CMakeLists.txt
index 2df1c3529..53527c03d 100644
--- a/host/utils/CMakeLists.txt
+++ b/host/utils/CMakeLists.txt
@@ -1,5 +1,5 @@
#
-# Copyright 2010 Ettus Research LLC
+# Copyright 2010-2011 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
@@ -45,20 +45,6 @@ IF(ENABLE_USRP1)
)
ENDIF(ENABLE_USRP1)
-IF(ENABLE_USRP_E100)
- ENABLE_LANGUAGE(C)
- INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/lib/usrp/usrp_e100)
- INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/lib/usrp/usrp_e100/include)
- LIST(APPEND util_share_sources
- fpga-downloader.cpp
- clkgen-config.cpp
- usrp-e-loopback.c
- usrp-e-debug-pins.c
- usrp-e-i2c.c
- usrp-e-spi.c
- )
-ENDIF(ENABLE_USRP_E100)
-
#for each source: build an executable and install
FOREACH(util_source ${util_share_sources})
GET_FILENAME_COMPONENT(util_name ${util_source} NAME_WE)