commit-gnuradio
[Top][All Lists]
Advanced

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

[Commit-gnuradio] r7234 - in gnuradio/branches/developers/jcorgan/t127:


From: jcorgan
Subject: [Commit-gnuradio] r7234 - in gnuradio/branches/developers/jcorgan/t127: usrp/host/lib/legacy usrpdb/src
Date: Thu, 20 Dec 2007 11:52:32 -0700 (MST)

Author: jcorgan
Date: 2007-12-20 11:52:32 -0700 (Thu, 20 Dec 2007)
New Revision: 7234

Modified:
   gnuradio/branches/developers/jcorgan/t127/usrp/host/lib/legacy/usrp_basic.cc
   gnuradio/branches/developers/jcorgan/t127/usrp/host/lib/legacy/usrp_basic.h
   gnuradio/branches/developers/jcorgan/t127/usrp/host/lib/legacy/usrp_hwa_rx.cc
   gnuradio/branches/developers/jcorgan/t127/usrp/host/lib/legacy/usrp_hwa_rx.h
   gnuradio/branches/developers/jcorgan/t127/usrpdb/src/usrpdb_dbsrx.cc
   gnuradio/branches/developers/jcorgan/t127/usrpdb/src/usrpdb_hwa.h
   gnuradio/branches/developers/jcorgan/t127/usrpdb/src/usrpdb_hwa.i
   gnuradio/branches/developers/jcorgan/t127/usrpdb/src/usrpdb_hwa_qa.cc
   gnuradio/branches/developers/jcorgan/t127/usrpdb/src/usrpdb_hwa_qa.h
Log:
Work in progress.

Modified: 
gnuradio/branches/developers/jcorgan/t127/usrp/host/lib/legacy/usrp_basic.cc
===================================================================
--- 
gnuradio/branches/developers/jcorgan/t127/usrp/host/lib/legacy/usrp_basic.cc    
    2007-12-20 16:36:08 UTC (rev 7233)
+++ 
gnuradio/branches/developers/jcorgan/t127/usrp/host/lib/legacy/usrp_basic.cc    
    2007-12-20 18:52:32 UTC (rev 7234)
@@ -34,6 +34,7 @@
 #include <assert.h>
 #include <math.h>
 #include <ad9862.h>
+#include <usrp_hwa_rx.h>
 
 using namespace ad9862;
 
@@ -833,6 +834,12 @@
                         (d_fpga_shadows[FR_DC_OFFSET_CL_EN] & ~mask) | (bits & 
mask));
 }
 
+usrpdb_hwa_sptr
+usrp_basic_rx::hwa(int side)
+{
+    return usrp_make_hwa_rx(this, side);
+}
+
 ////////////////////////////////////////////////////////////////
 //
 //                        usrp_basic_tx

Modified: 
gnuradio/branches/developers/jcorgan/t127/usrp/host/lib/legacy/usrp_basic.h
===================================================================
--- gnuradio/branches/developers/jcorgan/t127/usrp/host/lib/legacy/usrp_basic.h 
2007-12-20 16:36:08 UTC (rev 7233)
+++ gnuradio/branches/developers/jcorgan/t127/usrp/host/lib/legacy/usrp_basic.h 
2007-12-20 18:52:32 UTC (rev 7234)
@@ -40,6 +40,7 @@
 #define INCLUDED_USRP_BASIC_H
 
 #include <usrp_slots.h>
+#include <usrpdb_hwa.h>
 #include <string>
 
 struct usb_dev_handle;
@@ -311,7 +312,7 @@
   bool stop ();
 };
 
-/*!
+/*!
  * \brief class for accessing the receive side of the USRP
  */
 class usrp_basic_rx : public usrp_basic 
@@ -548,9 +549,11 @@
   // called in base class to derived class order
   bool start ();
   bool stop ();
+
+  usrpdb_hwa_sptr hwa(int side);
 };
 
-/*!
+ /*!
  * \brief class for accessing the transmit side of the USRP
  */
 class usrp_basic_tx : public usrp_basic 

Modified: 
gnuradio/branches/developers/jcorgan/t127/usrp/host/lib/legacy/usrp_hwa_rx.cc
===================================================================
--- 
gnuradio/branches/developers/jcorgan/t127/usrp/host/lib/legacy/usrp_hwa_rx.cc   
    2007-12-20 16:36:08 UTC (rev 7233)
+++ 
gnuradio/branches/developers/jcorgan/t127/usrp/host/lib/legacy/usrp_hwa_rx.cc   
    2007-12-20 18:52:32 UTC (rev 7234)
@@ -25,21 +25,32 @@
 #endif
 
 #include <usrp_hwa_rx.h>
+#include <fpga_regs_standard.h>
 #include <stdexcept>
 #include <iostream>
 
-#define USRP_HWA_RX_DEBUG 1
+#define bmUSRP1_REFCLK_ENA   0x80
+#define bmUSRP1_REFCLK_DIV   0x7F
+#define USRP1_REFCLK_VAL(ena,div) \
+  ((ena?bmUSRP1_REFCLK_ENA:0) |   \
+   (div&bmUSRP1_REFCLK_DIV))
 
 usrpdb_hwa_sptr 
-usrp_make_hwa(usrp_basic_rx *u, int side)
+usrp_make_hwa_rx(usrp_basic_rx *u, int side)
 {
   return usrpdb_hwa_sptr(new usrp_hwa_rx(u, side));
 }
 
 usrp_hwa_rx::usrp_hwa_rx(usrp_basic_rx *u, int side)
   : d_u(u),
-    d_side(side)
+    d_side(side),
+    d_refclk_enable(false),
+    d_refclk_divisor(1)
 {
+  if (side == 0)
+    d_refclk_reg = FR_RX_A_REFCLK;
+  else
+    d_refclk_reg = FR_RX_B_REFCLK;
 }
 
 usrp_hwa_rx::~usrp_hwa_rx()
@@ -87,9 +98,6 @@
 void
 usrp_hwa_rx::set_pga(float gain)
 {
-  if (USRP_HWA_RX_DEBUG)
-    std::cout << "usrp_hwa_rx: setting ADC PGA gain to " << gain << std::endl;
-
   bool ok = false;
   ok &= d_u->set_pga(2*d_side+0, gain);
   ok &= d_u->set_pga(2*d_side+1, gain);
@@ -100,9 +108,6 @@
 void
 usrp_hwa_rx::bypass_adc_buffers(bool bypass)
 {
-  if (USRP_HWA_RX_DEBUG)
-    std::cout << "usrp_hwa_rx: bypassing ADC buffers: " << bypass << std::endl;
-
   bool ok = false;
   ok &= d_u->set_adc_buffer_bypass(2*d_side+0, bypass);
   ok &= d_u->set_adc_buffer_bypass(2*d_side+1, bypass);
@@ -113,34 +118,56 @@
 void
 usrp_hwa_rx::write_oe(unsigned short mask, unsigned short val)
 {
+  if (!d_u->_write_oe(d_side, mask, val))
+    throw std::runtime_error("unable to write output enable");
 }
 
 void
 usrp_hwa_rx::set_refclk_divisor(int divisor)
 {
+  d_refclk_divisor = divisor;
+  write_fpga_reg(d_refclk_reg, USRP1_REFCLK_VAL(d_refclk_enable, 
d_refclk_divisor));
 }
 
 void
 usrp_hwa_rx::enable_refclk(bool enable)
 {
+  d_refclk_enable = enable;
+  write_fpga_reg(d_refclk_reg, USRP1_REFCLK_VAL(d_refclk_enable, 
d_refclk_divisor));
 }
 
 float
 usrp_hwa_rx::refclk_frequency()
 {
+  return fpga_master_clock_freq()/d_refclk_divisor;
 }
 
 void
 usrp_hwa_rx::write_i2c(char addr, std::vector<unsigned char> seq)
 {
+  std::string s(seq.begin(), seq.end());
+  d_u->write_i2c(addr, s);
 }
 
 std::vector<unsigned char>
 usrp_hwa_rx::read_i2c(char addr, int len)
 {
+  std::string s = d_u->read_i2c(addr, len);
+  return std::vector<unsigned char>(s.begin(), s.end());
 }
 
 void
-usrp_hwa_rx::write_aux_dac(int val)
+usrp_hwa_rx::write_aux_dac(int which_adc, int val)
 {
+  bool ok = d_u->write_aux_dac(2*d_side+1, which_adc, val);
+  if (!ok)
+    throw std::runtime_error("unable to write AUX DAC");
 }
+
+void
+usrp_hwa_rx::write_fpga_reg(int regno, int val)
+{
+  bool ok = d_u->_write_fpga_reg(regno, val);
+  if (!ok)
+    throw std::runtime_error("unable to write FPGA register");
+}

Modified: 
gnuradio/branches/developers/jcorgan/t127/usrp/host/lib/legacy/usrp_hwa_rx.h
===================================================================
--- 
gnuradio/branches/developers/jcorgan/t127/usrp/host/lib/legacy/usrp_hwa_rx.h    
    2007-12-20 16:36:08 UTC (rev 7233)
+++ 
gnuradio/branches/developers/jcorgan/t127/usrp/host/lib/legacy/usrp_hwa_rx.h    
    2007-12-20 18:52:32 UTC (rev 7234)
@@ -26,37 +26,39 @@
 #include <usrpdb_hwa.h>
 #include "usrp_basic.h"
 
-usrpdb_hwa_sptr usrp_make_hwa(usrp_basic_rx *u, int side);
+usrpdb_hwa_sptr usrp_make_hwa_rx(usrp_basic_rx *u, int side);
 
 class usrp_hwa_rx : public usrpdb_hwa
 {
 private:
   usrp_hwa_rx(usrp_basic_rx *u, int side);
-  friend usrpdb_hwa_sptr usrp_make_hwa(usrp_basic_rx *u, int side);
+  friend usrpdb_hwa_sptr usrp_make_hwa_rx(usrp_basic_rx *u, int side);
 
   usrp_basic_rx *d_u;
-  int d_side;
+  int  d_side;           // 0 = A, 1 = B
+  bool d_refclk_enable;
+  int  d_refclk_divisor;
+  int  d_refclk_reg;
 
 public:
-  virtual ~usrp_hwa_rx();
+  ~usrp_hwa_rx();
 
-  virtual unsigned int side();
-  virtual float fpga_master_clock_freq();
-  virtual float pga_gain();
-  virtual float pga_min();
-  virtual float pga_max();
-  virtual float pga_db_per_step();
-  virtual void set_pga(float gain);
-  virtual void bypass_adc_buffers(bool bypass);
-  virtual void write_oe(unsigned short mask, unsigned short val);
-  virtual void set_refclk_divisor(int divisor);
-  virtual void enable_refclk(bool enable);
-  virtual float refclk_frequency();
-  virtual void write_i2c(char addr, std::vector<unsigned char> seq);
-  virtual std::vector<unsigned char> read_i2c(char addr, int len);
-  virtual void write_aux_dac(int val);
+  unsigned int side();
+  float fpga_master_clock_freq();
+  float pga_gain();
+  float pga_min();
+  float pga_max();
+  float pga_db_per_step();
+  void set_pga(float gain);
+  void bypass_adc_buffers(bool bypass);
+  void write_oe(unsigned short mask, unsigned short val);
+  void set_refclk_divisor(int divisor);
+  void enable_refclk(bool enable);
+  float refclk_frequency();
+  void write_i2c(char addr, std::vector<unsigned char> seq);
+  std::vector<unsigned char> read_i2c(char addr, int len);
+  void write_aux_dac(int which_adc, int val);
+  void write_fpga_reg(int regno, int val);
 };
 
-typedef boost::shared_ptr<usrpdb_hwa> usrpdb_hwa_sptr;
-
 #endif /* INCLUDED_USRPDB_HWA_H */

Modified: gnuradio/branches/developers/jcorgan/t127/usrpdb/src/usrpdb_dbsrx.cc
===================================================================
--- gnuradio/branches/developers/jcorgan/t127/usrpdb/src/usrpdb_dbsrx.cc        
2007-12-20 16:36:08 UTC (rev 7233)
+++ gnuradio/branches/developers/jcorgan/t127/usrpdb/src/usrpdb_dbsrx.cc        
2007-12-20 18:52:32 UTC (rev 7234)
@@ -179,7 +179,7 @@
 {
   assert(gc1 >= 0 && gc1 < 4096);
   d_gc1 = gc1;
-  d_hwa->write_aux_dac(gc1);
+  d_hwa->write_aux_dac(0, gc1);
 }
 
 void

Modified: gnuradio/branches/developers/jcorgan/t127/usrpdb/src/usrpdb_hwa.h
===================================================================
--- gnuradio/branches/developers/jcorgan/t127/usrpdb/src/usrpdb_hwa.h   
2007-12-20 16:36:08 UTC (rev 7233)
+++ gnuradio/branches/developers/jcorgan/t127/usrpdb/src/usrpdb_hwa.h   
2007-12-20 18:52:32 UTC (rev 7234)
@@ -46,7 +46,8 @@
   virtual float refclk_frequency() = 0;
   virtual void write_i2c(char addr, std::vector<unsigned char> seq) = 0;
   virtual std::vector<unsigned char> read_i2c(char addr, int len) = 0;
-  virtual void write_aux_dac(int val) = 0;
+  virtual void write_aux_dac(int which_adc, int val) = 0;
+  virtual void write_fpga_reg(int regno, int val) = 0;
 };
 
 typedef boost::shared_ptr<usrpdb_hwa> usrpdb_hwa_sptr;

Modified: gnuradio/branches/developers/jcorgan/t127/usrpdb/src/usrpdb_hwa.i
===================================================================
--- gnuradio/branches/developers/jcorgan/t127/usrpdb/src/usrpdb_hwa.i   
2007-12-20 16:36:08 UTC (rev 7233)
+++ gnuradio/branches/developers/jcorgan/t127/usrpdb/src/usrpdb_hwa.i   
2007-12-20 18:52:32 UTC (rev 7234)
@@ -48,5 +48,6 @@
   virtual float refclk_frequency();
   virtual void write_i2c(char addr, std::vector<unsigned char> seq);
   virtual std::vector<unsigned char> read_i2c(char addr, int len);
-  virtual void write_aux_dac(int val);
+  virtual void write_aux_dac(int which_adc, int val);
+  virtual void write_fpga_reg(int regno, int val);
 };

Modified: gnuradio/branches/developers/jcorgan/t127/usrpdb/src/usrpdb_hwa_qa.cc
===================================================================
--- gnuradio/branches/developers/jcorgan/t127/usrpdb/src/usrpdb_hwa_qa.cc       
2007-12-20 16:36:08 UTC (rev 7233)
+++ gnuradio/branches/developers/jcorgan/t127/usrpdb/src/usrpdb_hwa_qa.cc       
2007-12-20 18:52:32 UTC (rev 7234)
@@ -173,9 +173,17 @@
 }
 
 void
-usrpdb_hwa_qa::write_aux_dac(int val)
+usrpdb_hwa_qa::write_aux_dac(int which_adc, int val)
 {
   if (USRPDB_HWA_QA_DEBUG)
-    std::cout << "usrpdb_hwa_qa: writing AUX DAC with: " << val << std::endl; 
+    std::cout << "usrpdb_hwa_qa: writing AUX DAC " << which_adc 
+             << " with: " << val << std::endl; 
 }
 
+void
+usrpdb_hwa_qa::write_fpga_reg(int regno, int val)
+{
+  if (USRPDB_HWA_QA_DEBUG)
+    std::cout << "usrpdb_hwa_qa: writing FPGA reg " << regno 
+              << " with " << val << std::endl; 
+}

Modified: gnuradio/branches/developers/jcorgan/t127/usrpdb/src/usrpdb_hwa_qa.h
===================================================================
--- gnuradio/branches/developers/jcorgan/t127/usrpdb/src/usrpdb_hwa_qa.h        
2007-12-20 16:36:08 UTC (rev 7233)
+++ gnuradio/branches/developers/jcorgan/t127/usrpdb/src/usrpdb_hwa_qa.h        
2007-12-20 18:52:32 UTC (rev 7234)
@@ -59,7 +59,8 @@
   float refclk_frequency();
   void write_i2c(char addr, std::vector<unsigned char> seq);
   std::vector<unsigned char> read_i2c(char addr, int len);
-  void write_aux_dac(int val);
+  void write_aux_dac(int which_adc, int val);
+  void write_fpga_reg(int regno, int val);
 };
 
 #endif /* INCLUDED_USRPDB_HWA_QA_H */





reply via email to

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