From a8f7839af32c2b38fc586bccffc7eb57f558672b Mon Sep 17 00:00:00 2001 From: Philip Balister Date: Wed, 16 Mar 2011 05:25:22 -0700 Subject: usrp_e100: Move gpio test program to utils. Still needs changing to use the new register map header. --- host/usrp_e_utils/usrp-e-gpio.c | 83 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100644 host/usrp_e_utils/usrp-e-gpio.c (limited to 'host/usrp_e_utils') diff --git a/host/usrp_e_utils/usrp-e-gpio.c b/host/usrp_e_utils/usrp-e-gpio.c new file mode 100644 index 000000000..adef877d3 --- /dev/null +++ b/host/usrp_e_utils/usrp-e-gpio.c @@ -0,0 +1,83 @@ +#include +#include +#include +#include +#include +#include +#include + +#include "usrp_e.h" +#include "usrp_e_regs.hpp" + +// Usage: usrp_e_gpio + +static int fp; + +static int read_reg(__u16 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 write_reg(__u16 reg, __u16 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); +} + +int main(int argc, char *argv[]) +{ + int i, test, data_in; + + test = 0; + if (argc > 1) + test = 1; + + fp = open("/dev/usrp_e0", O_RDWR); + printf("fp = %d\n", fp); + + write_reg(UE_REG_GPIO_TX_DDR, 0x0); + write_reg(UE_REG_GPIO_RX_DDR, 0xFFFF); + + for (i=0; i < 16; i++) { + write_reg(UE_REG_GPIO_RX_IO, 1 << i); + sleep(1); + if (test) { + data_in = read_reg(UE_REG_GPIO_TX_IO); + if (data_in != (1 << i)) + printf("Read failed, wrote: %X read: %X\n", \ + 1 << i, data_in); + } + } + + write_reg(UE_REG_GPIO_RX_DDR, 0x0); + write_reg(UE_REG_GPIO_TX_DDR, 0xFFFF); + + sleep(1); + + for (i=0; i < 16; i++) { + write_reg(UE_REG_GPIO_TX_IO, 1 << i); + sleep(1); + if (test) { + data_in = read_reg(UE_REG_GPIO_RX_IO); + if (data_in != (1 << i)) + printf("Read failed, wrote: %X read: %X\n", \ + 1 << i, data_in); + } + } + + write_reg(UE_REG_GPIO_RX_DDR, 0x0); + write_reg(UE_REG_GPIO_TX_DDR, 0x0); + + return 0; +} -- cgit v1.2.3 From a57310606c581addc5bafdb9c645eb7b46cb4a79 Mon Sep 17 00:00:00 2001 From: Philip Balister Date: Thu, 17 Mar 2011 04:41:38 -0700 Subject: usrp_e : Add usrp e1xx gpio test program the usrp e100 utils directory. --- host/usrp_e_utils/CMakeLists.txt | 1 + host/usrp_e_utils/usrp-e-gpio.c | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) (limited to 'host/usrp_e_utils') diff --git a/host/usrp_e_utils/CMakeLists.txt b/host/usrp_e_utils/CMakeLists.txt index 1ecd2ac46..f3537e542 100644 --- a/host/usrp_e_utils/CMakeLists.txt +++ b/host/usrp_e_utils/CMakeLists.txt @@ -37,6 +37,7 @@ IF(ENABLE_USRP_E_UTILS) usrp-e-timed.c usrp-e-wb-test.cpp usrp-e-debug-pins.c + usrp-e-gpio.c usrp-e-i2c.c usrp-e-spi.c ) diff --git a/host/usrp_e_utils/usrp-e-gpio.c b/host/usrp_e_utils/usrp-e-gpio.c index adef877d3..7e4bc4e13 100644 --- a/host/usrp_e_utils/usrp-e-gpio.c +++ b/host/usrp_e_utils/usrp-e-gpio.c @@ -6,8 +6,8 @@ #include #include -#include "usrp_e.h" -#include "usrp_e_regs.hpp" +#include "linux/usrp_e.h" +#include "usrp_e100_regs.hpp" // Usage: usrp_e_gpio -- cgit v1.2.3 From 31953ec55d038d75cfe9307bd38abdc953904b07 Mon Sep 17 00:00:00 2001 From: Philip Balister Date: Thu, 17 Mar 2011 05:38:32 -0700 Subject: usrp_e : Check packet length received from FPGA in case of corruption. If the packet length in invalid, do not calculate the checksum to avoid segfaulting. --- host/usrp_e_utils/usrp-e-loopback.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'host/usrp_e_utils') diff --git a/host/usrp_e_utils/usrp-e-loopback.c b/host/usrp_e_utils/usrp-e-loopback.c index 78e2b5d16..0bd3d3100 100644 --- a/host/usrp_e_utils/usrp-e-loopback.c +++ b/host/usrp_e_utils/usrp-e-loopback.c @@ -38,11 +38,15 @@ static int calc_checksum(struct pkt *p) i = 0; sum = 0; - for (i=0; i < p->len; i++) - sum += p->data[i]; - - sum += p->seq_num; - sum += p->len; + if (p->len < 1016) { + for (i=0; i < p->len; i++) + sum += p->data[i]; + + sum += p->seq_num; + sum += p->len; + } else { + printf("Bad packet length = %d received.\n", p->len); + } return sum; } -- cgit v1.2.3 From 83c608e17de45fd5372f05b54f343c721e25ad82 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Fri, 1 Apr 2011 15:54:51 -0700 Subject: uhd: define LINUX in build system to simplify some checks --- host/Modules/UHDPackage.cmake | 4 ++++ host/lib/usrp/usrp_e100/CMakeLists.txt | 6 +----- host/usrp_e_utils/CMakeLists.txt | 6 +----- 3 files changed, 6 insertions(+), 10 deletions(-) (limited to 'host/usrp_e_utils') diff --git a/host/Modules/UHDPackage.cmake b/host/Modules/UHDPackage.cmake index 7fee51741..7ac677d28 100644 --- a/host/Modules/UHDPackage.cmake +++ b/host/Modules/UHDPackage.cmake @@ -29,6 +29,10 @@ IF(UNIX AND EXISTS "/etc/redhat-release") SET(REDHAT TRUE) ENDIF() +IF(CMAKE_SYSTEM_NAME STREQUAL "Linux") + SET(LINUX TRUE) +ENDIF(CMAKE_SYSTEM_NAME STREQUAL "Linux") + ######################################################################## # Setup package file name ######################################################################## diff --git a/host/lib/usrp/usrp_e100/CMakeLists.txt b/host/lib/usrp/usrp_e100/CMakeLists.txt index acbac177e..d0e20a3d8 100644 --- a/host/lib/usrp/usrp_e100/CMakeLists.txt +++ b/host/lib/usrp/usrp_e100/CMakeLists.txt @@ -22,11 +22,7 @@ ######################################################################## # Conditionally configure the USRP-E100 support ######################################################################## -IF(CMAKE_SYSTEM_NAME STREQUAL "Linux") - SET(LINUX_TARGET TRUE) -ENDIF(CMAKE_SYSTEM_NAME STREQUAL "Linux") - -LIBUHD_REGISTER_COMPONENT("USRP-E100" ENABLE_USRP_E100 OFF "ENABLE_LIBUHD;LINUX_TARGET" OFF) +LIBUHD_REGISTER_COMPONENT("USRP-E100" ENABLE_USRP_E100 OFF "ENABLE_LIBUHD;LINUX" OFF) IF(ENABLE_USRP_E100) INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/include) diff --git a/host/usrp_e_utils/CMakeLists.txt b/host/usrp_e_utils/CMakeLists.txt index f3537e542..e7d6ae4b8 100644 --- a/host/usrp_e_utils/CMakeLists.txt +++ b/host/usrp_e_utils/CMakeLists.txt @@ -18,11 +18,7 @@ ######################################################################## # 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) +LIBUHD_REGISTER_COMPONENT("USRP-E Utils" ENABLE_USRP_E_UTILS OFF "LINUX" OFF) IF(ENABLE_USRP_E_UTILS) ENABLE_LANGUAGE(C) -- cgit v1.2.3