[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] r7167 - in usrp2/trunk: firmware/apps firmware/lib hos
From: |
eb |
Subject: |
[Commit-gnuradio] r7167 - in usrp2/trunk: firmware/apps firmware/lib host/apps host/lib |
Date: |
Thu, 13 Dec 2007 21:30:40 -0700 (MST) |
Author: eb
Date: 2007-12-13 21:30:40 -0700 (Thu, 13 Dec 2007)
New Revision: 7167
Modified:
usrp2/trunk/firmware/apps/rx_only.c
usrp2/trunk/firmware/lib/memory_map.h
usrp2/trunk/firmware/lib/u2_init.c
usrp2/trunk/host/apps/rx_samples.cc
usrp2/trunk/host/lib/usrp2_basic.cc
Log:
work-in-progress ready for sim ;)
Modified: usrp2/trunk/firmware/apps/rx_only.c
===================================================================
--- usrp2/trunk/firmware/apps/rx_only.c 2007-12-14 03:41:15 UTC (rev 7166)
+++ usrp2/trunk/firmware/apps/rx_only.c 2007-12-14 04:30:40 UTC (rev 7167)
@@ -63,7 +63,7 @@
// 4 lines of ethernet hdr + 1 line (word0)
// DSP Rx writes timestamp followed by nlines_per_frame of samples
#define DSP_RX_FIRST_LINE 5
-#define DSP_RX_SAMPLES_PER_FRAME 125
+#define DSP_RX_SAMPLES_PER_FRAME 128
#define DSP_RX_EXTRA_LINES 1 // writes timestamp
// receive from DSP
@@ -146,7 +146,7 @@
dsp_rx_regs->clear_state = 1; // reset
dsp_rx_regs->freq = 0;
dsp_rx_regs->scale_iq = (1 << 16) | 1;
- dsp_rx_regs->decim_rate = 24; // register gets N - 1
+ dsp_rx_regs->decim_rate = 127; // register gets N - 1
uint32_t cmd = MK_RX_CMD(10000 * DSP_RX_SAMPLES_PER_FRAME,
DSP_RX_SAMPLES_PER_FRAME);
printf("rx_command = "); puthex32_nl(cmd);
@@ -274,9 +274,11 @@
{
uint32_t status = buffer_pool_status->status;
- putstr("irq: ");
- puthex32(status);
- putchar('\n');
+ if (0){
+ putstr("irq: ");
+ puthex32(status);
+ putchar('\n');
+ }
if (status & BPS_ERROR_ALL){
// FIXME rare path, handle error conditions
@@ -331,8 +333,8 @@
bp_receive_to_buf(CPU_RX_BUF, PORT_ETH, 1, 0, 255);
// FIXME fake that we got a start command
- //u2_mac_addr_t host = {{ 0x00, 0x0A, 0xE4, 0x3E, 0xD2, 0xD5 }};
- //start_rx_cmd(&host);
+ u2_mac_addr_t host = {{ 0x00, 0x0A, 0xE4, 0x3E, 0xD2, 0xD5 }};
+ start_rx_cmd(&host);
while(1){
// FIXME perhaps handle low-pri stuff here
Modified: usrp2/trunk/firmware/lib/memory_map.h
===================================================================
--- usrp2/trunk/firmware/lib/memory_map.h 2007-12-14 03:41:15 UTC (rev
7166)
+++ usrp2/trunk/firmware/lib/memory_map.h 2007-12-14 04:30:40 UTC (rev
7167)
@@ -313,6 +313,9 @@
#define SERDES_LOOPEN 2
#define SERDES_RXEN 1
+#define ADC_CTRL_ON 0x00
+#define ADC_CTRL_OFF 0x0A
+
#define output_regs ((output_regs_t *) MISC_OUTPUT_BASE)
// --- dsp tx regs ---
Modified: usrp2/trunk/firmware/lib/u2_init.c
===================================================================
--- usrp2/trunk/firmware/lib/u2_init.c 2007-12-14 03:41:15 UTC (rev 7166)
+++ usrp2/trunk/firmware/lib/u2_init.c 2007-12-14 04:30:40 UTC (rev 7167)
@@ -55,10 +55,8 @@
output_regs->clk_ctrl = 0x1C;
-#if 1
// Enable ADCs
- output_regs->adc_ctrl = 0x0A; // Power up and enable outputs
-#endif
+ output_regs->adc_ctrl = ADC_CTRL_ON;
// Enable clock to ADCs and DACs
spi_transact(SPI_TXONLY, SPI_SS_AD9510, 0x00003F00, 24, 0); // Turn on
output 3 (DAC CLK), normal levels
Modified: usrp2/trunk/host/apps/rx_samples.cc
===================================================================
--- usrp2/trunk/host/apps/rx_samples.cc 2007-12-14 03:41:15 UTC (rev 7166)
+++ usrp2/trunk/host/apps/rx_samples.cc 2007-12-14 04:30:40 UTC (rev 7167)
@@ -21,11 +21,62 @@
#endif
#include "usrp2_basic.h"
#include <iostream>
+#include <complex>
+#include <getopt.h>
+typedef std::complex<float> fcomplex;
+
+/*
+ * Vectorize me!
+ */
+void
+convert_samples_to_complex(size_t nsamples,
+ uint32_t *i_samples,
+ fcomplex *c_samples)
+{
+ uint32_t *p = i_samples;
+ for (size_t i = 0; i < nsamples; i++){
+ int16_t si = ((int16_t) (p[i] >> 16));
+ int16_t sq = ((int16_t) (p[i] & 0xffff));
+ c_samples[i] = fcomplex((float) si, (float) sq);
+ }
+}
+
+
+static void
+usage(const char *progname)
+{
+ fprintf(stderr, "usage: %s [-o <output_file> ] [-N nsamples] [-h]\n",
+ progname);
+}
+
int
main(int argc, char **argv)
{
+ int ch;
+ const char *output_filename = "samples.dat";
+ ssize_t nsamples = -1; // inf
+
+ while ((ch = getopt(argc, argv, "o:N:h")) != EOF){
+ switch (ch){
+ case 'o':
+ output_filename = optarg;
+ break;
+
+ case 'N':
+ nsamples = strtol(optarg, 0, 0);
+ break;
+
+ case 'h':
+ default:
+ usage(argv[0]);
+ exit(1);
+ }
+ }
+
+ FILE *of = fopen(output_filename, "wb");
+
const char *interface = "eth0";
usrp2_basic *u2 = new usrp2_basic();
@@ -53,19 +104,21 @@
}
while (1){
+ static const int MAX_SAMPLES = 2048/sizeof(uint32_t);
u2_eth_samples_t pkt;
+ fcomplex c_samples[MAX_SAMPLES];
// read samples
int n = u2->read_samples(which, &pkt);
if (n <= 0)
break;
+
+ printf("%3d %8d\n", n, u2p_timestamp(&pkt.fixed));
- uint32_t *p = pkt.samples;
- for (int j = 0; j < n; j++){
- int16_t si = (int16_t) (p[j] >> 16);
- int16_t sq = (int16_t) (p[j] & 0xffff);
- printf("%6d %6d\n", si, sq);
- }
+ convert_samples_to_complex(n, pkt.samples, c_samples);
+ // size_t r = fwrite(c_samples, sizeof(fcomplex), n, of);
+ size_t r = fwrite(pkt.samples, sizeof(uint32_t), n, of);
+ fflush(of);
}
if (!u2->stop_rx(which)){
Modified: usrp2/trunk/host/lib/usrp2_basic.cc
===================================================================
--- usrp2/trunk/host/lib/usrp2_basic.cc 2007-12-14 03:41:15 UTC (rev 7166)
+++ usrp2/trunk/host/lib/usrp2_basic.cc 2007-12-14 04:30:40 UTC (rev 7167)
@@ -221,14 +221,14 @@
// FIXME check channel
- print_pkt(stdout, pkt);
-
+
+ // shouldn't happen
if ((size_t) len < sizeof(u2_eth_packet_t))
return 0;
// convert to samples
int r = (len - sizeof(u2_eth_packet_t)) / sizeof(uint32_t);
- printf("read_raw_samples = %d\n", r);
+ // printf("read_raw_samples = %d\n", r);
return r;
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Commit-gnuradio] r7167 - in usrp2/trunk: firmware/apps firmware/lib host/apps host/lib,
eb <=