From 4e5429b2839115235c7be778fe334479b833f128 Mon Sep 17 00:00:00 2001 From: Philip Balister Date: Wed, 24 Mar 2010 11:33:02 -0400 Subject: Start renaming stuff in line with product name USRP Embedded. --- host/apps/omap_debug/usrp-e-spi.c | 40 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 host/apps/omap_debug/usrp-e-spi.c (limited to 'host/apps/omap_debug/usrp-e-spi.c') diff --git a/host/apps/omap_debug/usrp-e-spi.c b/host/apps/omap_debug/usrp-e-spi.c new file mode 100644 index 000000000..a79d74b18 --- /dev/null +++ b/host/apps/omap_debug/usrp-e-spi.c @@ -0,0 +1,40 @@ +#include +#include +#include +#include +#include + +#include "usrp1_e.h" + +// Usage: usrp1_e_spi w|rb slave data + +int main(int argc, char *argv[]) +{ + int fp, slave, data, ret; + struct usrp_e_spi spi_dat; + + if (argc < 4) { + printf("Usage: usrp1_e_spi w|rb slave data\n"); + exit(-1); + } + + slave = atoi(argv[2]); + data = atoi(argv[3]); + + fp = open("/dev/usrp1_e0", O_RDWR); + printf("fp = %d\n", fp); + + spi_dat.slave = slave; + spi_dat.data = data; + spi_dat.length = 2; + spi_dat.flags = 0; + + if (*argv[1] == 'r') { + spi_dat.readback = 1; + ret = ioctl(fp, USRP_E_SPI, &spi_dat); + printf("Data returned = %d\n", ret); + } else { + spi_dat.readback = 0; + ioctl(fp, USRP_E_SPI, &spi_dat); + } +} -- cgit v1.2.3 From 4f5cd64188c7e2b5490d910d5e86301c053960ea Mon Sep 17 00:00:00 2001 From: Philip Balister Date: Wed, 24 Mar 2010 15:49:08 -0400 Subject: Makefile and usrp-e-spi edits, add i2c test program. --- host/apps/omap_debug/Makefile | 10 ++++++ host/apps/omap_debug/usrp-e-i2c.c | 71 +++++++++++++++++++++++++++++++++++++++ host/apps/omap_debug/usrp-e-spi.c | 4 ++- 3 files changed, 84 insertions(+), 1 deletion(-) create mode 100644 host/apps/omap_debug/usrp-e-i2c.c (limited to 'host/apps/omap_debug/usrp-e-spi.c') diff --git a/host/apps/omap_debug/Makefile b/host/apps/omap_debug/Makefile index 5616a7355..07545a639 100644 --- a/host/apps/omap_debug/Makefile +++ b/host/apps/omap_debug/Makefile @@ -1 +1,11 @@ +CFLAGS=-Wall + +all : usrp-e-spi usrp-e-i2c + usrp-e-spi : usrp-e-spi.c + +usrp-e-i2c : usrp-e-i2c.c + +clean : + rm -f usrp-e-spi + rm -f usrp-e-i2c diff --git a/host/apps/omap_debug/usrp-e-i2c.c b/host/apps/omap_debug/usrp-e-i2c.c new file mode 100644 index 000000000..dce1ae153 --- /dev/null +++ b/host/apps/omap_debug/usrp-e-i2c.c @@ -0,0 +1,71 @@ +#include +#include +#include +#include +#include +#include + +#include "usrp1_e.h" + +// Usage: usrp_e_i2c w address data0 data1 data 2 .... +// Usage: usrp_e_i2c r address count + +int main(int argc, char *argv[]) +{ + int fp, ret, i; + struct usrp_e_i2c *i2c_msg; + int direction, address, count; + + if (argc < 3) { + printf("Usage: usrp1_e_i2c w address data0 data1 data2 ...\n"); + printf("Usage: usrp1_e_i2c r address count\n"); + exit(-1); + } + + if (strcmp(argv[1], "r") == 0) { + direction = 0; + } else if (strcmp(argv[1], "w") == 0) { + direction = 1; + } else { + return -1; + } + + address = atoi(argv[2]); + + fp = open("/dev/usrp1_e0", O_RDWR); + printf("fp = %d\n", fp); + + if (direction) { + count = argc - 2; + } else { + count = atoi(argv[3]); + } + + i2c_msg = malloc(sizeof(i2c_msg) + count * sizeof(char)); + + i2c_msg->addr = address; + i2c_msg->len = count; + + if (direction) { + // Write + + for (i=0; idata[i] = atoi(argv[3+i]); + } + + ret = ioctl(fp, USRP_E_I2C_WRITE, i2c_msg); + printf("Return value from i2c_write ioctl: %d\n", ret); + } else { + // Read + + ret = ioctl(fp, USRP_E_I2C_READ, i2c_msg); + + printf("Ioctl: %d Data read :", ret); + for (i=0; idata[i]); + } + printf("/n"); + + } + return 0; +} diff --git a/host/apps/omap_debug/usrp-e-spi.c b/host/apps/omap_debug/usrp-e-spi.c index a79d74b18..e10e72b80 100644 --- a/host/apps/omap_debug/usrp-e-spi.c +++ b/host/apps/omap_debug/usrp-e-spi.c @@ -2,7 +2,7 @@ #include #include #include -#include +#include #include "usrp1_e.h" @@ -37,4 +37,6 @@ int main(int argc, char *argv[]) spi_dat.readback = 0; ioctl(fp, USRP_E_SPI, &spi_dat); } + + return 0; } -- cgit v1.2.3 From 28e5e0740a8fc3c7233a1bd5cc6bbc897c586da6 Mon Sep 17 00:00:00 2001 From: root Date: Thu, 25 Mar 2010 17:42:36 +0000 Subject: Updates for header file change from usrp1_e.h to usrp_e.h. --- host/apps/omap_debug/fetch-module.sh | 4 +- host/apps/omap_debug/usrp-e-i2c.c | 8 ++-- host/apps/omap_debug/usrp-e-spi.c | 8 ++-- host/apps/omap_debug/usrp1_e.h | 72 ------------------------------------ host/apps/omap_debug/usrp_e.h | 72 ++++++++++++++++++++++++++++++++++++ 5 files changed, 82 insertions(+), 82 deletions(-) delete mode 100644 host/apps/omap_debug/usrp1_e.h create mode 100644 host/apps/omap_debug/usrp_e.h (limited to 'host/apps/omap_debug/usrp-e-spi.c') diff --git a/host/apps/omap_debug/fetch-module.sh b/host/apps/omap_debug/fetch-module.sh index 101ea9aef..45cf1f052 100755 --- a/host/apps/omap_debug/fetch-module.sh +++ b/host/apps/omap_debug/fetch-module.sh @@ -1,3 +1,3 @@ -scp balister@192.168.1.167:src/git/kernel_usrp/drivers/misc/usrp1_e.ko /lib/modules/2.6.33-rc3/kernel/drivers/misc -scp balister@192.168.1.167:src/git/kernel_usrp/include/linux/usrp1_e.h . +scp balister@192.168.1.167:src/git/kernel_usrp/drivers/misc/usrp_e.ko /lib/modules/2.6.33-rc3/kernel/drivers/misc +scp balister@192.168.1.167:src/git/kernel_usrp/include/linux/usrp_e.h . sync diff --git a/host/apps/omap_debug/usrp-e-i2c.c b/host/apps/omap_debug/usrp-e-i2c.c index dce1ae153..417d6d580 100644 --- a/host/apps/omap_debug/usrp-e-i2c.c +++ b/host/apps/omap_debug/usrp-e-i2c.c @@ -5,7 +5,7 @@ #include #include -#include "usrp1_e.h" +#include "usrp_e.h" // Usage: usrp_e_i2c w address data0 data1 data 2 .... // Usage: usrp_e_i2c r address count @@ -17,8 +17,8 @@ int main(int argc, char *argv[]) int direction, address, count; if (argc < 3) { - printf("Usage: usrp1_e_i2c w address data0 data1 data2 ...\n"); - printf("Usage: usrp1_e_i2c r address count\n"); + printf("Usage: usrp_e_i2c w address data0 data1 data2 ...\n"); + printf("Usage: usrp_e_i2c r address count\n"); exit(-1); } @@ -32,7 +32,7 @@ int main(int argc, char *argv[]) address = atoi(argv[2]); - fp = open("/dev/usrp1_e0", O_RDWR); + fp = open("/dev/usrp_e0", O_RDWR); printf("fp = %d\n", fp); if (direction) { diff --git a/host/apps/omap_debug/usrp-e-spi.c b/host/apps/omap_debug/usrp-e-spi.c index e10e72b80..1af47b172 100644 --- a/host/apps/omap_debug/usrp-e-spi.c +++ b/host/apps/omap_debug/usrp-e-spi.c @@ -4,9 +4,9 @@ #include #include -#include "usrp1_e.h" +#include "usrp_e.h" -// Usage: usrp1_e_spi w|rb slave data +// Usage: usrp_e_spi w|rb slave data int main(int argc, char *argv[]) { @@ -14,14 +14,14 @@ int main(int argc, char *argv[]) struct usrp_e_spi spi_dat; if (argc < 4) { - printf("Usage: usrp1_e_spi w|rb slave data\n"); + printf("Usage: usrp_e_spi w|rb slave data\n"); exit(-1); } slave = atoi(argv[2]); data = atoi(argv[3]); - fp = open("/dev/usrp1_e0", O_RDWR); + fp = open("/dev/usrp_e0", O_RDWR); printf("fp = %d\n", fp); spi_dat.slave = slave; diff --git a/host/apps/omap_debug/usrp1_e.h b/host/apps/omap_debug/usrp1_e.h deleted file mode 100644 index b34446b01..000000000 --- a/host/apps/omap_debug/usrp1_e.h +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright (C) 2010 Ettus Research, LLC - * - * Written by Philip Balister - * - * 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 2 of the License, or - * (at your option) any later version. - */ - -#ifndef __USRP_E_H -#define __USRP_E_H - -#include -#include - -struct usrp1_e_ctl16 { - __u32 offset; - __u32 count; - __u16 buf[20]; -}; - -struct usrp1_e_ctl32 { - __u32 offset; - __u32 count; - __u32 buf[10]; -}; - -// SPI interface - -#define UE_SPI_TXONLY 0 -#define UE_SPI_TXRX 1 - -// Defines for spi ctrl register -#define UE_SPI_CTRL_ASS (1<<13) -#define UE_SPI_CTRL_IE (1<<12) -#define UE_SPI_CTRL_LSB (1<<11) -#define UE_SPI_CTRL_TXNEG (1<<10) -#define UE_SPI_CTRL_RXNEG (1<<9) -#define UE_SPI_CTRL_GO_BSY (1<<8) -#define UE_SPI_CTRL_CHAR_LEN_MASK 0x7f - -#define UE_SPI_PUSH_RISE 0 -#define UE_SPI_PUSH_FALL UE_SPI_CTRL_TXNEG -#define UE_SPI_LATCH_RISE 0 -#define UE_SPI_LATCH_FALL UE_SPI_CTRL_RXNEG - -struct usrp_e_spi { - __u8 readback; - __u32 slave; - __u32 data; - __u32 length; - __u32 flags; -}; - -struct usrp_e_i2c { - __u8 addr; - __u32 len; - __u8 data[]; -}; - -#define USRP_E_IOC_MAGIC 'u' -#define USRP_E_WRITE_CTL16 _IOW(USRP_E_IOC_MAGIC, 0x20, struct usrp1_e_ctl16) -#define USRP_E_READ_CTL16 _IOWR(USRP_E_IOC_MAGIC, 0x21, struct usrp1_e_ctl16) -#define USRP_E_WRITE_CTL32 _IOW(USRP_E_IOC_MAGIC, 0x22, struct usrp1_e_ctl32) -#define USRP_E_READ_CTL32 _IOWR(USRP_E_IOC_MAGIC, 0x23, struct usrp1_e_ctl32) -#define USRP_E_SPI _IOW(USRP_E_IOC_MAGIC, 0x24, struct usrp_e_spi) -#define USRP_E_I2C_READ _IOR(USRP_E_IOC_MAGIC, 0x25, struct usrp_e_i2c) -#define USRP_E_I2C_WRITE _IOW(USRP_E_IOC_MAGIC, 0x26, struct usrp_e_i2c) - -#endif diff --git a/host/apps/omap_debug/usrp_e.h b/host/apps/omap_debug/usrp_e.h new file mode 100644 index 000000000..aa8ef3d57 --- /dev/null +++ b/host/apps/omap_debug/usrp_e.h @@ -0,0 +1,72 @@ +/* + * Copyright (C) 2010 Ettus Research, LLC + * + * Written by Philip Balister + * + * 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 2 of the License, or + * (at your option) any later version. + */ + +#ifndef __USRP_E_H +#define __USRP_E_H + +#include +#include + +struct usrp_e_ctl16 { + __u32 offset; + __u32 count; + __u16 buf[20]; +}; + +struct usrp_e_ctl32 { + __u32 offset; + __u32 count; + __u32 buf[10]; +}; + +// SPI interface + +#define UE_SPI_TXONLY 0 +#define UE_SPI_TXRX 1 + +// Defines for spi ctrl register +#define UE_SPI_CTRL_ASS (1<<13) +#define UE_SPI_CTRL_IE (1<<12) +#define UE_SPI_CTRL_LSB (1<<11) +#define UE_SPI_CTRL_TXNEG (1<<10) +#define UE_SPI_CTRL_RXNEG (1<<9) +#define UE_SPI_CTRL_GO_BSY (1<<8) +#define UE_SPI_CTRL_CHAR_LEN_MASK 0x7f + +#define UE_SPI_PUSH_RISE 0 +#define UE_SPI_PUSH_FALL UE_SPI_CTRL_TXNEG +#define UE_SPI_LATCH_RISE 0 +#define UE_SPI_LATCH_FALL UE_SPI_CTRL_RXNEG + +struct usrp_e_spi { + __u8 readback; + __u32 slave; + __u32 data; + __u32 length; + __u32 flags; +}; + +struct usrp_e_i2c { + __u8 addr; + __u32 len; + __u8 data[]; +}; + +#define USRP_E_IOC_MAGIC 'u' +#define USRP_E_WRITE_CTL16 _IOW(USRP_E_IOC_MAGIC, 0x20, struct usrp_e_ctl16) +#define USRP_E_READ_CTL16 _IOWR(USRP_E_IOC_MAGIC, 0x21, struct usrp_e_ctl16) +#define USRP_E_WRITE_CTL32 _IOW(USRP_E_IOC_MAGIC, 0x22, struct usrp_e_ctl32) +#define USRP_E_READ_CTL32 _IOWR(USRP_E_IOC_MAGIC, 0x23, struct usrp_e_ctl32) +#define USRP_E_SPI _IOW(USRP_E_IOC_MAGIC, 0x24, struct usrp_e_spi) +#define USRP_E_I2C_READ _IOR(USRP_E_IOC_MAGIC, 0x25, struct usrp_e_i2c) +#define USRP_E_I2C_WRITE _IOW(USRP_E_IOC_MAGIC, 0x26, struct usrp_e_i2c) + +#endif -- cgit v1.2.3 From 3e01c94fe0c690293f13a09666deb79fcb6af58c Mon Sep 17 00:00:00 2001 From: Philip Balister Date: Thu, 1 Apr 2010 12:44:55 +0000 Subject: Spi word length is in bits, not bytes. --- host/apps/omap_debug/usrp-e-spi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'host/apps/omap_debug/usrp-e-spi.c') diff --git a/host/apps/omap_debug/usrp-e-spi.c b/host/apps/omap_debug/usrp-e-spi.c index 1af47b172..f7131bbe3 100644 --- a/host/apps/omap_debug/usrp-e-spi.c +++ b/host/apps/omap_debug/usrp-e-spi.c @@ -26,7 +26,7 @@ int main(int argc, char *argv[]) spi_dat.slave = slave; spi_dat.data = data; - spi_dat.length = 2; + spi_dat.length = 32; spi_dat.flags = 0; if (*argv[1] == 'r') { -- cgit v1.2.3 From 9b30d7293f93ec340c23448147c425c398c01db4 Mon Sep 17 00:00:00 2001 From: Philip Balister Date: Thu, 1 Apr 2010 19:27:59 +0000 Subject: Allow variable length spi messages. --- host/apps/omap_debug/usrp-e-spi.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'host/apps/omap_debug/usrp-e-spi.c') diff --git a/host/apps/omap_debug/usrp-e-spi.c b/host/apps/omap_debug/usrp-e-spi.c index f7131bbe3..de1409647 100644 --- a/host/apps/omap_debug/usrp-e-spi.c +++ b/host/apps/omap_debug/usrp-e-spi.c @@ -10,23 +10,24 @@ int main(int argc, char *argv[]) { - int fp, slave, data, ret; + int fp, slave, length, data, ret; struct usrp_e_spi spi_dat; - if (argc < 4) { - printf("Usage: usrp_e_spi w|rb slave data\n"); + if (argc < 5) { + printf("Usage: usrp_e_spi w|rb slave transfer_length data\n"); exit(-1); } slave = atoi(argv[2]); - data = atoi(argv[3]); + length = atoi(argv[3]); + data = atoi(argv[4]); fp = open("/dev/usrp_e0", O_RDWR); printf("fp = %d\n", fp); spi_dat.slave = slave; spi_dat.data = data; - spi_dat.length = 32; + spi_dat.length = length; spi_dat.flags = 0; if (*argv[1] == 'r') { -- cgit v1.2.3 From 80b2b928df6e3c1caf68dee199593a0af1cb91ae Mon Sep 17 00:00:00 2001 From: Philip Balister Date: Fri, 2 Apr 2010 12:33:37 +0000 Subject: Handle 32 bit data to spi controller. --- host/apps/omap_debug/usrp-e-spi.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'host/apps/omap_debug/usrp-e-spi.c') diff --git a/host/apps/omap_debug/usrp-e-spi.c b/host/apps/omap_debug/usrp-e-spi.c index de1409647..f693d7db1 100644 --- a/host/apps/omap_debug/usrp-e-spi.c +++ b/host/apps/omap_debug/usrp-e-spi.c @@ -10,7 +10,8 @@ int main(int argc, char *argv[]) { - int fp, slave, length, data, ret; + int fp, slave, length, ret; + unsigned int data; struct usrp_e_spi spi_dat; if (argc < 5) { @@ -20,7 +21,9 @@ int main(int argc, char *argv[]) slave = atoi(argv[2]); length = atoi(argv[3]); - data = atoi(argv[4]); + data = atoll(argv[4]); + + printf("Data = %X\n", data); fp = open("/dev/usrp_e0", O_RDWR); printf("fp = %d\n", fp); -- cgit v1.2.3 From c05fc634407741ce202cccc0781e937897c51361 Mon Sep 17 00:00:00 2001 From: Philip Balister Date: Tue, 20 Apr 2010 13:35:00 +0000 Subject: usrp-e-spi: change active edges around. --- host/apps/omap_debug/usrp-e-spi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'host/apps/omap_debug/usrp-e-spi.c') diff --git a/host/apps/omap_debug/usrp-e-spi.c b/host/apps/omap_debug/usrp-e-spi.c index f693d7db1..caa36b3f1 100644 --- a/host/apps/omap_debug/usrp-e-spi.c +++ b/host/apps/omap_debug/usrp-e-spi.c @@ -31,7 +31,7 @@ int main(int argc, char *argv[]) spi_dat.slave = slave; spi_dat.data = data; spi_dat.length = length; - spi_dat.flags = 0; + spi_dat.flags = UE_SPI_PUSH_FALL | UE_SPI_LATCH_RISE; if (*argv[1] == 'r') { spi_dat.readback = 1; -- cgit v1.2.3 From a8f284d03d061a2fb9a6daf6e6bc2493daccd5d4 Mon Sep 17 00:00:00 2001 From: Philip Balister Date: Mon, 3 May 2010 12:44:41 +0000 Subject: Add a hack to work around a driver race. Remove when teh driver is fixed. --- host/apps/omap_debug/usrp-e-spi.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'host/apps/omap_debug/usrp-e-spi.c') diff --git a/host/apps/omap_debug/usrp-e-spi.c b/host/apps/omap_debug/usrp-e-spi.c index caa36b3f1..264231731 100644 --- a/host/apps/omap_debug/usrp-e-spi.c +++ b/host/apps/omap_debug/usrp-e-spi.c @@ -28,6 +28,8 @@ int main(int argc, char *argv[]) fp = open("/dev/usrp_e0", O_RDWR); printf("fp = %d\n", fp); + sleep(1); // HACK HACK + spi_dat.slave = slave; spi_dat.data = data; spi_dat.length = length; -- cgit v1.2.3 From 4c4e0f48534a735cc7f5780f4483871264a880ad Mon Sep 17 00:00:00 2001 From: Philip Balister Date: Mon, 3 May 2010 12:51:02 +0000 Subject: Add hack to work around driver race. --- host/apps/omap_debug/usrp-e-i2c.c | 3 +++ host/apps/omap_debug/usrp-e-spi.c | 1 + 2 files changed, 4 insertions(+) (limited to 'host/apps/omap_debug/usrp-e-spi.c') diff --git a/host/apps/omap_debug/usrp-e-i2c.c b/host/apps/omap_debug/usrp-e-i2c.c index 575430f84..57a3f4739 100644 --- a/host/apps/omap_debug/usrp-e-i2c.c +++ b/host/apps/omap_debug/usrp-e-i2c.c @@ -1,6 +1,7 @@ #include #include #include +#include #include #include #include @@ -37,6 +38,8 @@ int main(int argc, char *argv[]) fp = open("/dev/usrp_e0", O_RDWR); printf("fp = %d\n", fp); + sleep(1); + if (direction) { count = argc - 3; } else { diff --git a/host/apps/omap_debug/usrp-e-spi.c b/host/apps/omap_debug/usrp-e-spi.c index 264231731..47ee9369c 100644 --- a/host/apps/omap_debug/usrp-e-spi.c +++ b/host/apps/omap_debug/usrp-e-spi.c @@ -1,5 +1,6 @@ #include #include +#include #include #include #include -- cgit v1.2.3 From 5583cb575e45441c98480f7beecb48437842fc5c Mon Sep 17 00:00:00 2001 From: Philip Balister Date: Mon, 3 May 2010 22:36:56 +0000 Subject: Spi data returned in struct now. --- host/apps/omap_debug/usrp-e-spi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'host/apps/omap_debug/usrp-e-spi.c') diff --git a/host/apps/omap_debug/usrp-e-spi.c b/host/apps/omap_debug/usrp-e-spi.c index 47ee9369c..2fcc39b9b 100644 --- a/host/apps/omap_debug/usrp-e-spi.c +++ b/host/apps/omap_debug/usrp-e-spi.c @@ -39,7 +39,7 @@ int main(int argc, char *argv[]) if (*argv[1] == 'r') { spi_dat.readback = 1; ret = ioctl(fp, USRP_E_SPI, &spi_dat); - printf("Data returned = %d\n", ret); + printf("Ioctl returns: %d, Data returned = %d\n", ret, spi_dat.data); } else { spi_dat.readback = 0; ioctl(fp, USRP_E_SPI, &spi_dat); -- cgit v1.2.3 From 6929d0cba40a2bf4f4b3b81819bb915bdbb16488 Mon Sep 17 00:00:00 2001 From: root Date: Wed, 5 May 2010 21:12:43 +0000 Subject: Remove workaround for driver hang. --- host/apps/omap_debug/usrp-e-i2c.c | 2 -- host/apps/omap_debug/usrp-e-spi.c | 2 -- host/apps/omap_debug/usrp_e.h | 4 ++-- 3 files changed, 2 insertions(+), 6 deletions(-) (limited to 'host/apps/omap_debug/usrp-e-spi.c') diff --git a/host/apps/omap_debug/usrp-e-i2c.c b/host/apps/omap_debug/usrp-e-i2c.c index 57a3f4739..615dc557b 100644 --- a/host/apps/omap_debug/usrp-e-i2c.c +++ b/host/apps/omap_debug/usrp-e-i2c.c @@ -38,8 +38,6 @@ int main(int argc, char *argv[]) fp = open("/dev/usrp_e0", O_RDWR); printf("fp = %d\n", fp); - sleep(1); - if (direction) { count = argc - 3; } else { diff --git a/host/apps/omap_debug/usrp-e-spi.c b/host/apps/omap_debug/usrp-e-spi.c index 2fcc39b9b..d2c38e524 100644 --- a/host/apps/omap_debug/usrp-e-spi.c +++ b/host/apps/omap_debug/usrp-e-spi.c @@ -29,8 +29,6 @@ int main(int argc, char *argv[]) fp = open("/dev/usrp_e0", O_RDWR); printf("fp = %d\n", fp); - sleep(1); // HACK HACK - spi_dat.slave = slave; spi_dat.data = data; spi_dat.length = length; diff --git a/host/apps/omap_debug/usrp_e.h b/host/apps/omap_debug/usrp_e.h index d4132021f..0b582f59b 100644 --- a/host/apps/omap_debug/usrp_e.h +++ b/host/apps/omap_debug/usrp_e.h @@ -66,8 +66,8 @@ struct usrp_e_i2c { #define USRP_E_READ_CTL16 _IOWR(USRP_E_IOC_MAGIC, 0x21, struct usrp_e_ctl16) #define USRP_E_WRITE_CTL32 _IOW(USRP_E_IOC_MAGIC, 0x22, struct usrp_e_ctl32) #define USRP_E_READ_CTL32 _IOWR(USRP_E_IOC_MAGIC, 0x23, struct usrp_e_ctl32) -#define USRP_E_SPI _IOW(USRP_E_IOC_MAGIC, 0x24, struct usrp_e_spi) -#define USRP_E_I2C_READ _IOR(USRP_E_IOC_MAGIC, 0x25, struct usrp_e_i2c) +#define USRP_E_SPI _IOWR(USRP_E_IOC_MAGIC, 0x24, struct usrp_e_spi) +#define USRP_E_I2C_READ _IOWR(USRP_E_IOC_MAGIC, 0x25, struct usrp_e_i2c) #define USRP_E_I2C_WRITE _IOW(USRP_E_IOC_MAGIC, 0x26, struct usrp_e_i2c) // Data transfer frame definition -- cgit v1.2.3 From b47920906bd1b0480bbcd8427b2d703889cb78e3 Mon Sep 17 00:00:00 2001 From: Philip Balister Date: Fri, 7 May 2010 19:23:58 +0000 Subject: Print an error and exit if open fails for some programs. --- host/apps/omap_debug/usrp-e-debug-pins.c | 4 ++++ host/apps/omap_debug/usrp-e-i2c.c | 6 ++++++ host/apps/omap_debug/usrp-e-spi.c | 7 +++++++ 3 files changed, 17 insertions(+) (limited to 'host/apps/omap_debug/usrp-e-spi.c') diff --git a/host/apps/omap_debug/usrp-e-debug-pins.c b/host/apps/omap_debug/usrp-e-debug-pins.c index d4e3f5223..d18bbf990 100644 --- a/host/apps/omap_debug/usrp-e-debug-pins.c +++ b/host/apps/omap_debug/usrp-e-debug-pins.c @@ -46,6 +46,10 @@ int main(int argc, char *argv[]) fp = open("/dev/usrp_e0", O_RDWR); printf("fp = %d\n", fp); + if (fp < 0) { + perror("Open failed"); + return -1; + } if (strcmp(argv[1], "0") == 0) { printf("Selected 0 based on %s\n", argv[1]); diff --git a/host/apps/omap_debug/usrp-e-i2c.c b/host/apps/omap_debug/usrp-e-i2c.c index 615dc557b..da8709ae1 100644 --- a/host/apps/omap_debug/usrp-e-i2c.c +++ b/host/apps/omap_debug/usrp-e-i2c.c @@ -37,6 +37,12 @@ int main(int argc, char *argv[]) fp = open("/dev/usrp_e0", O_RDWR); printf("fp = %d\n", fp); + if (fp < 0) { + perror("Open failed"); + return -1; + } + +// sleep(1); if (direction) { count = argc - 3; diff --git a/host/apps/omap_debug/usrp-e-spi.c b/host/apps/omap_debug/usrp-e-spi.c index d2c38e524..c353c409b 100644 --- a/host/apps/omap_debug/usrp-e-spi.c +++ b/host/apps/omap_debug/usrp-e-spi.c @@ -28,6 +28,13 @@ int main(int argc, char *argv[]) fp = open("/dev/usrp_e0", O_RDWR); printf("fp = %d\n", fp); + if (fp < 0) { + perror("Open failed"); + return -1; + } + +// sleep(1); + spi_dat.slave = slave; spi_dat.data = data; -- cgit v1.2.3