commit-gnuradio
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Commit-gnuradio] r9223 - gnuradio/branches/developers/trondeau/dbs/usrp


From: trondeau
Subject: [Commit-gnuradio] r9223 - gnuradio/branches/developers/trondeau/dbs/usrp/host/lib/legacy
Date: Sun, 10 Aug 2008 13:43:49 -0600 (MDT)

Author: trondeau
Date: 2008-08-10 13:43:47 -0600 (Sun, 10 Aug 2008)
New Revision: 9223

Added:
   gnuradio/branches/developers/trondeau/dbs/usrp/host/lib/legacy/db_base.cc
   gnuradio/branches/developers/trondeau/dbs/usrp/host/lib/legacy/db_base.h
   gnuradio/branches/developers/trondeau/dbs/usrp/host/lib/legacy/db_basic.cc
   gnuradio/branches/developers/trondeau/dbs/usrp/host/lib/legacy/db_basic.h
   gnuradio/branches/developers/trondeau/dbs/usrp/host/lib/legacy/db_boards.cc
   gnuradio/branches/developers/trondeau/dbs/usrp/host/lib/legacy/db_boards.h
Log:
wip: adding base and basic daughterboard classes and instantiator functions for 
building daughterboard objects.

Added: gnuradio/branches/developers/trondeau/dbs/usrp/host/lib/legacy/db_base.cc
===================================================================
--- gnuradio/branches/developers/trondeau/dbs/usrp/host/lib/legacy/db_base.cc   
                        (rev 0)
+++ gnuradio/branches/developers/trondeau/dbs/usrp/host/lib/legacy/db_base.cc   
2008-08-10 19:43:47 UTC (rev 9223)
@@ -0,0 +1,343 @@
+//
+// Copyright 2008 Free Software Foundation, Inc.
+// 
+// This file is part of GNU Radio
+// 
+// GNU Radio is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either asversion 3, or (at your option)
+// any later version.
+// 
+// GNU Radio is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+// 
+// You should have received a copy of the GNU General Public License
+// along with GNU Radio; see the file COPYING.  If not, write to
+// the Free Software Foundation, Inc., 51 Franklin Street,
+// Boston, MA 02110-1301, USA.
+//
+
+#include <db_base.h>
+
+tune_result::tune_result(float baseband, float dxc, float residual, bool inv)
+  : ok(false), baseband_freq(baseband), dxc_freq(dxc), 
+    residual_freq(residual), inverted(inv)
+{
+}
+
+tune_result::~tune_result()
+{ 
+}
+
+
+/******************************************************************************/
+
+
+db_base::db_base(usrp_basic *usrp, int which, bool tx)
+{
+  d_which = which;
+  d_tx = tx;
+  d_usrp = usrp;
+
+  printf("Creating db_base  usrp_basic usrp: %x\n", d_usrp);
+}
+
+int 
+db_base::dbid()
+{
+  return d_usrp->daughterboard_id(d_which);
+}
+
+std::string 
+db_base::name()
+{
+  return usrp_dbid_to_string(dbid());
+}
+
+std::string 
+db_base::side_and_name()
+{
+  if(d_which == 0)
+    return "A: " + name();
+  else
+    return "B: " + name();
+}
+
+// Function to bypass ADC buffers. Any board which is DC-coupled should bypass 
the buffers
+void 
+db_base::bypass_adc_buffers(bool bypass)
+{
+  if(d_tx) {
+    throw "TX Board has no adc buffers";
+  }
+  if(d_which==0) {
+    
+    d_usrp->set_adc_buffer_bypass(0, bypass);
+    d_usrp->set_adc_buffer_bypass(1, bypass);
+  }
+  else {
+    d_usrp->set_adc_buffer_bypass(2, bypass);
+    d_usrp->set_adc_buffer_bypass(3, bypass);
+  }
+}
+
+bool 
+db_base::set_atr_mask(int v)
+{
+  // Set Auto T/R mask.
+  return d_usrp->_write_fpga_reg(FR_ATR_MASK_0 + 3 * d_slot, v);
+}
+
+bool 
+db_base::set_atr_txval(int v)
+{
+  // Set Auto T/R register value to be used when transmitting.
+  return d_usrp->_write_fpga_reg(FR_ATR_TXVAL_0 + 3 * d_slot, v);
+}
+  
+bool 
+db_base::set_atr_rxval(int v)
+{
+  // Set Auto T/R register value to be used when receiving.
+  return d_usrp->_write_fpga_reg(FR_ATR_RXVAL_0 + 3 * d_slot, v);
+}
+  
+bool 
+db_base::set_atr_tx_delay(int v)
+{
+  // Set Auto T/R delay (in clock ticks) from when Tx fifo gets data to 
+  // when T/R switches.
+  return d_usrp->_write_fpga_reg(FR_ATR_TX_DELAY, v);
+}
+
+bool 
+db_base::set_atr_rx_delay(int v)
+{
+  // Set Auto T/R delay (in clock ticks) from when Tx fifo goes empty to 
+  // when T/R switches.
+  return d_usrp->_write_fpga_reg(FR_ATR_RX_DELAY, v);
+}
+
+std::vector<float> 
+db_base::freq_range()
+{
+  // Return range of frequencies in Hz that can be tuned by this d'board.
+  
+  // @returns (min_freq, max_freq, step_size)
+  // @rtype tuple
+  throw 0;
+}
+
+std::vector<float> 
+db_base::set_freq(float target_freq)
+{
+  // Set the frequency.
+  //
+  // @param freq:  target RF frequency in Hz
+  // @type freq:   float
+  // 
+  // @returns (ok, actual_baseband_freq) where:
+  //   ok is True or False and indicates success or failure,
+  //   actual_baseband_freq is the RF frequency that corresponds to DC in the 
IF.
+  printf("db_base::set_freq\n");
+  throw 0;
+}
+
+std::vector<float> db_base::gain_range()
+{
+  // Return range of gain that can be set by this d'board.
+  // 
+  // @returns (min_gain, max_gain, step_size)
+  //   Where gains are expressed in decibels (your mileage may vary)
+  printf("db_base::set_gain_range\n");
+  throw 0;
+}
+
+bool 
+db_base::set_gain(float gain)
+{
+  // Set the gain.
+  // 
+  // @param gain:  gain in decibels
+  // @returns True/False
+  printf("db_base::set_gain\n");
+  throw 0;
+}
+
+bool 
+db_base::is_quadrature()
+{
+  // Return True if this daughterboard does quadrature up or down conversion.
+  // That is, return True if this board requires both I & Q analog channels.
+  // 
+  // This bit of info is useful when setting up the USRP Rx mux register.
+  throw 0;
+}
+
+bool 
+db_base::i_and_q_swapped()
+{
+  // Return True if this is a quadrature device and (for RX) ADC 0 is Q
+  // or (for TX) DAC 0 is Q
+  return false;
+}
+
+bool 
+db_base::spectrum_inverted()
+{
+  // Return True if the dboard gives an inverted spectrum
+  
+  return false;
+}
+
+void 
+db_base::set_enable(bool on)
+{
+  // For tx daughterboards, this controls the transmitter enable.
+}
+
+void 
+db_base::set_auto_tr(bool on)
+{
+  // Enable automatic Transmit/Receive switching (ATR).
+  // 
+  // Should be overridden in subclasses that care.  This will typically
+  // set the atr_mask, txval and rxval.
+}
+
+void 
+db_base::set_lo_offset(float offset)
+{
+  // Set how much LO is offset from requested frequency
+  // 
+  // Should be overriden by daughterboards that care.
+}
+
+float 
+db_base::lo_offset()
+{
+  // Get how much LO is offset from requested frequency
+  // 
+  // Should be overriden by daughterboards that care.
+  return 0.0;
+}
+
+void 
+db_base::select_rx_antenna(int which_antenna)
+{
+  // Specify which antenna port to use for reception.
+  // Should be overriden by daughterboards that care.
+}
+
+
+// Reference Clock section
+//
+// Control whether a reference clock is sent to the daughterboards,
+// and what frequency
+//
+// Bit 7  -- 1 turns on refclk, 0 allows IO use
+// Bits 6:0 Divider value
+//
+    
+float 
+db_base::_refclk_freq() 
+{
+  return d_usrp->fpga_master_clock_freq() / _refclk_divisor();
+}
+
+void 
+db_base::_enable_refclk(bool enable)
+{
+  int CLOCK_OUT = 1;   // Clock is on lowest bit
+  int REFCLK_ENABLE = 0x80;
+  int REFCLK_DIVISOR_MASK = 0x7f;
+  if(enable) {
+    d_usrp->_write_oe(d_which, CLOCK_OUT, CLOCK_OUT); // output enable
+    d_usrp->_write_fpga_reg(d_refclk_reg,
+                           ((_refclk_divisor() & REFCLK_DIVISOR_MASK)
+                            | REFCLK_ENABLE));
+  }
+  else {
+    d_usrp->_write_fpga_reg(d_refclk_reg, 0);
+  }
+}
+
+int 
+db_base::_refclk_divisor()
+{
+  // Return value to stick in REFCLK_DIVISOR register
+  throw 0;
+}
+
+tune_result 
+db_base::tune(int chan, float target_freq)
+{
+  /*
+    Set the center frequency we're interested in.
+
+    @param u: instance of usrp.source_* or usrp.sink_*
+    @param chan: DDC/DUC channel
+    @type  chan: int
+    @param subdev: daughterboard subdevice
+    @param target_freq: frequency in Hz
+    @returns False if failure else tune_result
+    
+    Tuning is a two step process.  First we ask the front-end to
+    tune as close to the desired frequency as it can.  Then we use
+    the result of that operation and our target_frequency to
+    determine the value for the digital down converter.
+  */
+
+  // Set the daughterboard frequency
+  bool ok=true;
+  float baseband_freq;
+  std::vector<float> freq = set_freq(target_freq);
+  ok = (bool)freq[0];
+  baseband_freq = freq[1];
+
+  bool inverted;
+  float dxc_freq = calc_dxc_freq(target_freq, baseband_freq, 
d_usrp->converter_rate(), inverted);
+
+  // If the spectrum is inverted, and the daughterboard doesn't do
+  // quadrature downconversion, we can fix the inversion by flipping the
+  // sign of the dxc_freq...  (This only happens using the basic_rx board)
+  
+  if(spectrum_inverted()) {
+    inverted = !(inverted);
+  }
+  
+  if(inverted && (!is_quadrature())) {
+    dxc_freq = -dxc_freq;
+    inverted = !(inverted);
+  }
+  
+  if (!d_tx) {
+    ok = ok && ((usrp_standard_rx*)d_usrp)->set_rx_freq(chan, dxc_freq);
+  }
+  else {
+    dxc_freq = -dxc_freq;
+    ok = ok && ((usrp_standard_tx*)d_usrp)->set_tx_freq(chan, dxc_freq);
+  }
+  
+  if(!ok) {
+    return tune_result(0, 0, 0, 0);
+  }
+  
+  // residual_freq is the offset left over because of dxc tuning step size
+  float residual_freq;
+  if(!d_tx) {
+    residual_freq = dxc_freq - ((usrp_standard_rx*)d_usrp)->rx_freq(chan);
+  }
+  else {
+    // FIXME 50-50 chance this has the wrong sign...
+    residual_freq = dxc_freq - ((usrp_standard_tx*)d_usrp)->tx_freq(chan);
+  }
+
+  tune_result res = tune_result(baseband_freq, dxc_freq, residual_freq, 
inverted);
+  res.ok = true;
+     
+  return res;
+}
+

Added: gnuradio/branches/developers/trondeau/dbs/usrp/host/lib/legacy/db_base.h
===================================================================
--- gnuradio/branches/developers/trondeau/dbs/usrp/host/lib/legacy/db_base.h    
                        (rev 0)
+++ gnuradio/branches/developers/trondeau/dbs/usrp/host/lib/legacy/db_base.h    
2008-08-10 19:43:47 UTC (rev 9223)
@@ -0,0 +1,105 @@
+/* -*- c++ -*- */
+//
+// Copyright 2008 Free Software Foundation, Inc.
+// 
+// This file is part of GNU Radio
+// 
+// GNU Radio is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either asversion 3, or (at your option)
+// any later version.
+// 
+// GNU Radio is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+// 
+// You should have received a copy of the GNU General Public License
+// along with GNU Radio; see the file COPYING.  If not, write to
+// the Free Software Foundation, Inc., 51 Franklin Street,
+// Boston, MA 02110-1301, USA.
+//
+
+#ifndef DB_BASE_H
+#define DB_BASE_H
+
+#include <fpga_regs_standard.h>
+#include <fpga_regs_common.h>
+#include <vector>
+#include <usrp_basic.h>
+#include <usrp_standard.h>
+#include <usrp_prims.h>
+#include <usrp_spi_defs.h>
+
+class usrp_base;
+
+#define NUM_DAUGHTERBOARDS 1
+
+
+class tune_result
+{
+public:  
+  tune_result(float baseband=0, float dxc=0, 
+             float residual=0, bool inv=0);
+  ~tune_result();
+
+  bool  ok;
+  float baseband_freq;
+  float dxc_freq;
+  float residual_freq;
+  bool  inverted;
+};
+
+
+/******************************************************************************/
+
+class db_base
+{
+ public:
+  db_base(usrp_basic *usrp, int which, bool tx=true);
+  ~db_base() {}
+
+  int dbid();
+  std::string name();
+  std::string side_and_name();
+
+  void bypass_adc_buffers(bool bypass);
+  bool set_atr_mask(int v);
+  bool set_atr_txval(int v);
+  bool set_atr_rxval(int v);
+  bool set_atr_tx_delay(int v);
+  bool set_atr_rx_delay(int v);
+
+  ////////////////////////////////////////////////////////
+  // derived classes should override the following methods
+
+  virtual std::vector<float> freq_range();
+  virtual std::vector<float> set_freq(float target_freq);
+  virtual std::vector<float> gain_range();
+  virtual bool set_gain(float gain);
+  virtual bool is_quadrature();
+  virtual bool i_and_q_swapped();
+  virtual bool spectrum_inverted();
+  virtual void set_enable(bool on);
+  virtual void set_auto_tr(bool on);
+  virtual void set_lo_offset(float offset);
+  virtual float lo_offset();
+  virtual void select_rx_antenna(int which_antenna);
+
+  tune_result tune(int chan, float target_freq);
+
+ protected:
+  void _enable_refclk(bool enable);
+  float _refclk_freq();
+  virtual int _refclk_divisor();
+
+  int d_which;
+  usrp_basic *d_usrp;
+  int d_refclk_reg;
+  bool d_tx;
+  int d_slot;
+};
+
+#endif 
+
+

Added: 
gnuradio/branches/developers/trondeau/dbs/usrp/host/lib/legacy/db_basic.cc
===================================================================
--- gnuradio/branches/developers/trondeau/dbs/usrp/host/lib/legacy/db_basic.cc  
                        (rev 0)
+++ gnuradio/branches/developers/trondeau/dbs/usrp/host/lib/legacy/db_basic.cc  
2008-08-10 19:43:47 UTC (rev 9223)
@@ -0,0 +1,273 @@
+//
+// Copyright 2008 Free Software Foundation, Inc.
+// 
+// This file is part of GNU Radio
+// 
+// GNU Radio is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either asversion 3, or (at your option)
+// any later version.
+// 
+// GNU Radio is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+// 
+// You should have received a copy of the GNU General Public License
+// along with GNU Radio; see the file COPYING.  If not, write to
+// the Free Software Foundation, Inc., 51 Franklin Street,
+// Boston, MA 02110-1301, USA.
+
+#include <db_basic.h>
+#include <usrp1_base.h>
+
+
+/**************************************************************************************************/
+
+
+db_basic_tx::db_basic_tx(usrp1_base *usrp, int which)
+  : db_base(usrp, which, true)
+{
+  // Handler for Basic Tx daughterboards.
+  // 
+  // @param usrp: instance of usrp.source_c
+  // @param which: which side: 0 or 1 corresponding to TX_A or TX_B 
respectively
+
+  if(0) {
+    // Doing this would give us a different default than the historical 
values...
+    std::vector<float> g = gain_range();                  // initialize gain
+    set_gain(float(g[0]+g[1]) / 2);
+  }
+}
+
+std::vector<float> 
+db_basic_tx::freq_range() 
+{
+  // Return range of frequencies in Hz that can be tuned by this d'board.
+  // 
+  // @returns (min_freq, max_freq, step_size)
+  // @rtype tuple
+  // 
+  // We say we can do pretty much anything...
+  
+  std::vector<float> f(3,0);
+  f[0] = -90e9;
+  f[1] = 90e9;
+  f[2] = 1e-6;
+  return f;
+}
+
+std::vector<float>
+db_basic_tx::set_freq(float target_freq)
+{
+  // Set the frequency.
+  // 
+  // @param freq:  target RF frequency in Hz
+  // @type freq:   float
+  // 
+  // @returns (ok, actual_baseband_freq) where:
+  //   ok is True or False and indicates success or failure,
+  //   actual_baseband_freq is the RF frequency that corresponds to DC in the 
IF.
+  
+  // FIXME: Should I return a struct{bool, float} instead?
+  std::vector<float> args(2);
+  args[0] = 1;   // 1: true
+  args[1] = 0.0; // baseband freq
+  return args;
+}
+
+std::vector<float>
+db_basic_tx::gain_range()
+{
+  // Return range of gain that can be set by this d'board.
+  // 
+  // @returns (min_gain, max_gain, step_size)
+  //    Where gains are expressed in decibels (your mileage may vary)
+  
+  std::vector<float> g(3,0);
+  g[0] = d_usrp->pga_min();
+  g[1] = d_usrp->pga_max();
+  g[2] = d_usrp->pga_db_per_step();
+  return g;
+}
+
+bool 
+db_basic_tx::set_gain(float gain)
+{
+  // Set the gain.
+  // 
+  // @param gain:  gain in decibels
+  // @returns True/False
+
+  bool ok = d_usrp->set_pga(d_which * 2 + 0, gain);
+  ok = ok && d_usrp->set_pga(d_which * 2 + 1, gain);
+  return ok;
+}
+
+bool 
+db_basic_tx::is_quadrature()
+{
+  // Return True if this board requires both I & Q analog channels.
+  
+  return true;
+}
+
+
+/******************************************************************************/
+
+
+db_basic_rx::db_basic_rx(usrp1_base *usrp, int which, int subdev)
+  : db_base(usrp, which, false)
+{
+  // Handler for Basic Rx daughterboards.
+  // 
+  // @param usrp: instance of usrp.source_c
+  // @param which: which side: 0 or 1 corresponding to TX_A or TX_B 
respectively
+  // @param subdev: which analog i/o channel: 0 or 1
+  // @type subdev: int
+  
+  d_subdev = subdev;
+    
+  bypass_adc_buffers(true);
+
+  if(0) {       // Doing this would give us a different default than the 
historical values...
+    std::vector<float> g = gain_range();                  // initialize gain
+    set_gain(float(g[0]+g[1]) / 2.0);
+  }
+}
+
+std::vector<float> 
+db_basic_rx::freq_range() 
+{
+  // Return range of frequencies in Hz that can be tuned by this d'board.
+  // 
+  // @returns (min_freq, max_freq, step_size)
+  // @rtype tuple
+  // 
+  // We say we can do pretty much anything...
+  
+  std::vector<float> f(3,0);
+  f[0] = -90e9;
+  f[1] = 90e9;
+  f[2] = 1e-6;
+  return f;
+}
+
+std::vector<float>
+db_basic_rx::set_freq(float target_freq)
+{
+  // Set the frequency.
+  // 
+  // @param freq:  target RF frequency in Hz
+  // @type freq:   float
+  // 
+  // @returns (ok, actual_baseband_freq) where:
+  //   ok is True or False and indicates success or failure,
+  //   actual_baseband_freq is the RF frequency that corresponds to DC in the 
IF.
+  
+  // FIXME: Should I return a struct{bool, float} instead?
+  std::vector<float> args(2);
+  args[0] = 1;   // 1: true
+  args[1] = 0.0; // baseband freq
+  return args;
+}
+
+std::vector<float>
+db_basic_rx::gain_range()
+{
+  // Return range of gain that can be set by this d'board.
+  // 
+  // @returns (min_gain, max_gain, step_size)
+  //    Where gains are expressed in decibels (your mileage may vary)
+  
+  std::vector<float> g(3,0);
+  g[0] = d_usrp->pga_min();
+  g[1] = d_usrp->pga_max();
+  g[2] = d_usrp->pga_db_per_step();
+  return g;
+}
+
+bool 
+db_basic_rx::set_gain(float gain)
+{
+  // Set the gain.
+  // 
+  // @param gain:  gain in decibels
+  // @returns True/False
+  
+  return d_usrp->set_pga(d_which * 2 + d_subdev, gain);
+}
+
+bool 
+db_basic_rx::is_quadrature()
+{
+  // Return True if this board requires both I & Q analog channels.
+
+  // This bit of info is useful when setting up the USRP Rx mux register.
+  
+  return false;
+}
+
+
+
+/******************************************************************************/
+
+
+db_lf_tx::db_lf_tx(usrp1_base *usrp, int which)
+  : db_basic_tx(usrp, which)
+{
+  // Handler for Low Freq Tx daughterboards.
+  //
+  // @param usrp: instance of usrp.source_c
+  // @param which: which side: 0 or 1 corresponding to RX_A or RX_B 
respectively
+}
+
+std::vector<float> 
+db_lf_tx::freq_range() 
+{
+  // Return range of frequencies in Hz that can be tuned by this d'board.
+  // 
+  // @returns (min_freq, max_freq, step_size)
+  // @rtype tuple
+  // 
+  // We cover the first nyquist zone only
+  
+  std::vector<float> f(3,0);
+  f[0] = -32e6;
+  f[1] = 32e6;
+  f[2] = 1e-6;
+  return f;
+}
+
+
+/******************************************************************************/
+
+
+db_lf_rx::db_lf_rx(usrp1_base *usrp, int which, int subdev)
+  : db_basic_rx(usrp, which, subdev)
+{
+  // Handler for Low Freq Rx daughterboards.
+  //
+  // @param usrp: instance of usrp.source_c
+  // @param which: which side: 0 or 1 corresponding to RX_A or RX_B 
respectively
+  // @param subdev: which analog i/o channel: 0 or 1
+  // @type subdev: int
+}
+
+std::vector<float>
+db_lf_rx::freq_range() 
+{
+  // Return range of frequencies in Hz that can be tuned by this d'board.
+  // 
+  // @returns (min_freq, max_freq, step_size)
+  // @rtype tuple
+  // 
+  // We cover the first nyquist zone only
+  
+  std::vector<float> f(3,0);
+  f[0] = 0.0;
+  f[1] = 32e6;
+  f[2] = 1e-6;
+  return f;
+}
+

Added: gnuradio/branches/developers/trondeau/dbs/usrp/host/lib/legacy/db_basic.h
===================================================================
--- gnuradio/branches/developers/trondeau/dbs/usrp/host/lib/legacy/db_basic.h   
                        (rev 0)
+++ gnuradio/branches/developers/trondeau/dbs/usrp/host/lib/legacy/db_basic.h   
2008-08-10 19:43:47 UTC (rev 9223)
@@ -0,0 +1,90 @@
+/* -*- c++ -*- */
+//
+// Copyright 2008 Free Software Foundation, Inc.
+// 
+// This file is part of GNU Radio
+// 
+// GNU Radio is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either asversion 3, or (at your option)
+// any later version.
+// 
+// GNU Radio is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+// 
+// You should have received a copy of the GNU General Public License
+// along with GNU Radio; see the file COPYING.  If not, write to
+// the Free Software Foundation, Inc., 51 Franklin Street,
+// Boston, MA 02110-1301, USA.
+
+#ifndef DB_BASIC_H
+#define DB_BASIC_H
+
+#include <db_base.h>
+#include <gr_sync_block.h>
+
+class usrp1_base;
+
+
+/******************************************************************************/
+
+
+class db_basic_tx : public db_base
+{
+public:
+  db_basic_tx(usrp1_base *usrp, int which);
+
+  std::vector<float> freq_range();
+  std::vector<float> set_freq(float target_freq);
+  std::vector<float> gain_range();
+  bool               set_gain(float gain);
+  bool               is_quadrature();
+};
+
+
+/******************************************************************************/
+
+
+class db_basic_rx : public db_base
+{
+ public:
+  db_basic_rx(usrp1_base *usrp, int which, int subdev);
+  
+  std::vector<float> freq_range();
+  std::vector<float> set_freq(float target_freq);
+  std::vector<float> gain_range();
+  bool               set_gain(float gain);
+  bool               is_quadrature();
+
+private:
+  int d_subdev;
+};
+
+
+/******************************************************************************/
+
+
+class db_lf_rx : public db_basic_rx
+{
+ public:
+  db_lf_rx(usrp1_base *usrp, int which, int subdev);
+  
+  std::vector<float> freq_range();
+};
+
+
+/******************************************************************************/
+
+
+class db_lf_tx : public db_basic_tx
+{ 
+ public:
+  db_lf_tx(usrp1_base *usrp, int which);
+  
+  std::vector<float> freq_range();
+};
+
+
+#endif

Added: 
gnuradio/branches/developers/trondeau/dbs/usrp/host/lib/legacy/db_boards.cc
===================================================================
--- gnuradio/branches/developers/trondeau/dbs/usrp/host/lib/legacy/db_boards.cc 
                        (rev 0)
+++ gnuradio/branches/developers/trondeau/dbs/usrp/host/lib/legacy/db_boards.cc 
2008-08-10 19:43:47 UTC (rev 9223)
@@ -0,0 +1,117 @@
+/* -*- c++ -*- */
+//
+// Copyright 2008 Free Software Foundation, Inc.
+// 
+// This file is part of GNU Radio
+// 
+// GNU Radio is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either asversion 3, or (at your option)
+// any later version.
+// 
+// GNU Radio is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+// 
+// You should have received a copy of the GNU General Public License
+// along with GNU Radio; see the file COPYING.  If not, write to
+// the Free Software Foundation, Inc., 51 Franklin Street,
+// Boston, MA 02110-1301, USA.
+//
+
+#include <db_boards.h>
+
+db_base * instantiate_dbs(int dbid, usrp_basic * usrp, int which)
+{
+  db_base *db;
+
+  printf("dbid: %d\n", dbid);
+
+  switch(dbid) {
+
+    /*
+  case(USRP_DBID_BASIC_TX):
+    db = new db_basic_tx(usrp, which);
+    break;
+    */
+
+  case(USRP_DBID_TV_RX):
+    db = new db_tv_rx(usrp, which, 43.75e6, 5.75e6);
+    break;
+
+  case(USRP_DBID_TV_RX_REV_2):
+    db = new db_tv_rx(usrp, which, 44e6, 20e6);
+    break;
+
+  case(USRP_DBID_TV_RX_REV_3):
+    db = new db_tv_rx(usrp, which, 44e6, 20e6);
+    break;
+
+  case(USRP_DBID_FLEX_2400_TX): 
+    db = new db_flexrf_2400_tx(usrp, which); 
+    break;
+  case(USRP_DBID_FLEX_2400_RX): db = new db_flexrf_2400_rx(usrp, which); break;
+    //case(USRP_DBID_FLEX_1200_TX): db = new db_flexrf_1200_tx(usrp, which); 
break;
+    //case(USRP_DBID_FLEX_1200_RX): db = new db_flexrf_1200_rx(usrp, which); 
break;
+    //case(USRP_DBID_FLEX_1800_TX): db = new db_flexrf_1800_tx(usrp, which); 
break;
+    //case(USRP_DBID_FLEX_1800_RX): db = new db_flexrf_1800_rx(usrp, which); 
break;
+    //case(USRP_DBID_FLEX_900_TX):  db = new db_flexrf_900_tx(usrp, which); 
break;
+    //case(USRP_DBID_FLEX_900_RX):  db = new db_flexrf_900_rx(usrp, which); 
break;
+    //case(USRP_DBID_FLEX_400_TX):  db = new db_flexrf_400_tx(usrp, which); 
break;
+    //case(USRP_DBID_FLEX_400_RX):  db = new db_flexrf_400_rx(usrp, which); 
break;
+  
+  case(USRP_DBID_FLEX_2400_TX_MIMO_A): db = new db_flexrf_2400_tx_mimo_a(usrp, 
which); break;
+  case(USRP_DBID_FLEX_2400_RX_MIMO_A): db = new db_flexrf_2400_rx_mimo_a(usrp, 
which); break;
+    //case(USRP_DBID_FLEX_1800_TX_MIMO_A): db = new 
db_flexrf_1800_tx_mimo_a(usrp, which); break;
+    //case(USRP_DBID_FLEX_1800_RX_MIMO_A): db = new 
db_flexrf_1800_rx_mimo_a(usrp, which); break;
+    //case(USRP_DBID_FLEX_1200_TX_MIMO_A): db = new 
db_flexrf_1200_tx_mimo_a(usrp, which); break;
+    //case(USRP_DBID_FLEX_1200_RX_MIMO_A): db = new 
db_flexrf_1200_rx_mimo_a(usrp, which); break;
+    //case(USRP_DBID_FLEX_900_TX_MIMO_A):  db = new 
db_flexrf_900_tx_mimo_a(usrp, which); break;
+    //case(USRP_DBID_FLEX_900_RX_MIMO_A):  db = new 
db_flexrf_900_rx_mimo_a(usrp, which); break;
+    //case(USRP_DBID_FLEX_400_TX_MIMO_A):  db = new 
db_flexrf_400_tx_mimo_a(usrp, which); break;
+    //case(USRP_DBID_FLEX_400_RX_MIMO_A):  db = new 
db_flexrf_400_rx_mimo_a(usrp, which); break;
+    //case(USRP_DBID_FLEX_2400_TX_MIMO_B): db = new 
db_flexrf_2400_tx_mimo_b(usrp, which); break;
+    //case(USRP_DBID_FLEX_2400_RX_MIMO_B): db = new 
db_flexrf_2400_rx_mimo_b(usrp, which); break;
+    //case(USRP_DBID_FLEX_1800_TX_MIMO_B): db = new 
db_flexrf_1800_tx_mimo_b(usrp, which); break;
+    //case(USRP_DBID_FLEX_1800_RX_MIMO_B): db = new 
db_flexrf_1800_rx_mimo_b(usrp, which); break;
+    //case(USRP_DBID_FLEX_1200_TX_MIMO_B): db = new 
db_flexrf_1200_tx_mimo_b(usrp, which); break;
+    //case(USRP_DBID_FLEX_1200_RX_MIMO_B): db = new 
db_flexrf_1200_rx_mimo_b(usrp, which); break;
+    //case(USRP_DBID_FLEX_900_TX_MIMO_B):  db = new 
db_flexrf_900_tx_mimo_b(usrp, which); break;
+    //case(USRP_DBID_FLEX_900_RX_MIMO_B):  db = new 
db_flexrf_900_rx_mimo_b(usrp, which); break;
+    //case(USRP_DBID_FLEX_400_TX_MIMO_B):  db = new 
db_flexrf_400_tx_mimo_b(usrp, which); break;
+    //case(USRP_DBID_FLEX_400_RX_MIMO_B):  db = new 
db_flexrf_400_rx_mimo_b(usrp, which); break;
+
+
+  case(-1):
+    try { 
+      //usrp->tx_freq(0);
+      //db = new db_basic_tx(usrp, which);
+      db = NULL;
+    }
+    catch (int e) {
+      db = NULL; //new db_basic_rx(usrp, which);
+    }
+    break;
+  
+  case(-2):
+  default:
+    try {
+      /*
+      usrp->tx_freq(0);
+      fprintf(stderr, "\n\aWarning: Treating daughterboard with invalid EEPROM 
contents as if it were a \"Basic Tx.\"\n");
+      fprintf(stderr, "Warning: This is almost certainly wrong...  Use 
appropriate burn-*-eeprom utility.\n\n");
+      db = new db_basic_tx(usrp, which);
+      */
+      db = NULL;
+    }
+    catch (int e) {
+      fprintf(stderr, "\n\aWarning: Treating daughterboard with invalid EEPROM 
contents as if it were a \"Basic Rx.\"\n");
+      fprintf(stderr, "Warning: This is almost certainly wrong...  Use 
appropriate burn-*-eeprom utility.\n\n");
+      db = NULL; //new db_basic_rx(usrp, which);
+    }
+    break;
+  }
+
+  return db;
+}

Added: 
gnuradio/branches/developers/trondeau/dbs/usrp/host/lib/legacy/db_boards.h
===================================================================
--- gnuradio/branches/developers/trondeau/dbs/usrp/host/lib/legacy/db_boards.h  
                        (rev 0)
+++ gnuradio/branches/developers/trondeau/dbs/usrp/host/lib/legacy/db_boards.h  
2008-08-10 19:43:47 UTC (rev 9223)
@@ -0,0 +1,38 @@
+/* -*- c++ -*- */
+//
+// Copyright 2008 Free Software Foundation, Inc.
+// 
+// This file is part of GNU Radio
+// 
+// GNU Radio is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either asversion 3, or (at your option)
+// any later version.
+// 
+// GNU Radio is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+// 
+// You should have received a copy of the GNU General Public License
+// along with GNU Radio; see the file COPYING.  If not, write to
+// the Free Software Foundation, Inc., 51 Franklin Street,
+// Boston, MA 02110-1301, USA.
+//
+
+#ifndef DB_BOARDS_H
+#define DB_BOARDS_H
+
+#include <usrp_basic.h>
+#include <usrp_dbid.h>
+#include <db_base.h>
+//#include <db_basic.h>
+#include <db_tv_rx.h>
+#include <db_flexrf.h>
+#include <db_flexrf_mimo.h>
+
+db_base * instantiate_dbs(int dbid, usrp_basic *usrp, int which);
+
+#endif 
+
+





reply via email to

[Prev in Thread] Current Thread [Next in Thread]