[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] r8596 - in usrp2/trunk/firmware: apps include lib
From: |
eb |
Subject: |
[Commit-gnuradio] r8596 - in usrp2/trunk/firmware: apps include lib |
Date: |
Mon, 16 Jun 2008 21:35:47 -0600 (MDT) |
Author: eb
Date: 2008-06-16 21:35:46 -0600 (Mon, 16 Jun 2008)
New Revision: 8596
Modified:
usrp2/trunk/firmware/apps/app_common_v2.c
usrp2/trunk/firmware/apps/app_common_v2.h
usrp2/trunk/firmware/apps/rx_only_v2.c
usrp2/trunk/firmware/apps/tx_only_v2.c
usrp2/trunk/firmware/apps/txrx.c
usrp2/trunk/firmware/include/usrp2_eth_packet.h
usrp2/trunk/firmware/lib/db.h
usrp2/trunk/firmware/lib/db_init.c
usrp2/trunk/firmware/lib/db_tvrx.c
Log:
tx_config and rx_config now return replies
Modified: usrp2/trunk/firmware/apps/app_common_v2.c
===================================================================
--- usrp2/trunk/firmware/apps/app_common_v2.c 2008-06-16 23:09:30 UTC (rev
8595)
+++ usrp2/trunk/firmware/apps/app_common_v2.c 2008-06-17 03:35:46 UTC (rev
8596)
@@ -26,6 +26,7 @@
#include "ethernet.h"
#include "nonstdio.h"
#include "print_rmon_regs.h"
+#include "db.h"
#include <string.h>
volatile bool link_is_up = false; // eth handler sets this
@@ -96,6 +97,10 @@
unsigned char *s = &reply[sizeof(u2_eth_packet_t)];
size_t reply_len = 0;
+ // initialize reply
+ memset(reply, 0, sizeof(reply));
+ set_reply_hdr((u2_eth_packet_t *) reply, pkt);
+
// point to beginning of payload (subpackets)
unsigned char *p = ((unsigned char *) pkt) + sizeof(u2_eth_packet_t);
@@ -105,8 +110,6 @@
switch(opcode){
case OP_ID:
- memset(reply, 0, sizeof(reply));
- set_reply_hdr((u2_eth_packet_t *) reply, pkt);
{
op_id_reply_t *r = (op_id_reply_t *) s;
reply_len = sizeof(u2_eth_packet_t) + sizeof(op_id_reply_t);
@@ -124,11 +127,13 @@
break;
case OP_CONFIG_TX_V2:
- config_tx_v2_cmd((op_config_tx_v2_t *) p);
+ config_tx_v2_cmd((op_config_tx_v2_t *) p, (op_config_tx_reply_v2_t *) s);
+ send_reply(reply, sizeof(u2_eth_packet_t) + s[1]);
break;
case OP_CONFIG_RX_V2:
- config_rx_v2_cmd((op_config_rx_v2_t *) p);
+ config_rx_v2_cmd((op_config_rx_v2_t *) p, (op_config_rx_reply_v2_t *) s);
+ send_reply(reply, sizeof(u2_eth_packet_t) + s[1]);
break;
case OP_START_RX_STREAMING:
@@ -144,8 +149,6 @@
break;
case OP_READ_TIME:
- memset(reply, 0, sizeof(reply));
- set_reply_hdr((u2_eth_packet_t *) reply, pkt);
{
op_read_time_reply_t *r = (op_read_time_reply_t *) s;
reply_len = sizeof(u2_eth_packet_t) + sizeof(op_read_time_reply_t);
@@ -231,3 +234,103 @@
putstr(" residual_freq "); print_fxpt_freq(r->residual_freq); newline();
printf(" inverted %s\n", r->inverted ? "true" : "false");
}
+
+
+void
+config_tx_v2_cmd(const op_config_tx_v2_t *p, op_config_tx_reply_v2_t *r)
+{
+ struct tune_result tune_result;
+ memset(&tune_result, 0, sizeof(tune_result));
+
+ bool ok = true;
+
+ if (p->valid & CFGV_GAIN){
+ ok &= db_set_gain(tx_dboard, p->gain);
+ }
+
+ if (p->valid & CFGV_FREQ){
+ u2_fxpt_freq_t f = u2_fxpt_freq_from_hilo(p->freq_hi, p->freq_lo);
+ bool tune_ok = db_tune(tx_dboard, f, &tune_result);
+ ok &= tune_ok;
+ print_tune_result("Tx", tune_ok, f, &tune_result);
+ }
+
+ if (p->valid & CFGV_INTERP_DECIM){
+ dsp_tx_regs->interp_rate = p->interp;
+ }
+
+ if (p->valid & CFGV_SCALE_IQ){
+ dsp_tx_regs->scale_iq = p->scale_iq;
+ }
+
+ // Build reply; it's sent by our caller.
+
+ r->opcode = OP_CONFIG_TX_REPLY_V2;
+ r->len = sizeof(op_config_tx_reply_v2_t);
+ r->rid = p->rid;
+ r->ok = ok;
+ r->inverted = tune_result.inverted;
+ r->baseband_freq_hi = u2_fxpt_freq_hi(tune_result.baseband_freq);
+ r->baseband_freq_lo = u2_fxpt_freq_lo(tune_result.baseband_freq);
+ r->duc_freq_hi = u2_fxpt_freq_hi(tune_result.dxc_freq);
+ r->duc_freq_lo = u2_fxpt_freq_lo(tune_result.dxc_freq);
+ r->residual_freq_hi = u2_fxpt_freq_hi(tune_result.residual_freq);
+ r->residual_freq_lo = u2_fxpt_freq_lo(tune_result.residual_freq);
+}
+
+void
+config_rx_v2_cmd(const op_config_rx_v2_t *p, op_config_rx_reply_v2_t *r)
+{
+ struct tune_result tune_result;
+ memset(&tune_result, 0, sizeof(tune_result));
+
+ bool ok = true;
+
+ if (p->valid & CFGV_GAIN){
+ ok &= db_set_gain(rx_dboard, p->gain);
+ }
+
+ if (p->valid & CFGV_FREQ){
+ u2_fxpt_freq_t f = u2_fxpt_freq_from_hilo(p->freq_hi, p->freq_lo);
+ bool tune_ok = db_tune(rx_dboard, f, &tune_result);
+ ok &= tune_ok;
+ print_tune_result("Rx", tune_ok, f, &tune_result);
+ }
+
+ if (p->valid & CFGV_INTERP_DECIM){
+ int decim = p->decim;
+ int hb1 = 0;
+ int hb2 = 0;
+
+ if(!(decim & 1)) {
+ hb2 = 1;
+ decim = decim >> 1;
+ }
+
+ if(!(decim & 1)) {
+ hb1 = 1;
+ decim = decim >> 1;
+ }
+
+ dsp_rx_regs->decim_rate = (hb1<<9) | (hb2<<8) | decim;
+ // printf("Decim: %d, register %d\n", p->decim, (hb1<<9) | (hb2<<8) |
decim);
+ }
+
+ if (p->valid & CFGV_SCALE_IQ){
+ dsp_rx_regs->scale_iq = p->scale_iq;
+ }
+
+ // Build reply; it's sent by our caller.
+
+ r->opcode = OP_CONFIG_RX_REPLY_V2;
+ r->len = sizeof(op_config_rx_reply_v2_t);
+ r->rid = p->rid;
+ r->ok = ok;
+ r->inverted = tune_result.inverted;
+ r->baseband_freq_hi = u2_fxpt_freq_hi(tune_result.baseband_freq);
+ r->baseband_freq_lo = u2_fxpt_freq_lo(tune_result.baseband_freq);
+ r->ddc_freq_hi = u2_fxpt_freq_hi(tune_result.dxc_freq);
+ r->ddc_freq_lo = u2_fxpt_freq_lo(tune_result.dxc_freq);
+ r->residual_freq_hi = u2_fxpt_freq_hi(tune_result.residual_freq);
+ r->residual_freq_lo = u2_fxpt_freq_lo(tune_result.residual_freq);
+}
Modified: usrp2/trunk/firmware/apps/app_common_v2.h
===================================================================
--- usrp2/trunk/firmware/apps/app_common_v2.h 2008-06-16 23:09:30 UTC (rev
8595)
+++ usrp2/trunk/firmware/apps/app_common_v2.h 2008-06-17 03:35:46 UTC (rev
8596)
@@ -54,9 +54,8 @@
u2_fxpt_freq_t target_freq, struct tune_result *r);
-// FIXME move these somewhere else?
-void config_tx_v2_cmd(op_config_tx_v2_t *p);
-void config_rx_v2_cmd(op_config_rx_v2_t *p);
+void config_tx_v2_cmd(const op_config_tx_v2_t *p, op_config_tx_reply_v2_t *r);
+void config_rx_v2_cmd(const op_config_rx_v2_t *p, op_config_rx_reply_v2_t *r);
void start_rx_streaming_cmd(const u2_mac_addr_t *host, op_start_rx_streaming_t
*p);
void stop_rx_cmd(void);
Modified: usrp2/trunk/firmware/apps/rx_only_v2.c
===================================================================
--- usrp2/trunk/firmware/apps/rx_only_v2.c 2008-06-16 23:09:30 UTC (rev
8595)
+++ usrp2/trunk/firmware/apps/rx_only_v2.c 2008-06-17 03:35:46 UTC (rev
8596)
@@ -104,44 +104,7 @@
static volatile bool link_is_up = false; // eth handler sets this
-void
-config_tx_v2_cmd(op_config_tx_v2_t *p)
-{
- // FIXME nop
-}
-
void
-config_rx_v2_cmd(op_config_rx_v2_t *p)
-{
- struct tune_result tune_result;
- memset(&tune_result, 0, sizeof(tune_result));
-
- bool ok = true;
-
- if (p->valid & CFGV_GAIN){
- ok &= rx_dboard->set_gain(rx_dboard, p->gain);
- }
-
- if (p->valid & CFGV_FREQ){
- u2_fxpt_freq_t f = u2_fxpt_freq_from_hilo(p->freq_hi, p->freq_lo);
- bool tune_ok = db_tune(rx_dboard, f, &tune_result);
- ok &= tune_ok;
- print_tune_result("Rx", tune_ok, f, &tune_result);
- }
-
- if (p->valid & CFGV_INTERP_DECIM){
- dsp_rx_regs->decim_rate = p->decim;
- }
-
- if (p->valid & CFGV_SCALE_IQ){
- dsp_rx_regs->scale_iq = p->scale_iq;
- }
-
- // FIXME build and send reply
-}
-
-
-void
start_rx_streaming_cmd(const u2_mac_addr_t *host, op_start_rx_streaming_t *p)
{
host_mac_addr = *host; // remember who we're sending to
Modified: usrp2/trunk/firmware/apps/tx_only_v2.c
===================================================================
--- usrp2/trunk/firmware/apps/tx_only_v2.c 2008-06-16 23:09:30 UTC (rev
8595)
+++ usrp2/trunk/firmware/apps/tx_only_v2.c 2008-06-17 03:35:46 UTC (rev
8596)
@@ -89,43 +89,6 @@
u2_mac_addr_t host_mac_addr;
-void
-config_tx_v2_cmd(op_config_tx_v2_t *p)
-{
- struct tune_result tune_result;
- memset(&tune_result, 0, sizeof(tune_result));
-
- bool ok = true;
-
- if (p->valid & CFGV_GAIN){
- ok &= tx_dboard->set_gain(tx_dboard, p->gain);
- }
-
- if (p->valid & CFGV_FREQ){
- u2_fxpt_freq_t f = u2_fxpt_freq_from_hilo(p->freq_hi, p->freq_lo);
- bool tune_ok = db_tune(tx_dboard, f, &tune_result);
- ok &= tune_ok;
- print_tune_result("Tx", tune_ok, f, &tune_result);
- }
-
- if (p->valid & CFGV_INTERP_DECIM){
- dsp_tx_regs->interp_rate = p->interp;
- }
-
- if (p->valid & CFGV_SCALE_IQ){
- dsp_tx_regs->scale_iq = p->scale_iq;
- }
-
- // FIXME build and send reply
-}
-
-void
-config_rx_v2_cmd(op_config_rx_v2_t *p)
-{
- // FIXME nop
-}
-
-
void
start_rx_streaming_cmd(const u2_mac_addr_t *host, op_start_rx_streaming_t *p)
{
Modified: usrp2/trunk/firmware/apps/txrx.c
===================================================================
--- usrp2/trunk/firmware/apps/txrx.c 2008-06-16 23:09:30 UTC (rev 8595)
+++ usrp2/trunk/firmware/apps/txrx.c 2008-06-17 03:35:46 UTC (rev 8596)
@@ -35,8 +35,6 @@
#include <stddef.h>
#include <stdlib.h>
#include <string.h>
-#include <db.h>
-#include <db_base.h>
#define FW_SETS_SEQNO 1 // define to 0 or 1 (FIXME must be 1 for now)
@@ -129,83 +127,6 @@
// ----------------------------------------------------------------
-
-void
-config_tx_v2_cmd(op_config_tx_v2_t *p)
-{
- struct tune_result tune_result;
- memset(&tune_result, 0, sizeof(tune_result));
-
- bool ok = true;
-
- if (p->valid & CFGV_GAIN){
- ok &= tx_dboard->set_gain(tx_dboard, p->gain);
- }
-
- if (p->valid & CFGV_FREQ){
- u2_fxpt_freq_t f = u2_fxpt_freq_from_hilo(p->freq_hi, p->freq_lo);
- bool tune_ok = db_tune(tx_dboard, f, &tune_result);
- ok &= tune_ok;
- print_tune_result("Tx", tune_ok, f, &tune_result);
- }
-
- if (p->valid & CFGV_INTERP_DECIM){
- dsp_tx_regs->interp_rate = p->interp;
- }
-
- if (p->valid & CFGV_SCALE_IQ){
- dsp_tx_regs->scale_iq = p->scale_iq;
- }
-
- // FIXME build and send reply
-}
-
-void
-config_rx_v2_cmd(op_config_rx_v2_t *p)
-{
- struct tune_result tune_result;
- memset(&tune_result, 0, sizeof(tune_result));
-
- bool ok = true;
-
- if (p->valid & CFGV_GAIN){
- ok &= rx_dboard->set_gain(rx_dboard, p->gain);
- }
-
- if (p->valid & CFGV_FREQ){
- u2_fxpt_freq_t f = u2_fxpt_freq_from_hilo(p->freq_hi, p->freq_lo);
- bool tune_ok = db_tune(rx_dboard, f, &tune_result);
- ok &= tune_ok;
- print_tune_result("Rx", tune_ok, f, &tune_result);
- }
-
- if (p->valid & CFGV_INTERP_DECIM){
- int decim = p->decim;
- int hb1 = 0;
- int hb2 = 0;
-
- if(!(decim & 1)) {
- hb2 = 1;
- decim = decim >> 1;
- }
-
- if(!(decim & 1)) {
- hb1 = 1;
- decim = decim >> 1;
- }
-
- dsp_rx_regs->decim_rate = (hb1<<9) | (hb2<<8) | decim;
- printf("Decim: %d, register %d\n",p->decim,(hb1<<9) | (hb2<<8) | decim);
- }
-
- if (p->valid & CFGV_SCALE_IQ){
- dsp_rx_regs->scale_iq = p->scale_iq;
- }
-
- // FIXME build and send reply
-}
-
-
static void
restart_streaming(void)
{
Modified: usrp2/trunk/firmware/include/usrp2_eth_packet.h
===================================================================
--- usrp2/trunk/firmware/include/usrp2_eth_packet.h 2008-06-16 23:09:30 UTC
(rev 8595)
+++ usrp2/trunk/firmware/include/usrp2_eth_packet.h 2008-06-17 03:35:46 UTC
(rev 8596)
@@ -328,8 +328,8 @@
uint32_t baseband_freq_hi;
uint32_t baseband_freq_lo;
// DUC frequency (fxpt_freq)
- uint32_t ddc_freq_hi;
- uint32_t ddc_freq_lo;
+ uint32_t duc_freq_hi;
+ uint32_t duc_freq_lo;
// residual frequency (fxpt_freq)
uint32_t residual_freq_hi;
uint32_t residual_freq_lo;
Modified: usrp2/trunk/firmware/lib/db.h
===================================================================
--- usrp2/trunk/firmware/lib/db.h 2008-06-16 23:09:30 UTC (rev 8595)
+++ usrp2/trunk/firmware/lib/db.h 2008-06-17 03:35:46 UTC (rev 8596)
@@ -84,5 +84,11 @@
db_set_duc_freq(u2_fxpt_freq_t dxc_freq, u2_fxpt_freq_t *actual_dxc_freq);
+/*!
+ * \brief Set gain
+ */
+bool
+db_set_gain(struct db_base *db, u2_fxpt_gain_t gain);
+
#endif /* INCLUDED_DB_H */
Modified: usrp2/trunk/firmware/lib/db_init.c
===================================================================
--- usrp2/trunk/firmware/lib/db_init.c 2008-06-16 23:09:30 UTC (rev 8595)
+++ usrp2/trunk/firmware/lib/db_init.c 2008-06-17 03:35:46 UTC (rev 8596)
@@ -333,3 +333,8 @@
return true;
}
+bool
+db_set_gain(struct db_base *db, u2_fxpt_gain_t gain)
+{
+ return db->set_gain(db, gain);
+}
Modified: usrp2/trunk/firmware/lib/db_tvrx.c
===================================================================
--- usrp2/trunk/firmware/lib/db_tvrx.c 2008-06-16 23:09:30 UTC (rev 8595)
+++ usrp2/trunk/firmware/lib/db_tvrx.c 2008-06-17 03:35:46 UTC (rev 8596)
@@ -81,8 +81,8 @@
.base.is_tx = false,
.base.output_enables = 0x0000,
.base.used_pins = 0x0000,
- //.base.freq_min = U2_DOUBLE_TO_FXPT_FREQ(xxx),
- //.base.freq_max = U2_DOUBLE_TO_FXPT_FREQ(xxx),
+ .base.freq_min = U2_DOUBLE_TO_FXPT_FREQ(50e6),
+ .base.freq_max = U2_DOUBLE_TO_FXPT_FREQ(860e6),
//.base.gain_min = U2_DOUBLE_TO_FXPT_GAIN(xxx),
//.base.gain_max = U2_DOUBLE_TO_FXPT_GAIN(xxx),
//.base.gain_step_size = U2_DOUBLE_TO_FXPT_GAIN(xxx),
@@ -108,8 +108,8 @@
.base.is_tx = false,
.base.output_enables = 0x0000,
.base.used_pins = 0x0000,
- //.base.freq_min = U2_DOUBLE_TO_FXPT_FREQ(xxx),
- //.base.freq_max = U2_DOUBLE_TO_FXPT_FREQ(xxx),
+ .base.freq_min = U2_DOUBLE_TO_FXPT_FREQ(50e6),
+ .base.freq_max = U2_DOUBLE_TO_FXPT_FREQ(860e6),
//.base.gain_min = U2_DOUBLE_TO_FXPT_GAIN(xxx),
//.base.gain_max = U2_DOUBLE_TO_FXPT_GAIN(xxx),
//.base.gain_step_size = U2_DOUBLE_TO_FXPT_GAIN(xxx),
@@ -135,8 +135,8 @@
.base.is_tx = false,
.base.output_enables = 0x0000,
.base.used_pins = 0x0000,
- //.base.freq_min = U2_DOUBLE_TO_FXPT_FREQ(xxx),
- //.base.freq_max = U2_DOUBLE_TO_FXPT_FREQ(xxx),
+ .base.freq_min = U2_DOUBLE_TO_FXPT_FREQ(50e6),
+ .base.freq_max = U2_DOUBLE_TO_FXPT_FREQ(860e6),
//.base.gain_min = U2_DOUBLE_TO_FXPT_GAIN(xxx),
//.base.gain_max = U2_DOUBLE_TO_FXPT_GAIN(xxx),
//.base.gain_step_size = U2_DOUBLE_TO_FXPT_GAIN(xxx),
@@ -169,6 +169,9 @@
tvrx_set_freq(struct db_base *dbb, u2_fxpt_freq_t freq, u2_fxpt_freq_t *dc)
{
*dc = 0;
+ if (freq < dbb->freq_min || freq > dbb->freq_max)
+ return false;
+
struct db_tvrx_dummy *db = (struct db_tvrx_dummy *) dbb;
u2_fxpt_freq_t target_lo_freq = freq + db->common.first_if;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Commit-gnuradio] r8596 - in usrp2/trunk/firmware: apps include lib,
eb <=