aboutsummaryrefslogtreecommitdiffstats
path: root/host/apps/omap_debug/usrp-e-spi.c
diff options
context:
space:
mode:
authorJosh Blum <josh@joshknows.com>2010-11-23 13:50:37 -0800
committerJosh Blum <josh@joshknows.com>2010-11-23 13:50:37 -0800
commit30ce5acedd3e0dc6fc97d7597781a0a4828812f2 (patch)
tree28d010c0938121f587e1820849c34ee900e7f74b /host/apps/omap_debug/usrp-e-spi.c
parent8ce75a3ca7a51f4bdee87d78a610a0f2519473ae (diff)
parent13ae4786e091d5581baf31c9967dca822ef15e39 (diff)
downloaduhd-30ce5acedd3e0dc6fc97d7597781a0a4828812f2.tar.gz
uhd-30ce5acedd3e0dc6fc97d7597781a0a4828812f2.tar.bz2
uhd-30ce5acedd3e0dc6fc97d7597781a0a4828812f2.zip
Merge branch 'usrp_e100' into next
Conflicts: images/Makefile
Diffstat (limited to 'host/apps/omap_debug/usrp-e-spi.c')
-rw-r--r--host/apps/omap_debug/usrp-e-spi.c54
1 files changed, 54 insertions, 0 deletions
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..c353c409b
--- /dev/null
+++ b/host/apps/omap_debug/usrp-e-spi.c
@@ -0,0 +1,54 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <fcntl.h>
+#include <sys/ioctl.h>
+
+#include "usrp_e.h"
+
+// Usage: usrp_e_spi w|rb slave data
+
+int main(int argc, char *argv[])
+{
+ int fp, slave, length, ret;
+ unsigned int data;
+ struct usrp_e_spi spi_dat;
+
+ if (argc < 5) {
+ printf("Usage: usrp_e_spi w|rb slave transfer_length data\n");
+ exit(-1);
+ }
+
+ slave = atoi(argv[2]);
+ length = atoi(argv[3]);
+ data = atoll(argv[4]);
+
+ printf("Data = %X\n", data);
+
+ 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;
+ spi_dat.length = length;
+ spi_dat.flags = UE_SPI_PUSH_FALL | UE_SPI_LATCH_RISE;
+
+ if (*argv[1] == 'r') {
+ spi_dat.readback = 1;
+ ret = ioctl(fp, USRP_E_SPI, &spi_dat);
+ printf("Ioctl returns: %d, Data returned = %d\n", ret, spi_dat.data);
+ } else {
+ spi_dat.readback = 0;
+ ioctl(fp, USRP_E_SPI, &spi_dat);
+ }
+
+ return 0;
+}