commit-gnuradio
[Top][All Lists]
Advanced

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

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


From: trondeau
Subject: [Commit-gnuradio] r9257 - gnuradio/branches/developers/trondeau/dbs/usrp/host/lib/legacy
Date: Tue, 12 Aug 2008 14:02:35 -0600 (MDT)

Author: trondeau
Date: 2008-08-12 14:02:35 -0600 (Tue, 12 Aug 2008)
New Revision: 9257

Modified:
   gnuradio/branches/developers/trondeau/dbs/usrp/host/lib/legacy/db_flexrf.cc
   gnuradio/branches/developers/trondeau/dbs/usrp/host/lib/legacy/db_flexrf.h
   gnuradio/branches/developers/trondeau/dbs/usrp/host/lib/legacy/usrp_basic.cc
   gnuradio/branches/developers/trondeau/dbs/usrp/host/lib/legacy/usrp_basic.h
   
gnuradio/branches/developers/trondeau/dbs/usrp/host/lib/legacy/usrp_standard.cc
Log:
wip: refactoring some rx/tx guys in usrp_basic.

Modified: 
gnuradio/branches/developers/trondeau/dbs/usrp/host/lib/legacy/db_flexrf.cc
===================================================================
--- gnuradio/branches/developers/trondeau/dbs/usrp/host/lib/legacy/db_flexrf.cc 
2008-08-12 20:02:01 UTC (rev 9256)
+++ gnuradio/branches/developers/trondeau/dbs/usrp/host/lib/legacy/db_flexrf.cc 
2008-08-12 20:02:35 UTC (rev 9257)
@@ -125,7 +125,13 @@
   s[0] = (char)((v >> 16) & 0xff);
   s[1] = (char)((v >>  8) & 0xff);
   s[2] = (char)(v & 0xff);
-  d_usrp->_write_spi(0, d_spi_enable, d_spi_format, s);
+  std::string str(s, 3);
+  printf("s[0]: %d  s[1]: %d  s[2]: %d\n",
+        ((v >> 16) & 0xff),
+        ((v >>  8) & 0xff),
+        (v & 0xff));
+  printf("spi_enable: %d   spi_format: %d\n", d_spi_enable, d_spi_format);
+  d_usrp->_write_spi(0, d_spi_enable, d_spi_format, str);
 }
         
 bool
@@ -139,6 +145,12 @@
     return true;
   }
   else {      // Give it a second chance
+    // FIXME: make portable sleep
+    timespec t;
+    t.tv_sec = 0;
+    t.tv_nsec = 10000000;
+    nanosleep(&t, NULL);
+    
     if(d_usrp->read_io(d_which) & PLL_LOCK_DETECT) {
       return true;
     }
@@ -189,7 +201,7 @@
   */
 
   //std::vector<float> args(2, 0);
-  struct freq_result_t args = {0, 0};
+  struct freq_result_t args = {false, 0};
 
   // Offsetting the LO helps get the Tx carrier leakage out of the way.
   // This also ensures that on Rx, we're not getting hosed by the
@@ -579,7 +591,8 @@
 
   int R = (d_R_RSV<<22) | (d_BSC<<20) | (d_TEST<<19) | 
     (d_LDP<<18) | (d_ABP<<16) | (d_R_DIV<<2);
-        
+  
+  printf("computing control reg\n");
   int control = _compute_control_reg();
 
   int N = (d_DIVSEL<<23) | (d_DIV2<<22) | (d_CPGAIN<<21) | 
@@ -599,6 +612,7 @@
     | (d_MTLD<<11) | (d_CPG<<10) | (d_CP3S<<9) | (d_PDP<<8) |
     (d_MUXOUT<<5) | (d_CR<<4) | (d_PC<<2);
   
+  printf("_AD4360_common::_compute_control_reg\n");
   return control;
 }
 
@@ -812,6 +826,8 @@
 
   d_power_on = 0;
   d_power_off = 0;    // powering it off kills the serial bus
+
+  printf("built RFX2400tx\n");
 }
 
 db_flexrf_2400_tx::~db_flexrf_2400_tx()
@@ -834,6 +850,7 @@
 bool
 db_flexrf_2400_tx::_compute_regs(float freq, int &retR, int &retcontrol, int 
&retN, float &retfreq)
 {
+  printf("db_flexrf_2400_tx::_compute_regs\n");
   return d_common->_compute_regs(_refclk_freq(), freq, retR, retcontrol, retN, 
retfreq);
 }
 
@@ -842,10 +859,10 @@
 db_flexrf_2400_rx::db_flexrf_2400_rx(usrp_basic *usrp, int which)
   : flexrf_base_rx(usrp, which)
 {
-  d_common = new _2400_common(false);
+  d_common = new _2400_common(d_tx);
   d_power_on = 0;
   d_power_off = 0;   // Powering it off kills the serial bus
-  printf("db_flexrf_2400_rx\n");
+  printf("built RFX2400rx\n");
 }
 
 db_flexrf_2400_rx::~db_flexrf_2400_rx()
@@ -893,12 +910,14 @@
 bool
 db_flexrf_2400_rx::_compute_regs(float freq, int &retR, int &retcontrol, int 
&retN, float &retfreq)
 {
+  printf("db_flexrf_2400_rx::_compute_regs\n");
   return d_common->_compute_regs(_refclk_freq(), freq, retR, retcontrol, retN, 
retfreq);
 }
 
 int
 db_flexrf_2400_rx::_compute_control_reg()
 {  
+  printf("db_flexrf_2400_rx::_compute_control_reg\n");
   return d_common->_compute_control_reg();
 }
 
@@ -913,9 +932,9 @@
 
 
 db_flexrf_1200_tx::db_flexrf_1200_tx(usrp_basic *usrp, int which)
-  : flexrf_base_tx(usrp, which),
-     _1200_common(true)
+  : flexrf_base_tx(usrp, which)
 {
+  d_common = new _1200_common(d_tx);
   d_power_on = 0;
   d_power_off = 0;    // powering it off kills the serial bus
 }
@@ -947,9 +966,9 @@
 
 
 db_flexrf_1200_rx::db_flexrf_1200_rx(usrp_basic *usrp, int which)
-  : flexrf_base_rx(usrp, which),
-    _1200_common(false)
+  : flexrf_base_rx(usrp, which)
 {
+  d_common = new _1200_common(d_tx);
   d_power_on = 0;
   d_power_off = 0;   // Powering it off kills the serial bus
 }
@@ -1004,6 +1023,7 @@
 int
 db_flexrf_1200_rx::_compute_control_reg()
 {  
+  printf("db_flexrf_1200_rx::_compute_control_reg\n");
   return d_common->_compute_control_reg();
 }
 
@@ -1018,9 +1038,9 @@
 
 
 db_flexrf_1800_tx::db_flexrf_1800_tx(usrp_basic *usrp, int which)
-  : flexrf_base_tx(usrp, which),
-     _1800_common(true)
+  : flexrf_base_tx(usrp, which)
 {
+  d_common = new _1800_common(d_tx);
   d_power_on = 0;
   d_power_off = 0;    // powering it off kills the serial bus
 }
@@ -1051,9 +1071,9 @@
 
 
 db_flexrf_1800_rx::db_flexrf_1800_rx(usrp_basic *usrp, int which)
-  : flexrf_base_rx(usrp, which),
-    _1800_common(false)
+  : flexrf_base_rx(usrp, which)
 {
+  d_common = new _1800_common(d_tx);
   d_power_on = 0;
   d_power_off = 0;   // Powering it off kills the serial bus
 }
@@ -1108,7 +1128,8 @@
 
 int
 db_flexrf_1800_rx::_compute_control_reg()
-{  
+{
+  printf("db_flexrf_1800_rx::_compute_control_reg\n");
   return d_common->_compute_control_reg();
 }
 
@@ -1123,9 +1144,9 @@
 
 
 db_flexrf_900_tx::db_flexrf_900_tx(usrp_basic *usrp, int which)
-  : flexrf_base_tx(usrp, which),
-    _900_common(true)
+  : flexrf_base_tx(usrp, which)
 {
+  d_common = new _900_common(d_tx);
   d_power_on = 0;
   d_power_off = 0;    // powering it off kills the serial bus
 }
@@ -1150,14 +1171,15 @@
 bool
 db_flexrf_900_tx::_compute_regs(float freq, int &retR, int &retcontrol, int 
&retN, float &retfreq)
 {
+  printf("db_flexrf_900_tx::_compute_regs\n");
   return d_common->_compute_regs(_refclk_freq(), freq, retR, retcontrol, retN, 
retfreq);
 }
 
 
 db_flexrf_900_rx::db_flexrf_900_rx(usrp_basic *usrp, int which)
-  : flexrf_base_rx(usrp, which),
-    _900_common(false)
+  : flexrf_base_rx(usrp, which)
 {
+  d_common = new _900_common(d_tx);
   d_power_on = 0;
   d_power_off = 0;   // Powering it off kills the serial bus
 }
@@ -1206,12 +1228,14 @@
 bool
 db_flexrf_900_rx::_compute_regs(float freq, int &retR, int &retcontrol, int 
&retN, float &retfreq)
 {
+  printf("db_flexrf_900_rx::_compute_regs\n");
   return d_common->_compute_regs(_refclk_freq(), freq, retR, retcontrol, retN, 
retfreq);
 }
 
 int
 db_flexrf_900_rx::_compute_control_reg()
 {  
+  printf("db_flexrf_900_rx::_compute_control_reg\n");
   return d_common->_compute_control_reg();
 }
 
@@ -1226,11 +1250,13 @@
 
 
 db_flexrf_400_tx::db_flexrf_400_tx(usrp_basic *usrp, int which)
-  : flexrf_base_tx(usrp, which),
-    _400_common(true)
+  : flexrf_base_tx(usrp, which)
 {
+  d_common = new _400_common(d_tx);
   d_power_on = POWER_UP;
   d_power_off = 0;    // powering it off kills the serial bus
+
+  printf("built RFX400tx\n");
 }
 
 db_flexrf_400_tx::~db_flexrf_400_tx()
@@ -1253,17 +1279,22 @@
 bool
 db_flexrf_400_tx::_compute_regs(float freq, int &retR, int &retcontrol, int 
&retN, float &retfreq)
 {
+  printf("db_flexrf_400_tx::_compute_regs\n");
   return d_common->_compute_regs(_refclk_freq(), freq, retR, retcontrol, retN, 
retfreq);
 }
 
 
 
 db_flexrf_400_rx::db_flexrf_400_rx(usrp_basic *usrp, int which)
-  : flexrf_base_rx(usrp, which),
-    _400_common(false)
+  : flexrf_base_rx(usrp, which)
 {
+  d_common = new _400_common(d_tx);
   d_power_on = POWER_UP;
   d_power_off = 0;   // Powering it off kills the serial bus
+
+  printf("built RFX400rx\n");
+  printf("flexrf_400_rx name: %s\n", name().c_str());
+  printf("flexrf_400_rx which: %d\n", d_which);
 }
 
 db_flexrf_400_rx::~db_flexrf_400_rx()
@@ -1284,6 +1315,7 @@
 }
 
 float
+
 db_flexrf_400_rx::gain_db_per_step()
 {
   return 0.035;
@@ -1311,12 +1343,14 @@
 bool
 db_flexrf_400_rx::_compute_regs(float freq, int &retR, int &retcontrol, int 
&retN, float &retfreq)
 {
+  printf("db_flexrf_400_rx::_compute_regs\n");
   return d_common->_compute_regs(_refclk_freq(), freq, retR, retcontrol, retN, 
retfreq);
 }
 
 int
 db_flexrf_400_rx::_compute_control_reg()
 {  
+  printf("db_flexrf_400_rx::_compute_control_reg\n");
   return d_common->_compute_control_reg();
 }
 

Modified: 
gnuradio/branches/developers/trondeau/dbs/usrp/host/lib/legacy/db_flexrf.h
===================================================================
--- gnuradio/branches/developers/trondeau/dbs/usrp/host/lib/legacy/db_flexrf.h  
2008-08-12 20:02:01 UTC (rev 9256)
+++ gnuradio/branches/developers/trondeau/dbs/usrp/host/lib/legacy/db_flexrf.h  
2008-08-12 20:02:35 UTC (rev 9257)
@@ -246,7 +246,7 @@
 
 //------------------------------------------------------------    
 
-class db_flexrf_1200_tx : public flexrf_base_tx, public _1200_common
+class db_flexrf_1200_tx : public flexrf_base_tx
 {
 public:
   db_flexrf_1200_tx(usrp_basic *usrp, int which);
@@ -262,7 +262,7 @@
 
 };
 
-class db_flexrf_1200_rx : public flexrf_base_rx, public _1200_common
+class db_flexrf_1200_rx : public flexrf_base_rx
 {
 public:
   db_flexrf_1200_rx(usrp_basic *usrp, int which);
@@ -285,7 +285,7 @@
 
 //------------------------------------------------------------    
 
-class db_flexrf_1800_tx : public flexrf_base_tx, public _1800_common
+class db_flexrf_1800_tx : public flexrf_base_tx
 {
  public:
   db_flexrf_1800_tx(usrp_basic *usrp, int which);
@@ -300,7 +300,7 @@
   _1800_common *d_common;
 };
 
-class db_flexrf_1800_rx : public flexrf_base_rx, public _1800_common
+class db_flexrf_1800_rx : public flexrf_base_rx
 {
 public:
   db_flexrf_1800_rx(usrp_basic *usrp, int which);
@@ -323,7 +323,7 @@
 
 //------------------------------------------------------------    
 
-class db_flexrf_900_tx : public flexrf_base_tx, public _900_common
+class db_flexrf_900_tx : public flexrf_base_tx
 {
  public:
   db_flexrf_900_tx(usrp_basic *usrp, int which);
@@ -338,7 +338,7 @@
   _900_common *d_common;
 };
 
-class db_flexrf_900_rx : public flexrf_base_rx, public _900_common
+class db_flexrf_900_rx : public flexrf_base_rx
 {
 public:
   db_flexrf_900_rx(usrp_basic *usrp, int which);
@@ -362,7 +362,7 @@
 
 //------------------------------------------------------------    
 
-class db_flexrf_400_tx : public flexrf_base_tx, public _400_common
+class db_flexrf_400_tx : public flexrf_base_tx
 {
  public:
   db_flexrf_400_tx(usrp_basic *usrp, int which);
@@ -377,7 +377,7 @@
   _400_common *d_common;
 };
 
-class db_flexrf_400_rx : public flexrf_base_rx, public _400_common
+class db_flexrf_400_rx : public flexrf_base_rx
 {
 public:
   db_flexrf_400_rx(usrp_basic *usrp, int which);

Modified: 
gnuradio/branches/developers/trondeau/dbs/usrp/host/lib/legacy/usrp_basic.cc
===================================================================
--- 
gnuradio/branches/developers/trondeau/dbs/usrp/host/lib/legacy/usrp_basic.cc    
    2008-08-12 20:02:01 UTC (rev 9256)
+++ 
gnuradio/branches/developers/trondeau/dbs/usrp/host/lib/legacy/usrp_basic.cc    
    2008-08-12 20:02:35 UTC (rev 9257)
@@ -236,24 +236,34 @@
 }
 
 int
-usrp_basic::dboard_to_slot (int dboard)
+usrp_basic::dboard_to_slot (txrx_t tx, int dboard)
 {
-  printf("usrp_basic::dboard_to_slot\n");
-  return (dboard << 1) | !(d_tx); 
-
   // tx=(0,2) rx=(1,3)
+  return (dboard << 1) | (tx^1); 
 }
 
 std::vector<db_base_sptr> 
 usrp_basic::db(int which)
 {
+  printf("calling db: %s\n", d_db[which][0]->name().c_str());
   if(which > 3) {
         throw std::invalid_argument("usrp_standard_commond::db which must be 
0, 1, 2, or 3");
   }
   return d_db[which];
 }
 
+int
+usrp_basic::common_daughterboard_id (txrx_t tx, int which_dboard) const 
+{ 
+  return d_dbid[(which_dboard << 1) | (tx^1)];
+}
 
+int
+usrp_basic::daughterboard_id (int which_dboard) const 
+{ 
+  throw std::runtime_error("daughterboard_id called from usrp_basic.\n");
+}
+
 /********************************************
   PGA functions
 ********************************************/
@@ -619,6 +629,7 @@
 bool
 usrp_basic::_write_spi (int optional_header, int enables, int format, 
std::string buf)
 {
+  printf("buf length: %d\n", buf.size());
   return usrp_spi_write (d_udh, optional_header, enables, format,
                         buf.data(), buf.size());
 }
@@ -638,48 +649,71 @@
 }
 
 bool
-usrp_basic::_write_oe (int which_dboard, int value, int mask)
+usrp_basic::_common_write_oe (txrx_t tx, int which_dboard, int value, int mask)
 {
+
   if (! (0 <= which_dboard && which_dboard <= 1))
     return false;
 
-  return _write_fpga_reg (slot_id_to_oe_reg (dboard_to_slot (which_dboard)),
+  return _write_fpga_reg (slot_id_to_oe_reg (dboard_to_slot (tx, 
which_dboard)),
                          (mask << 16) | (value & 0xffff));
 }
 
 bool
-usrp_basic::write_io (int which_dboard, int value, int mask)
+usrp_basic::_write_oe (int which_dboard, int value, int mask)
 {
+  throw std::runtime_error("_write_oe called from usrp_basic.\n");
+}
+
+bool
+usrp_basic::common_write_io (txrx_t tx, int which_dboard, int value, int mask)
+{
   if (! (0 <= which_dboard && which_dboard <= 1))
     return false;
 
-  return _write_fpga_reg (slot_id_to_io_reg (dboard_to_slot (which_dboard)),
+  return _write_fpga_reg (slot_id_to_io_reg (dboard_to_slot (tx, 
which_dboard)),
                          (mask << 16) | (value & 0xffff));
 }
 
 bool
-usrp_basic::read_io (int which_dboard, int *value)
+usrp_basic::write_io (int which_dboard, int value, int mask)
 {
+  throw std::runtime_error("write_io called from usrp_basic.\n");
+}
+
+bool
+usrp_basic::common_read_io (txrx_t tx, int which_dboard, int *value)
+{
   if (! (0 <= which_dboard && which_dboard <= 1))
     return false;
 
   int t;
   int reg = which_dboard + 1;  // FIXME, *very* magic number (fix in 
serial_io.v)
   bool ok = _read_fpga_reg (reg, &t);
+  printf("read_fpga_reg ret: %d\n", ok);
   if (!ok)
     return false;
 
-  *value = (t >> 16) & 0xffff; // FIXME, more magic
+  // FIXME, more magic
+  if(tx) {
+    *value = t & 0xffff;       
+  }
+  else {
+    *value = (t >> 16) & 0xffff;
+  }
   return true;
 }
 
+bool
+usrp_basic::read_io (int which_dboard, int *value)
+{
+  throw std::runtime_error("read_io called from usrp_basic.\n");
+}
+
 int
 usrp_basic::read_io (int which_dboard)
 {
-  int  value;
-  if (!read_io (which_dboard, &value))
-    return READ_FAILED;
-  return value;
+  throw std::runtime_error("read_io called from usrp_basic.\n");
 }
 
 bool
@@ -739,6 +773,8 @@
 
   printf("probing rx slots\n");
   probe_rx_slots (false);
+  printf("rx slot A: %d\n", d_dbid[SLOT_RX_A]);
+  printf("rx slot B: %d\n", d_dbid[SLOT_RX_B]);
   d_db[SLOT_RX_A] = instantiate_dbs(d_dbid[SLOT_RX_A], this, which_board);
   d_db[SLOT_RX_B] = instantiate_dbs(d_dbid[SLOT_RX_B], this, which_board);
 
@@ -788,11 +824,21 @@
   }
 }
 
+int
+usrp_basic_rx::daughterboard_id (int which_dboard) const 
+{ 
+  printf("called daughterboard_id in usrp_basic_rx with 
which_dboard=%d\n",which_dboard);
+  return common_daughterboard_id(C_RX, which_dboard);
+}
+
+
 std::vector<db_base_sptr> 
 usrp_basic_rx::db(int which)
 {
+  printf("usrp_basic_rx::db which: %d\n", which);
   // When called from here, only return if the RX side
   if(which == 0) {
+    printf("   name: %s\n", d_db[SLOT_RX_A][0]->name().c_str());
     return d_db[SLOT_RX_A];
   }
   else {
@@ -800,8 +846,34 @@
   }
 }
 
+bool 
+usrp_basic_rx::_write_oe (int which_dboard, int value, int mask)
+{
+  return _common_write_oe(C_RX, which_dboard, value, mask);
+}
 
 bool
+usrp_basic_rx::write_io (int which_dboard, int value, int mask)
+{
+  return common_write_io(C_RX, which_dboard, value, mask);
+}
+
+bool
+usrp_basic_rx::read_io (int which_dboard, int *value)
+{
+  return common_read_io(C_RX, which_dboard, value);
+}
+
+int
+usrp_basic_rx::read_io (int which_dboard)
+{
+  int value;
+  common_read_io(C_RX, which_dboard, &value);
+  return value;
+}
+
+
+bool
 usrp_basic_rx::start ()
 {
   if (!usrp_basic::start ())   // invoke parent's method
@@ -1002,27 +1074,30 @@
       fflush (stdout);
       fprintf (stderr, "%s: %s\n", slot_name[i], msg);
     }
+    
+    printf("usrp_basic_rx::probe_rx_slots dbid[%d] = %d\n", slot_id, 
d_dbid[slot_id]);
+
   }
 }
 
 bool
 usrp_basic_rx::write_aux_dac (int which_dboard, int which_dac, int value)
 {
-  return usrp_basic::write_aux_dac (dboard_to_slot (which_dboard),
+  return usrp_basic::write_aux_dac (dboard_to_slot (C_RX, which_dboard),
                                    which_dac, value);
 }
 
 bool
 usrp_basic_rx::read_aux_adc (int which_dboard, int which_adc, int *value)
 {
-  return usrp_basic::read_aux_adc (dboard_to_slot (which_dboard),
+  return usrp_basic::read_aux_adc (dboard_to_slot (C_RX, which_dboard),
                                   which_adc, value);
 }
 
 int
 usrp_basic_rx::read_aux_adc (int which_dboard, int which_adc)
 {
-  return usrp_basic::read_aux_adc (dboard_to_slot (which_dboard), which_adc);
+  return usrp_basic::read_aux_adc (dboard_to_slot (C_RX, which_dboard), 
which_adc);
 }
 
 int
@@ -1103,6 +1178,8 @@
 
   printf("probing tx slots\n");
   probe_tx_slots (false);
+  printf("tx slot A: %d\n", d_dbid[SLOT_TX_A]);
+  printf("tx slot B: %d\n", d_dbid[SLOT_TX_B]);
   d_db[SLOT_TX_A] = instantiate_dbs(d_dbid[SLOT_TX_A], this, which_board);
   d_db[SLOT_TX_B] = instantiate_dbs(d_dbid[SLOT_TX_B], this, which_board);
 
@@ -1151,7 +1228,39 @@
   }
 }
 
+int
+usrp_basic_tx::daughterboard_id (int which_dboard) const 
+{
+  return common_daughterboard_id(C_TX, which_dboard);
+}
+
+bool 
+usrp_basic_tx::_write_oe (int which_dboard, int value, int mask)
+{
+  return _common_write_oe(C_TX, which_dboard, value, mask);
+}
+
 bool
+usrp_basic_tx::write_io (int which_dboard, int value, int mask)
+{
+  return common_write_io(C_TX, which_dboard, value, mask);
+}
+
+bool
+usrp_basic_tx::read_io (int which_dboard, int *value)
+{
+  return common_read_io(C_TX, which_dboard, value);
+}
+
+int
+usrp_basic_tx::read_io (int which_dboard)
+{
+  int value;
+  common_read_io(C_TX, which_dboard, &value);
+  return value;
+}
+
+bool
 usrp_basic_tx::start ()
 {
   if (!usrp_basic::start ())
@@ -1361,21 +1470,21 @@
 bool
 usrp_basic_tx::write_aux_dac (int which_dboard, int which_dac, int value)
 {
-  return usrp_basic::write_aux_dac (dboard_to_slot (which_dboard),
+  return usrp_basic::write_aux_dac (dboard_to_slot (C_TX, which_dboard),
                                    which_dac, value);
 }
 
 bool
 usrp_basic_tx::read_aux_adc (int which_dboard, int which_adc, int *value)
 {
-  return usrp_basic::read_aux_adc (dboard_to_slot (which_dboard),
+  return usrp_basic::read_aux_adc (dboard_to_slot (C_TX, which_dboard),
                                   which_adc, value);
 }
 
 int
 usrp_basic_tx::read_aux_adc (int which_dboard, int which_adc)
 {
-  return usrp_basic::read_aux_adc (dboard_to_slot (which_dboard), which_adc);
+  return usrp_basic::read_aux_adc (dboard_to_slot (C_TX, which_dboard), 
which_adc);
 }
 
 int

Modified: 
gnuradio/branches/developers/trondeau/dbs/usrp/host/lib/legacy/usrp_basic.h
===================================================================
--- gnuradio/branches/developers/trondeau/dbs/usrp/host/lib/legacy/usrp_basic.h 
2008-08-12 20:02:01 UTC (rev 9256)
+++ gnuradio/branches/developers/trondeau/dbs/usrp/host/lib/legacy/usrp_basic.h 
2008-08-12 20:02:35 UTC (rev 9257)
@@ -1,6 +1,6 @@
 /* -*- c++ -*- */
 /*
- * Copyright 2003,2004 Free Software Foundation, Inc.
+ * Copyright 2003,2004,2008 Free Software Foundation, Inc.
  * 
  * This file is part of GNU Radio
  * 
@@ -45,6 +45,11 @@
 
 #include <boost/shared_ptr.hpp>
 
+enum txrx_t {
+  C_RX = 0,
+  C_TX = 1
+};
+
 class db_base;
 typedef boost::shared_ptr<db_base> db_base_sptr;
 
@@ -103,9 +108,8 @@
   void set_usb_data_rate (int usb_data_rate);
 
 
-  int  dboard_to_slot (int dboard);
+  int  dboard_to_slot (txrx_t tx, int dboard);
 
-
 public:
   virtual ~usrp_basic ();
 
@@ -114,19 +118,23 @@
   /*!
    * \brief Return daughterboard ID for given daughterboard slot [0,1].
    *
+   * \param tx                  [0,1] if tx (1) or rx (0)
    * \param which_dboard       [0,1] which daughterboard
-   *                            If this is a Tx daughterboard (d_tx=true), 
[0,1] -> [2,3]
-   *                            If this is a Rx daughterboard, select 0 or 1
+   *                            based on TX value, maps to:
+   *                                SLOT_TX_A = 0
+   *                                SLOT_RX_A = 1
+   *                                SLOT_TX_B = 2
+   *                                SLOT_RX_B = 3
    *
    * \return daughterboard id >= 0 if successful
    * \return -1 if no daugherboard
    * \return -2 if invalid EEPROM on daughterboard
    */
-  int daughterboard_id (int which_dboard) const { return d_dbid[2*(d_tx==true) 
+ which_dboard & 0x1]; }
+  int common_daughterboard_id (txrx_t tx, int which_dboard) const;
+  virtual int daughterboard_id (int which_dboard) const;
 
+  virtual long converter_rate() const = 0;
 
-  virtual long converter_rate() const { throw 0; } // throw something real 
-
   virtual bool set_pga (int which, double gain);
   bool set_rx_pga(int which, double gain);
   bool set_tx_pga(int which, double gain);
@@ -140,6 +148,7 @@
   double pga_rx (int which) const;
   double pga_tx (int which) const;
 
+
   /*!
    * \brief Return minimum legal PGA gain in dB.
    */
@@ -376,7 +385,6 @@
   std::string _read_spi (int optional_header, int enables, int format, int 
len);
 
 
-
   /*!
    * \brief Write direction register (output enables) for pins that go to 
daughterboard.
    *
@@ -392,34 +400,32 @@
    * without a very good reason.  Using this method incorrectly will
    * kill your USRP motherboard and/or daughterboard.
    */
-  bool _write_oe (int which_dboard, int value, int mask);
+  bool _common_write_oe (txrx_t tx, int which_dboard, int value, int mask);
+  virtual bool _write_oe (int which_dboard, int value, int mask);
 
   /*!
    * \brief Write daughterboard i/o pin value
    *
+   * \param tx                  [0, 1] if transmit (1) or receive (0)
    * \param which_dboard       [0,1] which d'board
    * \param value              value to write into register
    * \param mask               which bits of value to write into reg
    */
-  bool write_io (int which_dboard, int value, int mask);
+  bool common_write_io (txrx_t tx, int which_dboard, int value, int mask);
+  virtual bool write_io (int which_dboard, int value, int mask);
 
   /*!
    * \brief Read daughterboard i/o pin value
    *
+   * \param tx                 [0,1] if transmit (1) or receive (0)
    * \param which_dboard       [0,1] which d'board
    * \param value              output
    */
-  bool read_io (int which_dboard, int *value);
+  bool common_read_io (txrx_t tx, int which_dboard, int *value);
+  virtual bool read_io (int which_dboard, int *value);
+  virtual int  read_io (int which_dboard);
 
   /*!
-   * \brief Read daughterboard i/o pin value
-   *
-   * \param which_dboard       [0,1] which d'board
-   * \returns register value if successful, else READ_FAILED
-   */
-  int read_io (int which_dboard);
-
-  /*!
    * \brief Start data transfers.
    * Called in base class to derived class order.
    */
@@ -475,6 +481,12 @@
 
   std::vector<db_base_sptr> db(int which);
 
+  int daughterboard_id (int which_dboard) const;
+  bool _write_oe (int which_dboard, int value, int mask);
+  bool write_io (int which_dboard, int value, int mask);
+  bool read_io (int which_dboard, int *value);
+  int  read_io (int which_dboard);
+
   /*!
    * \brief invokes constructor, returns instance or 0 if trouble
    *
@@ -516,7 +528,7 @@
   // ACCESSORS
 
   //! sampling rate of A/D converter
-  virtual long converter_rate() const { return fpga_master_clock_freq(); } // 
64M
+  long converter_rate() const { return fpga_master_clock_freq(); } // 64M
   long adc_rate() const { return converter_rate(); }
   long adc_freq() const { return converter_rate(); }   //!< deprecated method 
name
 
@@ -661,6 +673,14 @@
 
   ~usrp_basic_tx ();
 
+  std::vector<db_base_sptr> db(int which);
+
+  int daughterboard_id (int which_dboard) const;
+  bool _write_oe (int which_dboard, int value, int mask);
+  bool write_io (int which_dboard, int value, int mask);
+  bool read_io (int which_dboard, int *value);
+  int  read_io (int which_dboard);
+
   /*!
    * \brief invokes constructor, returns instance or 0 if trouble
    *
@@ -708,7 +728,7 @@
   // ACCESSORS
 
   //! sampling rate of D/A converter
-  virtual long converter_rate() const { return fpga_master_clock_freq () * 2; 
} // 128M
+  long converter_rate() const { return fpga_master_clock_freq () * 2; } // 128M
   long dac_rate() const { return converter_rate(); }
   long dac_freq() const { return converter_rate(); }   //!< deprecated method 
name
 

Modified: 
gnuradio/branches/developers/trondeau/dbs/usrp/host/lib/legacy/usrp_standard.cc
===================================================================
--- 
gnuradio/branches/developers/trondeau/dbs/usrp/host/lib/legacy/usrp_standard.cc 
    2008-08-12 20:02:01 UTC (rev 9256)
+++ 
gnuradio/branches/developers/trondeau/dbs/usrp/host/lib/legacy/usrp_standard.cc 
    2008-08-12 20:02:35 UTC (rev 9257)
@@ -184,6 +184,8 @@
     set_rx_freq(i, 0);
     set_ddc_phase(i, 0);
   }
+
+  printf("usrp_standard_rx::usrp_standard_rx\n");
 }
 
 usrp_standard_rx::~usrp_standard_rx ()
@@ -400,7 +402,8 @@
 
 /*
 db_base_sptr 
-usrp_standard_rx::db(int which) const
+usrp_standard_rx::db(
+int which) const
 {
   if(which > 1) {
         throw std::invalid_argument("usrp_standard_tx::db which is not 0 or 
1");





reply via email to

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