summaryrefslogtreecommitdiffstats
path: root/host
diff options
context:
space:
mode:
authorPhilip Balister <philip@opensdr.com>2010-03-26 15:22:12 +0000
committerPhilip Balister <philip@opensdr.com>2010-03-26 15:22:12 +0000
commit84df070f371b989ef51b6f2d04c131b34308e5e9 (patch)
tree33e1a5ab23504ac8d2f10ea27922aaa5b158e3a5 /host
parent717a6acd2b0687348c492cbf2e0813ffd63d847a (diff)
downloaduhd-84df070f371b989ef51b6f2d04c131b34308e5e9.tar.gz
uhd-84df070f371b989ef51b6f2d04c131b34308e5e9.tar.bz2
uhd-84df070f371b989ef51b6f2d04c131b34308e5e9.zip
Add test program to send characters to the wishbone uart.
Diffstat (limited to 'host')
-rw-r--r--host/apps/omap_debug/Makefile6
-rw-r--r--host/apps/omap_debug/usrp-e-uart.c37
2 files changed, 42 insertions, 1 deletions
diff --git a/host/apps/omap_debug/Makefile b/host/apps/omap_debug/Makefile
index 34446ccc3..13b834e28 100644
--- a/host/apps/omap_debug/Makefile
+++ b/host/apps/omap_debug/Makefile
@@ -1,6 +1,6 @@
CFLAGS=-Wall
-all : usrp-e-spi usrp-e-i2c usrp-e-rw
+all : usrp-e-spi usrp-e-i2c usrp-e-rw usrp-e-uart
usrp-e-spi : usrp-e-spi.c
@@ -8,8 +8,12 @@ usrp-e-i2c : usrp-e-i2c.c
usrp-e-rw : usrp-e-rw.c
gcc -o $@ $< -lpthread
+
+usrp-e-uart : usrp-e-uart.c
+
clean :
rm -f usrp-e-spi
rm -f usrp-e-i2c
rm -f usrp-e-rw
+ rm -f usrp-e-uart
diff --git a/host/apps/omap_debug/usrp-e-uart.c b/host/apps/omap_debug/usrp-e-uart.c
new file mode 100644
index 000000000..92f89f45c
--- /dev/null
+++ b/host/apps/omap_debug/usrp-e-uart.c
@@ -0,0 +1,37 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/types.h>
+#include <fcntl.h>
+#include <string.h>
+#include <sys/ioctl.h>
+
+#include "usrp_e.h"
+
+// Usage: usrp_e_uart <string>
+
+#define UART_WRITE_ADDR ((1<<6) + 16)
+
+int main(int argc, char *argv[])
+{
+ int fp, i, ret;
+ struct usrp_e_ctl16 d;
+ char *str = argv[1];
+
+ if (argc < 2) {
+ printf("Usage: usrp_e_uart <string>n");
+ exit(-1);
+ }
+
+ fp = open("/dev/usrp_e0", O_RDWR);
+ printf("fp = %d\n", fp);
+
+ for (i=0; i<strlen(str); i++) {
+ d.offset = UART_WRITE_ADDR;
+ d.count = 1;
+ d.buf[0] = str[i];
+ ret = ioctl(fp, USRP_E_WRITE_CTL16, &d);
+ printf("Wrote %X, to %X, ret = %d\n", d.buf[0], d.offset, ret);
+ }
+
+ return 0;
+}