summaryrefslogtreecommitdiffstats
path: root/host/apps
diff options
context:
space:
mode:
Diffstat (limited to 'host/apps')
-rw-r--r--host/apps/omap_debug/Makefile5
-rw-r--r--host/apps/omap_debug/usrp-e-fpga-rw.c32
-rw-r--r--host/apps/omap_debug/usrp-e-lb-test.c58
-rw-r--r--host/apps/omap_debug/usrp_e.h6
4 files changed, 93 insertions, 8 deletions
diff --git a/host/apps/omap_debug/Makefile b/host/apps/omap_debug/Makefile
index f48eb9539..14be592ff 100644
--- a/host/apps/omap_debug/Makefile
+++ b/host/apps/omap_debug/Makefile
@@ -1,6 +1,6 @@
CFLAGS=-Wall -I../../lib/usrp/usrp_e/
-all : usrp-e-spi usrp-e-i2c usrp-e-rw usrp-e-uart usrp-e-led usrp-e-ctl usrp-e-button usrp-e-uart-rx fpga-downloader usrp-e-gpio usrp-e-debug-pins usrp-e-rw-random usrp-e-fpga-rw
+all : usrp-e-spi usrp-e-i2c usrp-e-rw usrp-e-uart usrp-e-led usrp-e-ctl usrp-e-button usrp-e-uart-rx fpga-downloader usrp-e-gpio usrp-e-debug-pins usrp-e-rw-random usrp-e-fpga-rw usrp-e-lb-test
usrp-e-spi : usrp-e-spi.c
@@ -29,6 +29,8 @@ fpga-downloader : fpga-downloader.cc
usrp-e-gpio : usrp-e-gpio.c
+usrp-e-lb-test : usrp-e-lb-test.c
+
usrp-e-debug-pins : usrp-e-debug-pins.c
clean :
rm -f usrp-e-spi
@@ -44,3 +46,4 @@ clean :
rm -f fpga-downloader
rm -f usrp-e-gpio
rm -f usrp-e-debug-pins
+ rm -f usrp-e-lb-test
diff --git a/host/apps/omap_debug/usrp-e-fpga-rw.c b/host/apps/omap_debug/usrp-e-fpga-rw.c
index 455657203..f3fa1499a 100644
--- a/host/apps/omap_debug/usrp-e-fpga-rw.c
+++ b/host/apps/omap_debug/usrp-e-fpga-rw.c
@@ -38,6 +38,8 @@ static void *read_thread(void *threadid)
int cnt, prev_seq_num;
struct usrp_transfer_frame *rx_data;
struct pkt *p;
+ int rx_pkt_cnt;
+ int i;
printf("Greetings from the reading thread!\n");
@@ -51,23 +53,39 @@ static void *read_thread(void *threadid)
prev_seq_num = 0;
+ rx_pkt_cnt = 0;
+
while (1) {
cnt = read(fp, rx_data, 2048);
if (cnt < 0)
printf("Error returned from read: %d\n", cnt);
+ rx_pkt_cnt++;
+
+ if (rx_pkt_cnt == 512) {
+ printf(".");
+ fflush(stdout);
+ rx_pkt_cnt = 0;
+ }
+ if (rx_data->flags & RB_OVERRUN)
+ printf("RX ring buffer overrun occurred at packet %d\n", rx_pkt_cnt);
+
+// for (i = 0; i < 10; i++)
+// printf(" %d", p->data[i]);
+// printf("\n");
+
// printf("Packet received, flags = %X, len = %d\n", rx_data->flags, rx_data->len);
// printf("p->seq_num = %d\n", p->seq_num);
- if (p->seq_num != prev_seq_num + 1)
- printf("Sequence number fail, current = %X, previous = %X\n",
- p->seq_num, prev_seq_num);
- prev_seq_num = p->seq_num;
+// if (p->seq_num != prev_seq_num + 1)
+// printf("Sequence number fail, current = %X, previous = %X\n",
+// p->seq_num, prev_seq_num);
+// prev_seq_num = p->seq_num;
- if (calc_checksum(p) != p->checksum)
- printf("Checksum fail packet = %X, expected = %X\n",
- calc_checksum(p), p->checksum);
+// if (calc_checksum(p) != p->checksum)
+// printf("Checksum fail packet = %X, expected = %X\n",
+// calc_checksum(p), p->checksum);
// printf("\n");
}
diff --git a/host/apps/omap_debug/usrp-e-lb-test.c b/host/apps/omap_debug/usrp-e-lb-test.c
new file mode 100644
index 000000000..675de8622
--- /dev/null
+++ b/host/apps/omap_debug/usrp-e-lb-test.c
@@ -0,0 +1,58 @@
+#include <stdio.h>
+#include <sys/types.h>
+#include <fcntl.h>
+#include <pthread.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <stddef.h>
+#include "usrp_e.h"
+
+// max length #define PKT_DATA_LENGTH 1016
+
+int main(int argc, char *argv[])
+{
+ struct usrp_transfer_frame *tx_data, *rx_data;
+ int i, fp, packet_data_length, cnt;
+ struct usrp_e_ctl16 d;
+
+ if (argc < 2) {
+ printf("%s data_size (in bytes < 2040)\n", argv[0]);
+ return -1;
+ }
+
+ packet_data_length = atoi(argv[1]);
+
+ fp = open("/dev/usrp_e0", O_RDWR);
+
+ d.offset = 14;
+ d.count = 1;
+ d.buf[0] = (1 << 13);
+ ioctl(fp, USRP_E_WRITE_CTL16, &d);
+
+ tx_data = malloc(2048);
+ rx_data = malloc(2048);
+
+ tx_data->flags = 0;
+ tx_data->len = sizeof(struct usrp_transfer_frame) + packet_data_length;
+
+ while (1) {
+
+ for (i = 0; i < packet_data_length; i++) {
+ tx_data->buf[i] = random() >> 24;
+
+ }
+
+ cnt = write(fp, tx_data, 2048);
+ cnt = read(fp, rx_data, 2048);
+
+ if (tx_data->len != rx_data->len)
+ printf("Bad frame length sent %d, read %d\n", tx_data->len, rx_data->len);
+
+ for (i = 0; i < packet_data_length; i++) {
+ if (tx_data->buf[i] != rx_data->buf[i])
+ printf("Bad data at %d, sent %d, received %d\n", i, tx_data->buf[i], rx_data->buf[i]);
+ }
+ printf("---------------------------------------------------\n");
+ sleep(1);
+ }
+}
diff --git a/host/apps/omap_debug/usrp_e.h b/host/apps/omap_debug/usrp_e.h
index 48a3201cb..d4132021f 100644
--- a/host/apps/omap_debug/usrp_e.h
+++ b/host/apps/omap_debug/usrp_e.h
@@ -1,3 +1,4 @@
+
/*
* Copyright (C) 2010 Ettus Research, LLC
*
@@ -77,6 +78,11 @@ struct usrp_transfer_frame {
__u8 buf[];
};
+// Flag defines
+#define RB_USER (1 << 0)
+#define RB_KERNEL (1 << 1)
+#define RB_OVERRUN (1 << 2)
+
struct ring_buffer_entry {
unsigned long dma_addr;
struct usrp_transfer_frame *frame_addr;