summaryrefslogtreecommitdiffstats
path: root/host
diff options
context:
space:
mode:
authorJosh Blum <josh@joshknows.com>2011-08-20 03:24:11 +0000
committerJosh Blum <josh@joshknows.com>2011-08-31 18:44:34 -0700
commit20d5a87352ea1a29d102f9b693062684f9555446 (patch)
tree8dd4bcd174d32c828199cf1cd138135f9490a221 /host
parent927da3982ede4aef07d0dc42597c00b38c63cc48 (diff)
downloaduhd-20d5a87352ea1a29d102f9b693062684f9555446.tar.gz
uhd-20d5a87352ea1a29d102f9b693062684f9555446.tar.bz2
uhd-20d5a87352ea1a29d102f9b693062684f9555446.zip
e100: changes to support bus work
Diffstat (limited to 'host')
-rw-r--r--host/lib/usrp/e100/e100_impl.hpp2
-rw-r--r--host/usrp_e_utils/usrp-e-loopback.c34
2 files changed, 28 insertions, 8 deletions
diff --git a/host/lib/usrp/e100/e100_impl.hpp b/host/lib/usrp/e100/e100_impl.hpp
index d60d6a63c..76af828d0 100644
--- a/host/lib/usrp/e100/e100_impl.hpp
+++ b/host/lib/usrp/e100/e100_impl.hpp
@@ -42,7 +42,7 @@
uhd::transport::zero_copy_if::sptr e100_make_mmap_zero_copy(e100_ctrl::sptr iface);
-static const double E100_LINK_RATE_BPS = 256e6/8;
+static const double E100_LINK_RATE_BPS = 166e6/4*2; //gpmc_clock_rate/clk_div*bytes_per_transaction
static const std::string E100_I2C_DEV_NODE = "/dev/i2c-3";
static const std::string E100_FPGA_FILE_NAME = "usrp_e100_fpga_v2.bin";
static const boost::uint16_t E100_FPGA_COMPAT_NUM = 0x05;
diff --git a/host/usrp_e_utils/usrp-e-loopback.c b/host/usrp_e_utils/usrp-e-loopback.c
index 762e55ac8..6730967de 100644
--- a/host/usrp_e_utils/usrp-e-loopback.c
+++ b/host/usrp_e_utils/usrp-e-loopback.c
@@ -7,6 +7,7 @@
#include <stdlib.h>
#include <unistd.h>
#include <stddef.h>
+#include <stdint.h>
#include <sys/mman.h>
#include <sys/time.h>
#include <poll.h>
@@ -17,12 +18,24 @@ static int packet_data_length;
static int error;
struct pkt {
- int len;
- int checksum;
- int seq_num;
- short data[1024-6];
+ uint32_t words32;
+ uint32_t len;
+ uint32_t checksum;
+ uint32_t seq_num;
+ uint16_t data[1024-8];
};
+void print_pkt(const struct pkt *p){
+ printf("p->words32 %d\n", p->words32);
+ printf("p->len %d\n", p->len);
+ printf("p->checksum %d\n", p->checksum);
+ printf("p->seq_num %d\n", p->seq_num);
+ size_t i;
+ for (i = 0; i < 5; i++){
+ printf(" buff[%u] = 0x%.4x\n", i, p->data[i]);
+ }
+}
+
struct ring_buffer_info (*rxi)[];
struct ring_buffer_info (*txi)[];
struct pkt (*rx_buf)[200];
@@ -137,7 +150,7 @@ static void *read_thread(void *threadid)
if (rb_read == rb_size.num_rx_frames)
rb_read = 0;
- bytes_transfered += cnt;
+ bytes_transfered += p->len*2;//cnt;
if (bytes_transfered > (100 * 1000000)) {
struct timeval finish_time, d_time;
@@ -189,6 +202,8 @@ static void *write_thread(void *threadid)
else
p->len = (random() & 0x1ff) + (1004 - 512);
+ p->words32 = 4 /*hdr*/ + p->len/2;
+
p->checksum = calc_checksum(p);
if (!((*txi)[rb_write].flags & RB_KERNEL)) {
@@ -199,9 +214,9 @@ static void *write_thread(void *threadid)
poll(&pfd, 1, -1);
}
- memcpy(&(*tx_buf)[rb_write], tx_data, p->len * 2 + 12);
+ memcpy(&(*tx_buf)[rb_write], tx_data, p->words32*sizeof(uint32_t));
- (*txi)[rb_write].len = p->len * 2 + 12;
+ (*txi)[rb_write].len = p->words32*sizeof(uint32_t);
(*txi)[rb_write].flags = RB_USER;
rb_write++;
@@ -212,6 +227,7 @@ static void *write_thread(void *threadid)
// if (cnt < 0)
// printf("Error returned from write: %d\n", cnt);
// sleep(1);
+
}
return NULL;
}
@@ -287,11 +303,15 @@ int main(int argc, char *argv[])
sleep(1);
#endif
+#if 1
if (pthread_create(&tx, NULL, write_thread, (void *) t)) {
printf("Failed to create tx thread\n");
exit(-1);
}
+ sleep(1);
+#endif
+
// while (!error)
sleep(1000000000);