Changeset 9764

Show
Ignore:
Timestamp:
10/09/08 01:03:39
Author:
eb
Message:

Added db(int which_side) method back into usrp_basic. Refactored a
bunch of includes related to db_*. Not yet tested, but just about
ready to test.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • gnuradio/branches/developers/eb/cppdb-wip/usrp/host/lib/legacy/Makefile.am

    r9752 r9764  
    115115        db_xcvr2450.cc                  \ 
    116116        db_dtt754.cc                    \ 
    117         db_dtt768.cc 
     117        db_dtt768.cc                    \ 
     118        db_util.cc 
    118119 
    119120#       db_wbx.cc 
     
    162163noinst_HEADERS =                        \ 
    163164        ad9862.h                        \ 
     165        db_base_impl.h                  \ 
     166        db_util.h                       \ 
    164167        fusb.h                          \ 
    165168        fusb_darwin.h                   \ 
  • gnuradio/branches/developers/eb/cppdb-wip/usrp/host/lib/legacy/db_base.cc

    r9762 r9764  
    2121 
    2222#include <db_base.h> 
    23 #include <stdexcept
     23#include <db_base_impl.h
    2424 
    2525tune_result::tune_result(double baseband, double dxc, double residual, bool inv) 
     
    4848 
    4949int  
    50 db_base::dbid() 
     50db_base::dbid() const 
    5151{ 
    5252  return d_usrp->daughterboard_id(d_which); 
     
    5454 
    5555std::string  
    56 db_base::name() 
     56db_base::name() const 
    5757{ 
    5858  return usrp_dbid_to_string(dbid()); 
     
    6060 
    6161std::string  
    62 db_base::side_and_name() 
     62db_base::side_and_name() const 
    6363{ 
    6464  if(d_which == 0) 
     
    218218  throw std::runtime_error("_reflck_divisor() called from base class\n");; 
    219219} 
     220 
     221 
     222std::ostream &operator<<(std::ostream &os, const db_base &x) 
     223{ 
     224  os << x.side_and_name(); 
     225  return os; 
     226} 
     227 
     228 
     229 
    220230 
    221231#if 0   // FIXME tune shouldn't be a method of db_base 
  • gnuradio/branches/developers/eb/cppdb-wip/usrp/host/lib/legacy/db_base.h

    r9762 r9764  
    2121// 
    2222 
    23 #ifndef DB_BASE_H 
    24 #define DB_BASE_H 
     23#ifndef INCLUDED_DB_BASE_H 
     24#define INCLUDED_DB_BASE_H 
    2525 
    26 #include <fpga_regs_standard.h> 
    27 #include <fpga_regs_common.h> 
    28 #include <vector> 
    29 #include <usrp_prims.h> 
    30 #include <usrp_spi_defs.h> 
    31 #include <usrp_standard.h> 
     26#include <string> 
     27#include <iosfwd> 
     28 
     29class usrp_basic; 
    3230 
    3331 
     
    6058  virtual ~db_base(); 
    6159 
    62   int dbid()
    63   std::string name()
    64   std::string side_and_name()
     60  int dbid() const
     61  std::string name() const
     62  std::string side_and_name() const
    6563 
    6664  bool bypass_adc_buffers(bool bypass); 
     
    105103}; 
    106104 
    107 #endif  
    108105 
     106std::ostream & operator<<(std::ostream &os, const db_base &x); 
    109107 
     108#endif /* INCLUDED_DB_BASE_H */ 
  • gnuradio/branches/developers/eb/cppdb-wip/usrp/host/lib/legacy/db_basic.cc

    r9762 r9764  
    2020 
    2121#include <db_basic.h> 
     22#include <db_base_impl.h> 
    2223 
    2324 
  • gnuradio/branches/developers/eb/cppdb-wip/usrp/host/lib/legacy/db_boards.h

    r9744 r9764  
    2626#include <db_base.h> 
    2727#include <usrp_basic.h> 
    28 #include <vector> 
    29 #include <boost/shared_ptr.hpp> 
    30  
    31 class db_base; 
    32 typedef boost::shared_ptr<db_base> db_base_sptr; 
    3328 
    3429std::vector<db_base_sptr> instantiate_dbs(int dbid, usrp_basic *usrp, int which_side); 
  • gnuradio/branches/developers/eb/cppdb-wip/usrp/host/lib/legacy/db_dbs_rx.cc

    r9762 r9764  
    2020 
    2121#include <db_dbs_rx.h> 
    22 #include <db_tv_rx.h> 
    23 #include <sstream> 
    24 #include <assert.h> 
    25 #include <stdexcept> 
     22#include <db_base_impl.h> 
    2623#include <cmath> 
    2724 
  • gnuradio/branches/developers/eb/cppdb-wip/usrp/host/lib/legacy/db_dbs_rx.h

    r9762 r9764  
    2424 
    2525#include <db_base.h> 
     26#include <vector> 
    2627 
    2728struct bw_t { 
  • gnuradio/branches/developers/eb/cppdb-wip/usrp/host/lib/legacy/db_dtt754.cc

    r9733 r9764  
    2121 
    2222#include <db_dtt754.h> 
    23 #include <db_tv_rx.h> 
     23#include <db_base_impl.h> 
    2424 
    2525int 
  • gnuradio/branches/developers/eb/cppdb-wip/usrp/host/lib/legacy/db_dtt768.cc

    r9733 r9764  
    2121 
    2222#include <db_dtt768.h> 
    23 #include <db_tv_rx.h> 
     23#include <db_base_impl.h> 
    2424 
    2525int 
  • gnuradio/branches/developers/eb/cppdb-wip/usrp/host/lib/legacy/db_flexrf.cc

    r9762 r9764  
    2020 
    2121#include <db_flexrf.h> 
    22 #include <sstream> 
    23 #include <assert.h> 
    24 #include <stdexcept> 
     22#include <db_base_impl.h> 
    2523 
    2624// d'board i/o pin defs 
  • gnuradio/branches/developers/eb/cppdb-wip/usrp/host/lib/legacy/db_flexrf_mimo.cc

    r9733 r9764  
    2121 
    2222#include <db_flexrf_mimo.h> 
    23 #include <assert.h> 
     23#include <fpga_regs_standard.h> 
     24#include <fpga_regs_common.h> 
     25#include <usrp_prims.h> 
     26#include <usrp_spi_defs.h> 
     27 
    2428 
    2529db_flexrf_2400_tx_mimo_a::db_flexrf_2400_tx_mimo_a(usrp_basic *usrp, int which) 
  • gnuradio/branches/developers/eb/cppdb-wip/usrp/host/lib/legacy/db_tv_rx.cc

    r9762 r9764  
    2020 
    2121#include <db_tv_rx.h> 
    22 #include <sstream> 
    23 #include <assert.h> 
     22#include <db_base_impl.h> 
    2423 
    2524/*****************************************************************************/ 
    26  
    27 std::string 
    28 int_seq_to_str(std::vector<int> &seq) 
    29 { 
    30   //convert a sequence of integers into a string 
    31  
    32   std::stringstream str;  
    33   std::vector<int>::iterator i; 
    34   for(i = seq.begin(); i != seq.end(); i++) { 
    35     str << char((unsigned int)*i); 
    36   } 
    37   return str.str(); 
    38 } 
    39  
    40 std::vector<int>  
    41 str_to_int_seq(std::string str) 
    42 { 
    43   //convert a string to a list of integers 
    44   std::vector<int> seq; 
    45   std::vector<int>::iterator sitr; 
    46   std::string::iterator i; 
    47   for(i=str.begin(); i != str.end(); i++) { 
    48     int a = (int)(*i); 
    49     seq.push_back(a); 
    50   } 
    51   return seq; 
    52 } 
    5325 
    5426int 
  • gnuradio/branches/developers/eb/cppdb-wip/usrp/host/lib/legacy/db_tv_rx.h

    r9733 r9764  
    3232  void _set_pga(float pga_gain); 
    3333 
    34   usrp_basic_rx *d_usrp; 
    3534  int d_i2c_addr; 
    3635  double d_first_IF, d_second_IF; 
     
    5554}; 
    5655 
    57 std::string int_seq_to_str(std::vector<int> &seq); 
    58 std::vector<int> str_to_int_seq(std::string str); 
    59 int control_byte_1(bool fast_tuning_p, int reference_divisor); 
    60 int control_byte_2(double target_freq, bool shutdown_tx_PGA); 
    61  
    6256#endif 
  • gnuradio/branches/developers/eb/cppdb-wip/usrp/host/lib/legacy/db_wbx.cc

    r9733 r9764  
    2121 
    2222#include <db_wbx.h> 
     23#include <fpga_regs_standard.h> 
     24#include <fpga_regs_common.h> 
     25#include <usrp_prims.h> 
     26#include <usrp_spi_defs.h> 
    2327#include <stdexcept> 
    2428#include <cmath> 
  • gnuradio/branches/developers/eb/cppdb-wip/usrp/host/lib/legacy/db_xcvr2450.cc

    r9733 r9764  
    2020 
    2121#include <db_xcvr2450.h> 
     22#include <db_base_impl.h> 
    2223#include <cmath> 
    23 #include <sstream> 
    24 #include <assert.h> 
    2524 
    2625 
  • gnuradio/branches/developers/eb/cppdb-wip/usrp/host/lib/legacy/usrp_basic.cc

    r9763 r9764  
    3131#include "fpga_regs_standard.h" 
    3232#include "fusb.h" 
     33#include "db_boards.h" 
    3334#include <usb.h> 
    3435#include <stdexcept> 
     
    112113    d_usb_data_rate (16000000), // SWAG, see below 
    113114    d_bytes_per_poll ((int) (POLLING_INTERVAL * d_usb_data_rate)), 
    114     d_verbose (false) 
     115    d_verbose (false), d_db(2) 
    115116{ 
    116117  /* 
     
    158159usrp_basic::~usrp_basic () 
    159160{ 
     161  d_db.resize(0);       // nuke d'boards before we close down USB 
     162 
    160163  if (d_udh) 
    161164    usb_close (d_udh); 
    162165} 
     166 
     167/* 
     168 * We return a vector of weak pointers.  d_db should be the only place 
     169 * in the system that's holding them as shared pointers. 
     170 */ 
     171std::vector<db_base_wptr>  
     172usrp_basic::db(int which_side) 
     173{ 
     174  which_side &= 0x1;    // clamp it to avoid any reporting any errors 
     175  std::vector<db_base_wptr> r; 
     176 
     177  assert(d_db.size() == 2); 
     178 
     179  for (unsigned i = 0; i < d_db[which_side].size(); i++) 
     180    r.push_back(db_base_wptr(d_db[which_side][i])); 
     181 
     182  return r; 
     183} 
     184 
    163185 
    164186bool 
     
    742764 
    743765  probe_rx_slots (false); 
     766  d_db[0] = instantiate_dbs(d_dbid[0], this, 0); 
     767  d_db[1] = instantiate_dbs(d_dbid[1], this, 1); 
    744768 
    745769  // check fusb buffering parameters 
     
    11461170 
    11471171  probe_tx_slots (false); 
     1172  d_db[0] = instantiate_dbs(d_dbid[0], this, 0); 
     1173  d_db[1] = instantiate_dbs(d_dbid[1], this, 1); 
    11481174 
    11491175  // check fusb buffering parameters 
  • gnuradio/branches/developers/eb/cppdb-wip/usrp/host/lib/legacy/usrp_basic.h

    r9761 r9764  
    4242#include <usrp_slots.h> 
    4343#include <string> 
     44#include <vector> 
    4445#include <boost/shared_ptr.hpp> 
     46#include <boost/weak_ptr.hpp> 
    4547#include <boost/utility.hpp> 
    46  
    47  
    48 class db_base; 
    49 typedef boost::shared_ptr<db_base> db_base_sptr; 
    5048 
    5149 
     
    5856  C_TX = 1 
    5957}; 
     58 
     59class db_base; 
     60typedef boost::shared_ptr<db_base> db_base_sptr; 
     61typedef boost::weak_ptr<db_base> db_base_wptr; 
    6062 
    6163 
     
    7476  unsigned int           d_fpga_shadows[MAX_REGS]; 
    7577 
     78  int                    d_dbid[2];             // daughterboard ID's (side A, side B) 
     79 
     80  /*! 
     81   * Shared pointers to subclasses of db_base. 
     82   * The outer vector is of length 2 (0 = side A, 1 = side B).  The inner vectors 
     83   * are of length 1 or 2 depending on whether the given daugherboard implements 
     84   * 1 or 2 subdevices.  At this time, only the Basic Rx and LF Rx implement 
     85   * 2 subdevices. 
     86   */ 
     87  std::vector< std::vector<db_base_sptr> > d_db; 
     88 
    7689  usrp_basic (int which_board, 
    7790              struct usb_dev_handle *open_interface (struct usb_device *dev), 
     
    126139 
    127140  /*! 
     141   * Return a vector of size 1 or 2 that contains weak pointers 
     142   * to the daughterboard instance(s) associated with the specified side. 
     143   * 
     144   * \param which_side  [0,1] which daughterboard 
     145   * 
     146   * N.B. To ensure proper lifetime management, the caller should 
     147   * continue to hold these as weak pointers, not shared pointers.   
     148   * As long as the caller does not attempt to directly use the weak 
     149   * pointers after this usrp object has been destroyed, everything 
     150   * will work out fine. 
     151   */ 
     152  std::vector<db_base_wptr> db(int which_side); 
     153 
     154  /*! 
    128155   * \brief return frequency of master oscillator on USRP 
    129156   */ 
     
    194221  /*! 
    195222   * \brief Control ADC input buffer 
    196    * \param which     which ADC[0,3] 
     223   * \param which_adc         which ADC[0,3] 
    197224   * \param bypass      if non-zero, bypass input buffer and connect input 
    198225   *                    directly to switched cap SHA input of RxPGA. 
     
    717744 
    718745protected: 
    719   int                    d_dbid[2];             // Rx daughterboard ID's 
    720  
    721746  /*! 
    722747   * \param which_board      Which USRP board on usb (not particularly useful; use 0) 
     
    826851 
    827852 protected: 
    828   int                    d_dbid[2];             // Tx daughterboard ID's 
    829  
    830853  /*! 
    831854   * \param which_board      Which USRP board on usb (not particularly useful; use 0)