[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] r9814 - in gnuradio/branches/developers/eb/u2-wip2/usr
From: |
eb |
Subject: |
[Commit-gnuradio] r9814 - in gnuradio/branches/developers/eb/u2-wip2/usrp2: firmware/apps host/lib |
Date: |
Tue, 21 Oct 2008 18:29:10 -0600 (MDT) |
Author: eb
Date: 2008-10-21 18:29:10 -0600 (Tue, 21 Oct 2008)
New Revision: 9814
Modified:
gnuradio/branches/developers/eb/u2-wip2/usrp2/firmware/apps/app_common_v2.c
gnuradio/branches/developers/eb/u2-wip2/usrp2/host/lib/control.h
gnuradio/branches/developers/eb/u2-wip2/usrp2/host/lib/usrp2.cc
gnuradio/branches/developers/eb/u2-wip2/usrp2/host/lib/usrp2_impl.cc
gnuradio/branches/developers/eb/u2-wip2/usrp2/host/lib/usrp2_impl.h
Log:
work-in-progress on usrp2
Modified:
gnuradio/branches/developers/eb/u2-wip2/usrp2/firmware/apps/app_common_v2.c
===================================================================
--- gnuradio/branches/developers/eb/u2-wip2/usrp2/firmware/apps/app_common_v2.c
2008-10-21 23:19:37 UTC (rev 9813)
+++ gnuradio/branches/developers/eb/u2-wip2/usrp2/firmware/apps/app_common_v2.c
2008-10-22 00:29:10 UTC (rev 9814)
@@ -27,6 +27,7 @@
#include "nonstdio.h"
#include "print_rmon_regs.h"
#include "db.h"
+#include "db_base.h"
#include "clocks.h"
#include "u2_init.h"
#include <string.h>
@@ -279,7 +280,39 @@
return r->len;
}
+static void
+fill_db_info(u2_db_info_t *p, const struct db_base *db)
+{
+ p->dbid = db->dbid;
+ p->freq_min_hi = u2_fxpt_freq_hi(db->freq_min);
+ p->freq_min_lo = u2_fxpt_freq_lo(db->freq_min);
+ p->freq_max_hi = u2_fxpt_freq_hi(db->freq_max);
+ p->freq_max_lo = u2_fxpt_freq_lo(db->freq_max);
+ p->gain_min = db->gain_min;
+ p->gain_max = db->gain_max;
+ p->gain_step_size = db->gain_step_size;
+}
+
static size_t
+dboard_info_cmd(const op_generic_t *p,
+ void *reply_payload, size_t reply_payload_space)
+{
+ op_dboard_info_reply_t *r = (op_dboard_info_reply_t *) reply_payload;
+ if (reply_payload_space < sizeof(*r))
+ return 0; // no room
+
+ r->opcode = OP_DBOARD_INFO_REPLY;
+ r->len = sizeof(*r);
+ r->rid = p->rid;
+ r->ok = true;
+
+ fill_db_info(&r->tx_db_info, tx_dboard);
+ fill_db_info(&r->rx_db_info, rx_dboard);
+
+ return r->len;
+}
+
+static size_t
generic_reply(const op_generic_t *p,
void *reply_payload, size_t reply_payload_space,
bool ok)
@@ -374,6 +407,10 @@
subpktlen = read_time_cmd(gp, reply_payload, reply_payload_space);
break;
+ case OP_DBOARD_INFO:
+ subpktlen = dboard_info_cmd(gp, reply_payload, reply_payload_space);
+ break;
+
default:
printf("app_common_v2: unhandled opcode = %d\n", gp->opcode);
break;
Modified: gnuradio/branches/developers/eb/u2-wip2/usrp2/host/lib/control.h
===================================================================
--- gnuradio/branches/developers/eb/u2-wip2/usrp2/host/lib/control.h
2008-10-21 23:19:37 UTC (rev 9813)
+++ gnuradio/branches/developers/eb/u2-wip2/usrp2/host/lib/control.h
2008-10-22 00:29:10 UTC (rev 9814)
@@ -67,6 +67,13 @@
op_generic_t eop;
};
+ struct op_dboard_info_cmd {
+ u2_eth_packet_t h;
+ op_generic_t op;
+ op_generic_t eop;
+ };
+
+
/*!
* Control mechanism to allow API calls to block waiting for reply packets
*/
Modified: gnuradio/branches/developers/eb/u2-wip2/usrp2/host/lib/usrp2.cc
===================================================================
--- gnuradio/branches/developers/eb/u2-wip2/usrp2/host/lib/usrp2.cc
2008-10-21 23:19:37 UTC (rev 9813)
+++ gnuradio/branches/developers/eb/u2-wip2/usrp2/host/lib/usrp2.cc
2008-10-22 00:29:10 UTC (rev 9814)
@@ -168,12 +168,42 @@
return d_impl->set_rx_gain(gain);
}
+ double
+ usrp2::rx_gain_min()
+ {
+ return d_impl->rx_gain_min();
+ }
+
+ double
+ usrp2::rx_gain_max()
+ {
+ return d_impl->rx_gain_max();
+ }
+
+ double
+ usrp2::rx_gain_db_per_step()
+ {
+ return d_impl->rx_gain_db_per_step();
+ }
+
bool
usrp2::set_rx_center_freq(double frequency, tune_result *result)
{
return d_impl->set_rx_center_freq(frequency, result);
}
+ double
+ usrp2::rx_freq_min()
+ {
+ return d_impl->rx_freq_min();
+ }
+
+ double
+ usrp2::rx_freq_max()
+ {
+ return d_impl->rx_freq_max();
+ }
+
bool
usrp2::set_rx_decim(int decimation_factor)
{
@@ -224,12 +254,43 @@
return d_impl->set_tx_gain(gain);
}
+ double
+ usrp2::tx_gain_min()
+ {
+ return d_impl->tx_gain_min();
+ }
+
+ double
+ usrp2::tx_gain_max()
+ {
+ return d_impl->tx_gain_max();
+ }
+
+ double
+ usrp2::tx_gain_db_per_step()
+ {
+ return d_impl->tx_gain_db_per_step();
+ }
+
bool
usrp2::set_tx_center_freq(double frequency, tune_result *result)
{
return d_impl->set_tx_center_freq(frequency, result);
}
+ double
+ usrp2::tx_freq_min()
+ {
+ return d_impl->tx_freq_min();
+ }
+
+ double
+ usrp2::tx_freq_max()
+ {
+ return d_impl->tx_freq_max();
+ }
+
+
bool
usrp2::set_tx_interp(int interpolation_factor)
{
Modified: gnuradio/branches/developers/eb/u2-wip2/usrp2/host/lib/usrp2_impl.cc
===================================================================
--- gnuradio/branches/developers/eb/u2-wip2/usrp2/host/lib/usrp2_impl.cc
2008-10-21 23:19:37 UTC (rev 9813)
+++ gnuradio/branches/developers/eb/u2-wip2/usrp2/host/lib/usrp2_impl.cc
2008-10-22 00:29:10 UTC (rev 9814)
@@ -69,6 +69,8 @@
case OP_START_RX_STREAMING: return "OP_START_RX_STREAMING";
case OP_STOP_RX: return "OP_STOP_RX";
case OP_CONFIG_MIMO: return "OP_CONFIG_MIMO";
+ case OP_DBOARD_INFO: return "OP_DBOARD_INFO";
+ case OP_DBOARD_INFO_REPLY: return "OP_DBOARD_INFO_REPLY";
#if 0
case OP_WRITE_REG: return "OP_WRITE_REG";
case OP_WRITE_REG_MASKED: return "OP_WRITE_REG_MASKED";
@@ -125,7 +127,7 @@
usrp2::impl::impl(const std::string &ifc, props *p)
: d_eth_buf(new eth_buffer()), d_pf(0), d_bg_thread(0),
d_bg_running(false),
- d_rx_decim(0), d_rx_seqno(-1), d_tx_seqno(0), d_next_rid(0),
+ d_rx_seqno(-1), d_tx_seqno(0), d_next_rid(0),
d_num_rx_frames(0), d_num_rx_missing(0), d_num_rx_overruns(0),
d_num_rx_bytes(0),
d_num_enqueued(0), d_enqueued_mutex(),
d_bg_pending_cond(&d_enqueued_mutex),
d_channel_rings(NCHANS)
@@ -147,6 +149,36 @@
d_bg_thread = new usrp2_thread(this);
d_bg_thread->start();
+ if (!dboard_info()) // we're hosed
+ throw std::runtime_error("Unable to retrieve daughterboard info");
+
+ if (0){
+ int dbid;
+
+ tx_daughterboard_id(&dbid);
+ fprintf(stderr, "Tx dboard 0x%x\n", dbid);
+ fprintf(stderr, " freq_min = %g\n", tx_freq_min());
+ fprintf(stderr, " freq_max = %g\n", tx_freq_max());
+ fprintf(stderr, " gain_min = %g\n", tx_gain_min());
+ fprintf(stderr, " gain_max = %g\n", tx_gain_max());
+ fprintf(stderr, " gain_db_per_step = %g\n", tx_gain_db_per_step());
+
+ rx_daughterboard_id(&dbid);
+ fprintf(stderr, "Rx dboard 0x%x\n", dbid);
+ fprintf(stderr, " freq_min = %g\n", rx_freq_min());
+ fprintf(stderr, " freq_max = %g\n", rx_freq_max());
+ fprintf(stderr, " gain_min = %g\n", rx_gain_min());
+ fprintf(stderr, " gain_max = %g\n", rx_gain_max());
+ fprintf(stderr, " gain_db_per_step = %g\n", rx_gain_db_per_step());
+ }
+
+ // default gains to mid point
+ if (!set_tx_gain((tx_gain_min() + tx_gain_max()) / 2))
+ std::cerr << "usrp2::ctor set_tx_gain failed\n";
+
+ if (!set_rx_gain((rx_gain_min() + rx_gain_max()) / 2))
+ std::cerr << "usrp2::ctor set_rx_gain failed\n";
+
// set workable defaults for scaling
if (!set_rx_scale_iq(DEFAULT_RX_SCALE, DEFAULT_RX_SCALE))
std::cerr << "usrp2::ctor set_rx_scale_iq failed\n";
@@ -895,14 +927,14 @@
bool
usrp2::impl::tx_daughterboard_id(int *dbid)
{
- *dbid = -1; // FIXME implement
+ *dbid = d_tx_db_info.dbid;
return true;
}
bool
usrp2::impl::rx_daughterboard_id(int *dbid)
{
- *dbid = -1; // FIXME implement
+ *dbid = d_rx_db_info.dbid;
return true;
}
@@ -933,5 +965,48 @@
return success;
}
+ static void
+ fill_dboard_info(db_info *dst, const u2_db_info_t *src)
+ {
+ dst->dbid = ntohl(src->dbid);
+ dst->freq_min =
+ u2_fxpt_freq_to_double(u2_fxpt_freq_from_hilo(ntohl(src->freq_min_hi),
+ ntohl(src->freq_min_lo)));
+ dst->freq_max =
+ u2_fxpt_freq_to_double(u2_fxpt_freq_from_hilo(ntohl(src->freq_max_hi),
+ ntohl(src->freq_max_lo)));
+
+ dst->gain_min = u2_fxpt_gain_to_double(ntohs(src->gain_min));
+ dst->gain_max = u2_fxpt_gain_to_double(ntohs(src->gain_max));
+ dst->gain_step_size = u2_fxpt_gain_to_double(ntohs(src->gain_step_size));
+ }
+
+ bool
+ usrp2::impl::dboard_info()
+ {
+ op_dboard_info_cmd cmd;
+ op_dboard_info_reply_t reply;
+
+ memset(&cmd, 0, sizeof(cmd));
+ init_etf_hdrs(&cmd.h, d_addr, 0, CONTROL_CHAN, -1);
+ cmd.op.opcode = OP_DBOARD_INFO;
+ cmd.op.len = sizeof(cmd.op);
+ cmd.op.rid = d_next_rid++;
+ cmd.eop.opcode = OP_EOP;
+ cmd.eop.len = sizeof(cmd.eop);
+
+ pending_reply p(cmd.op.rid, &reply, sizeof(reply));
+ if (!transmit_cmd(&cmd, sizeof(cmd), &p, DEF_CMD_TIMEOUT))
+ return false;
+
+ bool success = (ntohx(reply.ok) == 1);
+ if (success){
+ fill_dboard_info(&d_tx_db_info, &reply.tx_db_info);
+ fill_dboard_info(&d_rx_db_info, &reply.rx_db_info);
+ }
+ return success;
+ }
+
+
} // namespace usrp2
Modified: gnuradio/branches/developers/eb/u2-wip2/usrp2/host/lib/usrp2_impl.h
===================================================================
--- gnuradio/branches/developers/eb/u2-wip2/usrp2/host/lib/usrp2_impl.h
2008-10-21 23:19:37 UTC (rev 9813)
+++ gnuradio/branches/developers/eb/u2-wip2/usrp2/host/lib/usrp2_impl.h
2008-10-22 00:29:10 UTC (rev 9814)
@@ -36,6 +36,19 @@
class pending_reply;
class ring;
+ //! High-level d'board info
+ struct db_info {
+ int dbid;
+ double freq_min; // Hz
+ double freq_max; // Hz
+ double gain_min; // dB
+ double gain_max; // dB
+ double gain_step_size; // dB
+
+ db_info() : dbid(-1), freq_min(0), freq_max(0),
+ gain_min(0), gain_max(0), gain_step_size(0) {}
+ };
+
class usrp2::impl : private data_handler
{
static const size_t NRIDS = 256;
@@ -47,7 +60,6 @@
usrp2_thread *d_bg_thread;
volatile bool d_bg_running; // TODO: multistate if needed
- int d_rx_decim;
int d_rx_seqno;
int d_tx_seqno;
int d_next_rid;
@@ -65,6 +77,10 @@
std::vector<ring_sptr> d_channel_rings; // indexed by 5-bit channel
number
+ db_info d_tx_db_info;
+ db_info d_rx_db_info;
+
+
void inc_enqueued() {
omni_mutex_lock l(d_enqueued_mutex);
d_num_enqueued++;
@@ -87,6 +103,7 @@
virtual data_handler::result operator()(const void *base, size_t len);
data_handler::result handle_control_packet(const void *base, size_t len);
data_handler::result handle_data_packet(const void *base, size_t len);
+ bool dboard_info();
public:
impl(const std::string &ifc, props *p);
@@ -99,7 +116,12 @@
// Rx
bool set_rx_gain(double gain);
+ double rx_gain_min() { return d_rx_db_info.gain_min; }
+ double rx_gain_max() { return d_rx_db_info.gain_max; }
+ double rx_gain_db_per_step() { return d_rx_db_info.gain_step_size; }
bool set_rx_center_freq(double frequency, tune_result *result);
+ double rx_freq_min() { return d_rx_db_info.freq_min; }
+ double rx_freq_max() { return d_rx_db_info.freq_max; }
bool set_rx_decim(int decimation_factor);
bool set_rx_scale_iq(int scale_i, int scale_q);
bool start_rx_streaming(unsigned int channel, unsigned int
items_per_frame);
@@ -111,7 +133,12 @@
// Tx
bool set_tx_gain(double gain);
+ double tx_gain_min() { return d_tx_db_info.gain_min; }
+ double tx_gain_max() { return d_tx_db_info.gain_max; }
+ double tx_gain_db_per_step() { return d_tx_db_info.gain_step_size; }
bool set_tx_center_freq(double frequency, tune_result *result);
+ double tx_freq_min() { return d_tx_db_info.freq_min; }
+ double tx_freq_max() { return d_tx_db_info.freq_max; }
bool set_tx_interp(int interpolation_factor);
bool set_tx_scale_iq(int scale_i, int scale_q);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Commit-gnuradio] r9814 - in gnuradio/branches/developers/eb/u2-wip2/usrp2: firmware/apps host/lib,
eb <=