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/usrp-e-gpio.c') 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/usrp-e-gpio.c') 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