commit-gnuradio
[Top][All Lists]
Advanced

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

[Commit-gnuradio] r7228 - gnuradio/branches/developers/jcorgan/t127/usrp


From: jcorgan
Subject: [Commit-gnuradio] r7228 - gnuradio/branches/developers/jcorgan/t127/usrpdb/src
Date: Tue, 18 Dec 2007 12:52:58 -0700 (MST)

Author: jcorgan
Date: 2007-12-18 12:52:58 -0700 (Tue, 18 Dec 2007)
New Revision: 7228

Modified:
   gnuradio/branches/developers/jcorgan/t127/usrpdb/src/qa_basic_rx.py
   gnuradio/branches/developers/jcorgan/t127/usrpdb/src/qa_basic_tx.py
   gnuradio/branches/developers/jcorgan/t127/usrpdb/src/qa_lfrx.py
   gnuradio/branches/developers/jcorgan/t127/usrpdb/src/qa_lftx.py
   gnuradio/branches/developers/jcorgan/t127/usrpdb/src/usrpdb_dbsrx.cc
   gnuradio/branches/developers/jcorgan/t127/usrpdb/src/usrpdb_dbsrx.h
   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
   gnuradio/branches/developers/jcorgan/t127/usrpdb/src/usrpdb_hwa_qa.i
Log:
Implemented dbsrx.

Modified: gnuradio/branches/developers/jcorgan/t127/usrpdb/src/qa_basic_rx.py
===================================================================
--- gnuradio/branches/developers/jcorgan/t127/usrpdb/src/qa_basic_rx.py 
2007-12-18 19:02:27 UTC (rev 7227)
+++ gnuradio/branches/developers/jcorgan/t127/usrpdb/src/qa_basic_rx.py 
2007-12-18 19:52:58 UTC (rev 7228)
@@ -43,18 +43,18 @@
        self.assertEqual(actual_baseband_freq, 0.0)
 
     def test_002_gain_range(self):
-       expected_range = (-20.0, 0, 0.2)
+       expected_range = (0.0, 20.0, 0.2)
        gain_range = self.db.gain_range()
        self.assertFloatTuplesAlmostEqual(gain_range, expected_range, 5)
 
     def test_003_set_gain(self):
-       self.db.set_gain(-10.0) 
-       self.assertEqual(self.hwa.adc_pga_gain(), -10.0)
+       self.db.set_gain(10.0)  
+       self.assertEqual(self.hwa.adc_pga_gain(), 10.0)
 
     # FIXME: disabled due to ticket:181
     def xtest_004_set_gain_bad(self):
        self.assertRaises(ValueError,
-           lambda: self.db.set_gain(10.0))     
+           lambda: self.db.set_gain(-10.0))
 
     def test_005_is_quadrature(self):
        self.assertFalse(self.db.is_quadrature())

Modified: gnuradio/branches/developers/jcorgan/t127/usrpdb/src/qa_basic_tx.py
===================================================================
--- gnuradio/branches/developers/jcorgan/t127/usrpdb/src/qa_basic_tx.py 
2007-12-18 19:02:27 UTC (rev 7227)
+++ gnuradio/branches/developers/jcorgan/t127/usrpdb/src/qa_basic_tx.py 
2007-12-18 19:52:58 UTC (rev 7228)
@@ -43,18 +43,18 @@
        self.assertEqual(actual_baseband_freq, 0.0)
 
     def test_002_gain_range(self):
-       expected_range = (-20.0, 0, 0.2)
+       expected_range = (0.0, 20.0, 0.2)
        gain_range = self.db.gain_range()
        self.assertFloatTuplesAlmostEqual(gain_range, expected_range, 5)
 
     def test_003_set_gain(self):
-       self.db.set_gain(-10.0) 
-       self.assertEqual(self.hwa.dac_pga_gain(), -10.0)
+       self.db.set_gain(10.0)  
+       self.assertEqual(self.hwa.dac_pga_gain(), 10.0)
 
     # FIXME: disabled due to ticket:181 problem
     def xtest_004_set_gain_bad(self):
        self.assertRaises(ValueError,
-           lambda: self.db.set_gain(10.0))     
+           lambda: self.db.set_gain(-10.0))
 
     def test_005_is_quadrature(self):
        self.assertTrue(self.db.is_quadrature())

Modified: gnuradio/branches/developers/jcorgan/t127/usrpdb/src/qa_lfrx.py
===================================================================
--- gnuradio/branches/developers/jcorgan/t127/usrpdb/src/qa_lfrx.py     
2007-12-18 19:02:27 UTC (rev 7227)
+++ gnuradio/branches/developers/jcorgan/t127/usrpdb/src/qa_lfrx.py     
2007-12-18 19:52:58 UTC (rev 7228)
@@ -40,7 +40,7 @@
 
     # Test inheritance from basic_tx
     def test_001_gain_range(self):
-       expected_range = (-20, 0, 0.2)
+       expected_range = (0.0, 20.0, 0.2)
        gain_range = self.db.gain_range()
        self.assertFloatTuplesAlmostEqual(gain_range, expected_range, 5)
 

Modified: gnuradio/branches/developers/jcorgan/t127/usrpdb/src/qa_lftx.py
===================================================================
--- gnuradio/branches/developers/jcorgan/t127/usrpdb/src/qa_lftx.py     
2007-12-18 19:02:27 UTC (rev 7227)
+++ gnuradio/branches/developers/jcorgan/t127/usrpdb/src/qa_lftx.py     
2007-12-18 19:52:58 UTC (rev 7228)
@@ -40,7 +40,7 @@
 
     # Test inheritance from basic_tx
     def test_001_gain_range(self):
-       expected_range = (-20, 0, 0.2)
+       expected_range = (0.0, 20.0, 0.2)
        gain_range = self.db.gain_range()
        self.assertFloatTuplesAlmostEqual(gain_range, expected_range, 5)
 

Modified: gnuradio/branches/developers/jcorgan/t127/usrpdb/src/usrpdb_dbsrx.cc
===================================================================
--- gnuradio/branches/developers/jcorgan/t127/usrpdb/src/usrpdb_dbsrx.cc        
2007-12-18 19:02:27 UTC (rev 7227)
+++ gnuradio/branches/developers/jcorgan/t127/usrpdb/src/usrpdb_dbsrx.cc        
2007-12-18 19:52:58 UTC (rev 7228)
@@ -26,8 +26,6 @@
 
 #include <usrpdb_dbsrx.h>
 #include <stdexcept>
-#include <iostream>
-#include <iomanip>
 #include <cmath>
 
 // i2c bus id, side A, side B
@@ -52,6 +50,7 @@
     d_dl(0),
     d_ade(0),
     d_adl(0),
+    d_gc1(0),
     d_gc2(31),
     d_diag(0)
 {
@@ -108,7 +107,11 @@
     case 2:
       write_reg(2, d_osc + (d_cp<<3) + (d_r_int<<5));
       break;
-      
+
+    case 3:
+      write_reg(3, d_fdac);
+      break;
+            
     case 4:
       write_reg(4, d_m + (d_dl<<5) + (d_ade<<6) + (d_adl<<7));
       break;
@@ -171,6 +174,37 @@
   send_reg(2);
 }
 
+void
+usrpdb_dbsrx::set_gc1(int gc1)
+{
+  assert(gc1 >= 0 && gc1 < 4096);
+  d_gc1 = gc1;
+  d_hwa->write_aux_dac(gc1);
+}
+
+void
+usrpdb_dbsrx::set_gc2(int gc2)
+{
+  assert(gc2 >= 0 && gc2 < 32);
+  d_gc2 = gc2;
+  send_reg(5);
+}
+
+void
+usrpdb_dbsrx::set_dl(int dl)
+{
+  assert(dl == 0 || dl == 1);
+  d_dl = dl;
+  send_reg(4);
+}
+
+void
+usrpdb_dbsrx::set_pga(float gain)
+{
+  assert(gain >= 0.0 && gain <= 20.0);
+  d_hwa->set_adc_pga(gain);
+}
+
 float
 usrpdb_dbsrx::set_freq(float target_freq)
 {
@@ -248,6 +282,7 @@
   set_osc(vco);
   int adc_val = 0;
   while(adc_val == 0 || adc_val == 7) { // Tuning voltage is pegged
+    // NOTE: might need to insert a delay here
     adc_val = read_status()[0]>>2;
     if (adc_val == 0) {
       if (vco <= 0)
@@ -292,6 +327,37 @@
   if (gain < 0 || gain > 104) {
     throw std::invalid_argument("gain value is out of range");
   }
+
+  int gc1=0, gc2=0, dl=0;
+
+  if (gain < 56.0) {
+    gc1 = (int)((-gain*1.85/56.0+2.6)*4096.0/3.3);
+    gain = 0.0;
+  }
+  else {
+    gc1 = 0;
+    gain -= 56.0;
+  }
+
+  if (gain < 24.0) {
+    gc2 = (int)round(31.0*(1-gain/24.0));
+    gain = 0.0;
+    
+  }
+  else {
+    gc2 = 0;
+    gain -= 24.0;
+  }
+
+  if (gain >= 4.58) {
+    dl = 1;
+    gain -= 4.58;
+  }
+
+  set_gc1(gc1);
+  set_gc2(gc2);
+  set_dl(dl);
+  set_pga(gain);
 }
 
 bool

Modified: gnuradio/branches/developers/jcorgan/t127/usrpdb/src/usrpdb_dbsrx.h
===================================================================
--- gnuradio/branches/developers/jcorgan/t127/usrpdb/src/usrpdb_dbsrx.h 
2007-12-18 19:02:27 UTC (rev 7227)
+++ gnuradio/branches/developers/jcorgan/t127/usrpdb/src/usrpdb_dbsrx.h 
2007-12-18 19:52:58 UTC (rev 7228)
@@ -38,6 +38,10 @@
   void set_n(int n);
   void set_osc(int osc);
   void set_cp(int cp);
+  void set_gc1(int gc1);
+  void set_gc2(int gc2);
+  void set_dl(int dl);
+  void set_pga(float gain);
   std::vector<unsigned char> read_status();
 
   char d_addr;
@@ -52,6 +56,7 @@
   int d_dl;
   int d_ade;
   int d_adl;
+  int d_gc1;
   int d_gc2;
   int d_diag;
 

Modified: gnuradio/branches/developers/jcorgan/t127/usrpdb/src/usrpdb_hwa.h
===================================================================
--- gnuradio/branches/developers/jcorgan/t127/usrpdb/src/usrpdb_hwa.h   
2007-12-18 19:02:27 UTC (rev 7227)
+++ gnuradio/branches/developers/jcorgan/t127/usrpdb/src/usrpdb_hwa.h   
2007-12-18 19:52:58 UTC (rev 7228)
@@ -51,6 +51,7 @@
   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;
 };
 
 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-18 19:02:27 UTC (rev 7227)
+++ gnuradio/branches/developers/jcorgan/t127/usrpdb/src/usrpdb_hwa.i   
2007-12-18 19:52:58 UTC (rev 7228)
@@ -53,4 +53,5 @@
   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;
 };

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-18 19:02:27 UTC (rev 7227)
+++ gnuradio/branches/developers/jcorgan/t127/usrpdb/src/usrpdb_hwa_qa.cc       
2007-12-18 19:52:58 UTC (rev 7228)
@@ -28,7 +28,7 @@
 #include <iostream>
 #include <iomanip>
 
-#define USRPDB_HWA_QA_DEBUG 1
+#define USRPDB_HWA_QA_DEBUG 0
 
 usrpdb_hwa_sptr 
 usrpdb_make_qa_hwa(int side)
@@ -82,14 +82,14 @@
 usrpdb_hwa_qa::dac_pga_min()
 {
   // mimic USRP1
-  return -20.0;
+  return 0.0;
 }
 
 float
 usrpdb_hwa_qa::dac_pga_max()
 {
   // mimic USRP1
-  return 0.0;
+  return 20.0;
 }
 
 float
@@ -117,14 +117,14 @@
 usrpdb_hwa_qa::adc_pga_min()
 {
   // mimic USRP1
-  return -20.0;
+  return 0.0;
 }
 
 float
 usrpdb_hwa_qa::adc_pga_max()
 {
   // mimic USRP1
-  return 0.0;
+  return 20.0;
 }
 
 float
@@ -185,10 +185,11 @@
 void
 usrpdb_hwa_qa::write_i2c(char addr, std::vector<unsigned char> seq)
 {
-  if (USRPDB_HWA_QA_DEBUG)
+#if USRPDB_HWA_QA_DEBUG
     std::cout << "usrpdb_hwa_qa: writing to I2C addr " << std::setbase(16) 
               << std::setw(2) << std::setfill('0') << (int)addr 
-              << ": " << seq << std::endl;
+              << ": " << seq << std::setbase(10) << std::endl;
+#endif
 }
 
 std::vector<unsigned char>
@@ -206,3 +207,11 @@
 
   return result;
 }
+
+void
+usrpdb_hwa_qa::write_aux_dac(int val)
+{
+  if (USRPDB_HWA_QA_DEBUG)
+    std::cout << "usrpdb_hwa_qa: writing AUX DAC 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-18 19:02:27 UTC (rev 7227)
+++ gnuradio/branches/developers/jcorgan/t127/usrpdb/src/usrpdb_hwa_qa.h        
2007-12-18 19:52:58 UTC (rev 7228)
@@ -65,6 +65,7 @@
   virtual float refclk_frequency();
   void write_i2c(char addr, std::vector<unsigned char> seq);
   std::vector<unsigned char> read_i2c(char addr, int len);
+  virtual void write_aux_dac(int val);
 };
 
 #endif /* INCLUDED_USRPDB_HWA_QA_H */

Modified: gnuradio/branches/developers/jcorgan/t127/usrpdb/src/usrpdb_hwa_qa.i
===================================================================
--- gnuradio/branches/developers/jcorgan/t127/usrpdb/src/usrpdb_hwa_qa.i        
2007-12-18 19:02:27 UTC (rev 7227)
+++ gnuradio/branches/developers/jcorgan/t127/usrpdb/src/usrpdb_hwa_qa.i        
2007-12-18 19:52:58 UTC (rev 7228)
@@ -55,4 +55,5 @@
   virtual float refclk_frequency();
   void write_i2c(char addr, std::vector<unsigned char> seq);
   std::vector<unsigned char> read_i2c(char addr, int len);
+  virtual void write_aux_dac(int val);
 };





reply via email to

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