aboutsummaryrefslogtreecommitdiffstats
path: root/host/apps
diff options
context:
space:
mode:
authorPhilip Balister <philip@opensdr.com>2010-04-02 19:49:45 +0000
committerPhilip Balister <philip@opensdr.com>2010-04-02 19:49:45 +0000
commitd8052db8e5614935241a4824a3f9711bfe34507d (patch)
treee70c2fa0d9d273b29bc353daa6d144a10bab1536 /host/apps
parent80b2b928df6e3c1caf68dee199593a0af1cb91ae (diff)
downloaduhd-d8052db8e5614935241a4824a3f9711bfe34507d.tar.gz
uhd-d8052db8e5614935241a4824a3f9711bfe34507d.tar.bz2
uhd-d8052db8e5614935241a4824a3f9711bfe34507d.zip
Convert to use register include file. Fix peek/poke16 program.
Add program to cycle through LED's and test buttons. Only pushbuttons tested at the moment.
Diffstat (limited to 'host/apps')
-rw-r--r--host/apps/omap_debug/Makefile14
-rw-r--r--host/apps/omap_debug/usrp-e-button.c56
-rw-r--r--host/apps/omap_debug/usrp-e-ctl.c20
-rw-r--r--host/apps/omap_debug/usrp-e-led.c35
-rwxr-xr-xhost/apps/omap_debug/usrp-e-uartbin0 -> 7143 bytes
5 files changed, 112 insertions, 13 deletions
diff --git a/host/apps/omap_debug/Makefile b/host/apps/omap_debug/Makefile
index 13b834e28..f292379f4 100644
--- a/host/apps/omap_debug/Makefile
+++ b/host/apps/omap_debug/Makefile
@@ -1,6 +1,6 @@
-CFLAGS=-Wall
+CFLAGS=-Wall -I../../lib/usrp/usrp_e/
-all : usrp-e-spi usrp-e-i2c usrp-e-rw usrp-e-uart
+all : usrp-e-spi usrp-e-i2c usrp-e-rw usrp-e-uart usrp-e-led usrp-e-ctl usrp-e-button
usrp-e-spi : usrp-e-spi.c
@@ -11,9 +11,17 @@ usrp-e-rw : usrp-e-rw.c
usrp-e-uart : usrp-e-uart.c
+usrp-e-led : usrp-e-led.c
+
+usrp-e-ctl : usrp-e-ctl.c
+
+usrp-e-button : usrp-e-button.c
+
clean :
rm -f usrp-e-spi
rm -f usrp-e-i2c
rm -f usrp-e-rw
rm -f usrp-e-uart
-
+ rm -f usrp-e-led
+ rm -f usrp-e-ctl
+ rm -f usrp-e-button
diff --git a/host/apps/omap_debug/usrp-e-button.c b/host/apps/omap_debug/usrp-e-button.c
new file mode 100644
index 000000000..fca501833
--- /dev/null
+++ b/host/apps/omap_debug/usrp-e-button.c
@@ -0,0 +1,56 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/types.h>
+#include <fcntl.h>
+#include <string.h>
+#include <sys/ioctl.h>
+#include <unistd.h>
+
+#include "usrp_e.h"
+#include "usrp_e_regs.hpp"
+
+// Usage: usrp_e_uart <string>
+
+#define PB1 (1<<8)
+#define PB2 (1<<9)
+#define PB3 (1<<10)
+#define P1 (0)
+#define P2 (0xFF)
+#define P3 (0xAA)
+#define P4 (0x55)
+
+int main(int argc, char *argv[])
+{
+ int fp, ret;
+ struct usrp_e_ctl16 d;
+ int pb1=0, pb2=0, pb3=0, p1=0, p2=0, p3=0, p4=0;
+
+ fp = open("/dev/usrp_e0", O_RDWR);
+ printf("fp = %d\n", fp);
+
+ d.offset = 6;
+ d.count = 1;
+
+ do {
+ ret = ioctl(fp, USRP_E_READ_CTL16, &d);
+ if (d.buf[0] & PB1) {
+ pb1 = 1;
+ printf("Pushbutton 1 hit\n");
+ }
+
+ if (d.buf[0] & PB2) {
+ pb2 = 1;
+ printf("Pushbutton 2 hit\n");
+ }
+
+ if (d.buf[0] & PB3) {
+ pb3 = 1;
+ printf("Pushbutton 3 hit\n");
+ }
+
+ sleep(1);
+
+ } while (!(pb1 && pb2 && pb3));
+
+ return 0;
+}
diff --git a/host/apps/omap_debug/usrp-e-ctl.c b/host/apps/omap_debug/usrp-e-ctl.c
index 045e7ce19..501a4870e 100644
--- a/host/apps/omap_debug/usrp-e-ctl.c
+++ b/host/apps/omap_debug/usrp-e-ctl.c
@@ -2,44 +2,44 @@
#include <stdlib.h>
#include <sys/types.h>
#include <fcntl.h>
-#include <linux/ioctl.h>
+#include <sys/ioctl.h>
-#include "usrp1_e.h"
+#include "usrp_e.h"
-// Usage: usrp1_e_ctl w|r offset number_of_values val1 val2 ....
+// Usage: usrp_e_ctl w|r offset number_of_values val1 val2 ....
int main(int argc, char *argv[])
{
int fp, i, cnt, ret;
- struct usrp1_e_ctl *ctl_data;
+ struct usrp_e_ctl16 *ctl_data;
if (argc < 4) {
- printf("Usage: usrp1_e_ctl w|r offset number_of_values val1 val2 ....\n");
+ printf("Usage: usrp_e_ctl w|r offset number_of_values val1 val2 ....\n");
exit(-1);
}
cnt = atoi(argv[3]);
- ctl_data = malloc(sizeof(struct usrp1_e_ctl) + cnt*2);
+ ctl_data = malloc(sizeof(struct usrp_e_ctl16) + cnt*2);
ctl_data->offset = atoi(argv[2]);
ctl_data->count = cnt;
- printf("Sizeof usrp1_e_ctl struct = %d\n", sizeof(struct usrp1_e_ctl));
+ printf("Sizeof usrp1_e_ctl struct = %d\n", sizeof(struct usrp_e_ctl16));
- fp = open("/dev/usrp1_e0", O_RDWR);
+ fp = open("/dev/usrp_e0", O_RDWR);
printf("fp = %d\n", fp);
if (*argv[1] == 'w') {
for (i=0; i<cnt; i++)
ctl_data->buf[i] = atoi(argv[4+i]);
- ret = ioctl(fp, USRP1_E_WRITE_CTL, ctl_data);
+ ret = ioctl(fp, USRP_E_WRITE_CTL16, ctl_data);
printf("Return value from write ioctl = %d\n", ret);
}
if (*argv[1] == 'r') {
- ret = ioctl(fp, USRP1_E_READ_CTL, ctl_data);
+ ret = ioctl(fp, USRP_E_READ_CTL16, ctl_data);
printf("Return value from write ioctl = %d\n", ret);
for (i=0; i<ctl_data->count; i++) {
diff --git a/host/apps/omap_debug/usrp-e-led.c b/host/apps/omap_debug/usrp-e-led.c
new file mode 100644
index 000000000..159251c8a
--- /dev/null
+++ b/host/apps/omap_debug/usrp-e-led.c
@@ -0,0 +1,35 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/types.h>
+#include <fcntl.h>
+#include <string.h>
+#include <sys/ioctl.h>
+#include <unistd.h>
+
+#include "usrp_e.h"
+#include "usrp_e_regs.hpp"
+
+// Usage: usrp_e_uart <string>
+
+
+int main(int argc, char *argv[])
+{
+ int fp, i, ret;
+ struct usrp_e_ctl16 d;
+
+ fp = open("/dev/usrp_e0", O_RDWR);
+ printf("fp = %d\n", fp);
+
+ d.offset = 4;
+ d.count = 1;
+
+ while (1) {
+ for (i=0; i<8; i++) {
+ d.buf[0] = i;
+ ret = ioctl(fp, USRP_E_WRITE_CTL16, &d);
+ sleep(1);
+ }
+ }
+
+ return 0;
+}
diff --git a/host/apps/omap_debug/usrp-e-uart b/host/apps/omap_debug/usrp-e-uart
new file mode 100755
index 000000000..5781f0db2
--- /dev/null
+++ b/host/apps/omap_debug/usrp-e-uart
Binary files differ