aboutsummaryrefslogtreecommitdiffstats
path: root/host/apps
diff options
context:
space:
mode:
authorPhilip Balister <balister@moose.(none)>2010-03-24 15:49:08 -0400
committerPhilip Balister <balister@moose.(none)>2010-03-24 15:49:08 -0400
commit4f5cd64188c7e2b5490d910d5e86301c053960ea (patch)
tree7e9f07b55f08cd52bc594c59bc23a2ba173e99c2 /host/apps
parentac482c5a469d6a02c8a83e0c0c7e10ce4eaf5718 (diff)
downloaduhd-4f5cd64188c7e2b5490d910d5e86301c053960ea.tar.gz
uhd-4f5cd64188c7e2b5490d910d5e86301c053960ea.tar.bz2
uhd-4f5cd64188c7e2b5490d910d5e86301c053960ea.zip
Makefile and usrp-e-spi edits, add i2c test program.
Diffstat (limited to 'host/apps')
-rw-r--r--host/apps/omap_debug/Makefile10
-rw-r--r--host/apps/omap_debug/usrp-e-i2c.c71
-rw-r--r--host/apps/omap_debug/usrp-e-spi.c4
3 files changed, 84 insertions, 1 deletions
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 <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/types.h>
+#include <fcntl.h>
+#include <sys/ioctl.h>
+
+#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; i<count; i++) {
+ i2c_msg->data[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; i<count; i++) {
+ printf(" %X", i2c_msg->data[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 <stdlib.h>
#include <sys/types.h>
#include <fcntl.h>
-#include <linux/ioctl.h>
+#include <sys/ioctl.h>
#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;
}