Clean up for work-in-progress
authorJohnathan Corgan <jcorgan@corganenterprises.com>
Wed, 7 Oct 2009 00:50:59 +0000 (17:50 -0700)
committerJohnathan Corgan <jcorgan@corganenterprises.com>
Wed, 7 Oct 2009 00:50:59 +0000 (17:50 -0700)
Copyright updates
Trailing whitespace cleanup
Move private headers out of install
Use standard include guards
Code cleanup

13 files changed:
usrp/host/apps/burn-db-eeprom
usrp/host/include/usrp/Makefile.am
usrp/host/include/usrp/db_wbxng.h
usrp/host/include/usrp/db_wbxng_adf4350.h [deleted file]
usrp/host/include/usrp/db_wbxng_adf4350_regs.h [deleted file]
usrp/host/lib/Makefile.am
usrp/host/lib/db_boards.cc
usrp/host/lib/db_wbxng.cc
usrp/host/lib/db_wbxng_adf4350.cc
usrp/host/lib/db_wbxng_adf4350.h [new file with mode: 0644]
usrp/host/lib/db_wbxng_adf4350_regs.cc
usrp/host/lib/db_wbxng_adf4350_regs.h [new file with mode: 0644]
usrp/host/lib/usrp_dbid.dat

index 195c4e897c6874cdb870e6fd4d03c6eb4c17d425..7ff1e973698c5fe453d427d53a3c6b47eb28fbbf 100755 (executable)
@@ -1,24 +1,24 @@
 #!/usr/bin/env python
 #
-# Copyright 2005,2007 Free Software Foundation, Inc.
-# 
+# Copyright 2005,2007,2009 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 version 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.
-# 
+#
 
 from usrpm.usrp_prims import *
 from optparse import OptionParser
@@ -105,11 +105,11 @@ def init_eeprom(u, slot_name, force, dbid, oe):
     if not e:
         print "%s: no d'board, skipped" % (slot_name,)
         return True
-    
+
     if not force and (sum (map (ord, e)) & 0xff) == 0 and ord (e[0]) == 0xDB:
         print "%s: already initialized, skipped" % (slot_name,)
         return True
-        
+
     if not write_dboard_eeprom (u, i2c_addr, dbid, oe):
         print "%s: failed to write d'board EEPROM" % (slot_name,)
         return False
@@ -169,4 +169,4 @@ and at least one side using -A and/or -B."""
 
 if __name__ == "__main__":
     main ()
-    
+
index 7c868e061564f16e5320df572b8f30c77a391878..cfce514438397475c08cdf79d20db5140d4a8c11 100644 (file)
@@ -1,23 +1,23 @@
 #
 # Copyright 2009 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 version 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 $(top_srcdir)/Makefile.common
 
@@ -32,9 +32,7 @@ usrpinclude_HEADERS = \
        db_flexrf.h \
        db_flexrf_mimo.h \
        db_tv_rx.h \
-       db_tv_rx_mimo.h \
-       db_wbxng_adf4350.h \
-       db_wbxng_adf4350_regs.h \
+       db_tv_rx_mimo.h \
        db_wbxng.h \
        db_xcvr2450.h \
        libusb_types.h \
index fb5c8da7138b3921043539fa1e02d068f5dc0bba..2158face2e77eb15077ccaf0f61254f3938b4bfb 100644 (file)
@@ -1,33 +1,30 @@
 /* -*- c++ -*- */
 //
-// Copyright 2008,2009 Free Software Foundation, Inc.
-// 
+// Copyright 2009 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_WBXNG_H
-#define DB_WBXNG_H
+#ifndef INCLUDED_DB_WBXNG_H
+#define INCLUDED_DB_WBXNG_H
 
 #include <usrp/db_base.h>
 #include <cmath>
 
-//debug_using_gui = true                // Must be set to True or False
-#define debug_using_gui false           // Must be set to True or False
-
 class adf4350;
 
 class wbxng_base : public db_base
@@ -43,11 +40,6 @@ public:
   double freq_max();
 
 protected:
-  void _write_all(int R, int control, int N);
-  void _write_control(int control);
-  void _write_R(int R);
-  void _write_N(int N);
-  void _write_it(int v);
   bool _lock_detect();
 
   //virtual bool _compute_regs(double freq, int &retR, int &retcontrol, int &retN, double &retfreq);
@@ -80,8 +72,6 @@ public:
   wbxng_base_tx(usrp_basic_sptr usrp, int which, int _power_on=0);
   ~wbxng_base_tx();
 
-  //*** TODO *** Fix comment
-  // All RFX tx d'boards have fixed gain
   float gain_min();
   float gain_max();
   float gain_db_per_step();
@@ -100,12 +90,11 @@ protected:
 public:
   wbxng_base_rx(usrp_basic_sptr usrp, int which, int _power_on=0);
   ~wbxng_base_rx();
-    
+
   bool set_auto_tr(bool on);
   bool select_rx_antenna(int which_antenna);
   bool select_rx_antenna(const std::string &which_antenna);
   bool set_gain(float gain);
-
 };
 
 // ----------------------------------------------------------------
@@ -115,9 +104,6 @@ class db_wbxng_tx : public wbxng_base_tx
  public:
   db_wbxng_tx(usrp_basic_sptr usrp, int which);
   ~db_wbxng_tx();
-
-  // Wrapper calls to d_common functions
-  //bool _compute_regs(double freq, int &retR, int &retcontrol, int &retN, double &retfreq);
 };
 
 class db_wbxng_rx : public wbxng_base_rx
@@ -125,14 +111,11 @@ class db_wbxng_rx : public wbxng_base_rx
 public:
   db_wbxng_rx(usrp_basic_sptr usrp, int which);
   ~db_wbxng_rx();
-  
+
   float gain_min();
   float gain_max();
   float gain_db_per_step();
   bool i_and_q_swapped();
-
-  //bool _compute_regs(double freq, int &retR, int &retcontrol, int &retN, double &retfreq);
 };
 
-
-#endif
+#endif /* INCLUDED_DB_WBXNG_H */
diff --git a/usrp/host/include/usrp/db_wbxng_adf4350.h b/usrp/host/include/usrp/db_wbxng_adf4350.h
deleted file mode 100644 (file)
index d7b8dd9..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Copyright 2009 Ettus Research LLC
- */
-
-#ifndef ADF4350_H
-#define ADF4350_H
-
-#include <usrp/db_wbxng_adf4350_regs.h>
-#include <usrp/db_base.h>
-#include <stdint.h>
-
-typedef uint64_t freq_t;
-class adf4350_regs;
-
-class adf4350
-{
-public:
-    adf4350(usrp_basic_sptr _usrp, int _which, int _spi_enable);
-    ~adf4350();
-    void _update();
-    bool _get_locked();
-    void _enable(bool enable);
-    void _write(uint8_t addr, uint32_t data);
-    bool _set_freq(freq_t freq);
-    freq_t _get_freq();
-    freq_t _get_max_freq();
-    freq_t _get_min_freq();
-
-protected:
-    usrp_basic_sptr d_usrp;
-    int d_which;
-    int d_spi_enable;
-    int d_spi_format;
-    adf4350_regs *d_regs;
-};
-
-#endif /* ADF4350_H */
diff --git a/usrp/host/include/usrp/db_wbxng_adf4350_regs.h b/usrp/host/include/usrp/db_wbxng_adf4350_regs.h
deleted file mode 100644 (file)
index 6a5b77a..0000000
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Copyright 2009 Ettus Research LLC
- */
-
-#ifndef ADF4350_REGS_H
-#define ADF4350_REGS_H
-
-#include <usrp/db_wbxng_adf4350.h>
-#include <usrp/db_base.h>
-#include <stdint.h>
-
-class adf4350;
-
-class adf4350_regs
-{
-public:
-    adf4350_regs(adf4350* _adf4350);
-    ~adf4350_regs();
-
-    adf4350* d_adf4350;
-
-    uint32_t _reg_shift(uint32_t data, uint32_t shift);
-    void _load_register(uint8_t addr);
-
-    /* reg 0 */
-    uint16_t d_int;
-    uint16_t d_frac;
-    /* reg 1 */
-    static const uint8_t s_prescaler;
-    static const uint16_t s_phase;
-    uint16_t d_mod;
-    /* reg 2 */
-    static const uint8_t s_low_noise_and_low_spur_modes;
-    static const uint8_t s_muxout;
-    static const uint8_t s_reference_doubler;
-    static const uint8_t s_rdiv2;
-    uint16_t d_10_bit_r_counter;
-    static const uint8_t s_double_buff;
-    static const uint8_t s_charge_pump_setting;
-    static const uint8_t s_ldf;
-    static const uint8_t s_ldp;
-    static const uint8_t s_pd_polarity;
-    static const uint8_t s_power_down;
-    static const uint8_t s_cp_three_state;
-    static const uint8_t s_counter_reset;
-    /* reg 3 */
-    static const uint8_t s_csr;
-    static const uint8_t s_clk_div_mode;
-    static const uint16_t s_12_bit_clock_divider_value;
-    /* reg 4 */
-    static const uint8_t s_feedback_select;
-    uint8_t d_divider_select;
-    uint8_t d_8_bit_band_select_clock_divider_value;
-    static const uint8_t s_vco_power_down;
-    static const uint8_t s_mtld;
-    static const uint8_t s_aux_output_select;
-    static const uint8_t s_aux_output_enable;
-    static const uint8_t s_aux_output_power;
-    static const uint8_t s_rf_output_enable;
-    static const uint8_t s_output_power;
-    /* reg 5 */
-    static const uint8_t s_ld_pin_mode;
-};
-
-#endif /* ADF4350_REGS_H */
index 13f25d69be1b03da3c79a75a1e86f6316865bb5a..72312ebbb37b8a8d2f8b70c558d06f4d2d17cc19 100644 (file)
@@ -1,22 +1,22 @@
 #
 #  USRP - Universal Software Radio Peripheral
-# 
+#
 #  Copyright (C) 2003,2004,2006,2007,2008,2009 Free Software Foundation, Inc.
-# 
+#
 #  This program 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 version 3 of the License, or
 #  (at your option) any later version.
-# 
+#
 #  This program 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 this program; if not, write to the Free Software
 #  Foundation, Inc., 51 Franklin Street, Boston, MA  02110-1301  USA
-# 
+#
 
 include $(top_srcdir)/Makefile.common
 
@@ -168,6 +168,8 @@ noinst_HEADERS =                    \
        db_base_impl.h                  \
        db_boards.h                     \
        db_util.h                       \
+       db_wbxng_adf4350.h              \
+       db_wbxng_adf4350_regs.h         \
        fusb.h                          \
        fusb_darwin.h                   \
        fusb_generic.h                  \
index 53304bd1aa7385dc72bd6824f0ef323e06aaad20..590d8132d152f02b368c6ee028cf6f28e539d2c8 100644 (file)
@@ -1,19 +1,19 @@
 /* -*- c++ -*- */
 //
 // Copyright 2008,2009 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,
@@ -64,7 +64,7 @@ instantiate_dbs(int dbid, usrp_basic_sptr usrp, int which_side)
     db.push_back(db_base_sptr(new db_lf_rx(usrp, which_side, 1)));
     db.push_back(db_base_sptr(new db_lf_rx(usrp, which_side, 2)));
     break;
-    
+
   case(USRP_DBID_DBS_RX):
     db.push_back(db_base_sptr(new db_dbs_rx(usrp, which_side)));
     break;
@@ -185,7 +185,7 @@ instantiate_dbs(int dbid, usrp_basic_sptr usrp, int which_side)
   case(USRP_DBID_XCVR2450_RX):
     db.push_back(db_base_sptr(new db_xcvr2450_rx(usrp, which_side)));
     break;
-  
+
 #if 0  // FIXME wbx doesn't compile
   case(USRP_DBID_WBX_LO_TX):
     db.push_back(db_base_sptr(new db_wbx_lo_tx(usrp, which_side)));
@@ -218,7 +218,7 @@ instantiate_dbs(int dbid, usrp_basic_sptr usrp, int which_side)
       db.push_back(db_base_sptr(new db_basic_rx(usrp, which_side, 1)));
     }
     break;
-  
+
   case(-2):
   default:
     if (boost::dynamic_pointer_cast<usrp_basic_tx>(usrp)){
index 0dd8b0d38e4059fb160265ee27fce6de4f2a3cff..c23fc47edf290b2310b862cd37b4cf2aaa6b4bfc 100644 (file)
@@ -1,25 +1,25 @@
 //
-// Copyright 2008 Free Software Foundation, Inc.
-// 
+// Copyright 2008,2009 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 <usrp/db_wbxng.h>
-#include <usrp/db_wbxng_adf4350.h>
+#include "db_wbxng_adf4350.h"
 #include <db_base_impl.h>
 #include <stdio.h>
 
@@ -61,143 +61,8 @@ wbxng_base::wbxng_base(usrp_basic_sptr _usrp, int which, int _power_on)
 
 wbxng_base::~wbxng_base()
 {
-  delete d_common;
-}
-
-void
-wbxng_base::_write_all(int R, int control, int N)
-{
-  /*
-    Write R counter latch, control latch and N counter latch to VCO.
-    
-    Adds 10ms delay between writing control and N if this is first call.
-    This is the required power-up sequence.
-    
-    @param R: 24-bit R counter latch
-    @type R: int
-    @param control: 24-bit control latch
-    @type control: int
-    @param N: 24-bit N counter latch
-    @type N: int
-  */
-  timespec t;
-  t.tv_sec = 0;
-  t.tv_nsec = 10000000;
-
-  /*
-  _write_R(R);
-  _write_control(control);
-  if(d_first) {
-    //time.sleep(0.010);
-    nanosleep(&t, NULL);
-    d_first = false;
-  }
-  _write_N(N);
-  */
-}
-
-void
-wbxng_base::_write_control(int control)
-{
-  //_write_it((control & ~0x3) | 0);
-}
-
-void
-wbxng_base::_write_R(int R)
-{
-  //_write_it((R & ~0x3) | 1);
-}
-
-void
-wbxng_base::_write_N(int N)
-{
-  //_write_it((N & ~0x3) | 2);
-}
-
-void
-wbxng_base::_write_it(int v)
-{
-  char s[3];
-  s[0] = (char)((v >> 16) & 0xff);
-  s[1] = (char)((v >>  8) & 0xff);
-  s[2] = (char)(v & 0xff);
-  std::string str(s, 3);
-  //usrp()->_write_spi(0, d_spi_enable, d_spi_format, str);
-}
-        
-bool
-wbxng_base::_lock_detect()
-{
-  /*
-    @returns: the value of the VCO/PLL lock detect bit.
-    @rtype: 0 or 1
-  */
-  
-  if(d_common->_get_locked()){
-    return true;
-  }
-  else {      // Give it a second chance
-    return false;
-    /*
-    // FIXME: make portable sleep
-    timespec t;
-    t.tv_sec = 0;
-    t.tv_nsec = 100000000;
-    nanosleep(&t, NULL);
-    
-    if(usrp()->read_io(d_which) & PLL_LOCK_DETECT) {
-      return true;
-    }
-    else {
-      return false;
-    }
-    */
-  }
-  throw std::runtime_error("_lock_detect called from wbxng_base\n");
-}
-
-/*
-bool
-wbxng_base::_compute_regs(double freq, int &retR, int &retcontrol,
-                          int &retN, double &retfreq)
-{
-  **COMMENT**
-    Determine values of R, control, and N registers, along with actual freq.
-    
-    @param freq: target frequency in Hz
-    @type freq: float
-    @returns: (R, control, N, actual_freq)
-    @rtype: tuple(int, int, int, float)
-    
-    Override this in derived classes.
-  **COMMENT**
-  
-  //raise NotImplementedError;
-  throw std::runtime_error("_compute_regs called from wbxng_base\n");
-}
-*/
-
-int
-wbxng_base::_compute_control_reg()
-{
-  throw std::runtime_error("_compute_control_reg called from wbxng_base\n");
-  //return d_common->_compute_control_reg();
-}
-
-int
-wbxng_base::_refclk_divisor()
-{
-  throw std::runtime_error("_refclk_divisor called from wbxng_base\n");
-  //return d_common->_refclk_divisor();
-}
-
-double
-wbxng_base::_refclk_freq()
-{
-  throw std::runtime_error("_refclk_divisor called from wbxng_base\n");
-  // *** TODO *** Magic Number 64e6?
-  //return 64e6/_refclk_divisor();
+  if (d_common)
+    delete d_common;
 }
 
 struct freq_result_t
@@ -220,27 +85,17 @@ wbxng_base::set_freq(double freq)
   t.tv_nsec = 10000000;
   nanosleep(&t, NULL);
 
-  fprintf(stderr,"Setting WBXNG frequency, requested %d, obtained %f, lock_detect %d\n", 
+  fprintf(stderr,"Setting WBXNG frequency, requested %d, obtained %f, lock_detect %d\n",
           int_freq, freq_result, _lock_detect());
 
+  // FIXME
   // 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
   // FPGA's DC removal loop's time constant.  We were seeing a
   // problem when running with discontinuous transmission.
   // Offsetting the LO made the problem go away.
   //freq += d_lo_offset;
-  
-  //int R, control, N;
-  //double actual_freq;
-  //_compute_regs(freq, R, control, N, actual_freq);
-
-  //if(R==0) {
-  //  return args;
-  //}
-   
-  //_write_all(R, control, N);
-  //args.ok = _lock_detect();
-  //args.baseband_freq = actual_freq;
+
   return args;
 }
 
@@ -263,7 +118,7 @@ wbxng_base::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 true;
@@ -290,7 +145,7 @@ wbxng_base_tx::wbxng_base_tx(usrp_basic_sptr _usrp, int which, int _power_on)
     @param usrp: instance of usrp.sink_c
     @param which: 0 or 1 corresponding to side TX_A or TX_B respectively.
   */
-  
+
   if(which == 0) {
     d_spi_enable = SPI_ENABLE_TX_A;
   }
@@ -299,11 +154,11 @@ wbxng_base_tx::wbxng_base_tx(usrp_basic_sptr _usrp, int which, int _power_on)
   }
 
   d_common = new adf4350(_usrp, d_which, d_spi_enable);
-  
-  // power up the transmit side, but don't enable the mixer
+
+  // FIXME: power up the transmit side, but don't enable the mixer
   usrp()->_write_oe(d_which,(RX_TXN|TXMOD_EN|ENABLE_33|ENABLE_5), (RX_TXN|TXMOD_EN|ENABLE_33|ENABLE_5));
   usrp()->write_io(d_which, (power_on()|RX_TXN|TXMOD_EN|ENABLE_33|ENABLE_5), (RX_TXN|TXMOD_EN|ENABLE_33|ENABLE_5));
-  fprintf(stderr,"Setting WBXNG TXMOD on"); 
+  fprintf(stderr,"Setting WBXNG TXMOD on");
   //set_lo_offset(4e6);
 
   set_gain((gain_min() + gain_max()) / 2.0);  // initialize gain
@@ -329,7 +184,7 @@ wbxng_base_tx::shutdown()
 
     // Power down VCO/PLL
     d_common->_enable(false);
-  
+
     /*
     _write_control(_compute_control_reg());
     */
@@ -396,11 +251,11 @@ wbxng_base_tx::set_gain(float gain)
 {
   /*
     Set the gain.
-    
+
     @param gain:  gain in decibels
     @returns True/False
   */
-  
+
   // clamp gain
   gain = std::max(gain_min(), std::min(gain, gain_max()));
 
@@ -418,7 +273,7 @@ wbxng_base_tx::set_gain(float gain)
     pga_gain = 0;
     agc_gain = gain;
   }
-  
+
   V_maxgain = 0.7;
   V_mingain = 1.4;
   V_fullscale = 3.3;
@@ -454,14 +309,14 @@ wbxng_base_rx::wbxng_base_rx(usrp_basic_sptr _usrp, int which, int _power_on)
 
   usrp()->_write_oe(d_which, (RX2_RX1N|RXBB_EN|ATTN_MASK|ENABLE_33|ENABLE_5), (RX2_RX1N|RXBB_EN|ATTN_MASK|ENABLE_33|ENABLE_5));
   usrp()->write_io(d_which,  (power_on()|RX2_RX1N|RXBB_EN|ENABLE_33|ENABLE_5), (RX2_RX1N|RXBB_EN|ATTN_MASK|ENABLE_33|ENABLE_5));
-  fprintf(stderr,"Setting WBXNG RXBB on"); 
-  
+  fprintf(stderr,"Setting WBXNG RXBB on");
+
   // set up for RX on TX/RX port
   select_rx_antenna("TX/RX");
-  
+
   bypass_adc_buffers(true);
 
-  /*  
+  /*
   set_lo_offset(-4e6);
   */
 }
@@ -532,7 +387,6 @@ wbxng_base_rx::select_rx_antenna(int which_antenna)
   }
   else {
     return false;
-    // throw std::invalid_argument("which_antenna must be either 'TX/RX' or 'RX2'\n");
   }
   return true;
 }
@@ -545,7 +399,7 @@ wbxng_base_rx::select_rx_antenna(const std::string &which_antenna)
     @param which_antenna: either 'TX/RX' or 'RX2'
   */
 
-  
+
   if(which_antenna == "TX/RX") {
     usrp()->write_io(d_which, 0, RX2_RX1N);
   }
@@ -553,10 +407,9 @@ wbxng_base_rx::select_rx_antenna(const std::string &which_antenna)
     usrp()->write_io(d_which, RX2_RX1N, RX2_RX1N);
   }
   else {
-    // throw std::invalid_argument("which_antenna must be either 'TX/RX' or 'RX2'\n");
     return false;
   }
-  
+
   return true;
 }
 
@@ -565,11 +418,11 @@ wbxng_base_rx::set_gain(float gain)
 {
   /*
     Set the gain.
-    
+
     @param gain:  gain in decibels
     @returns True/False
   */
-  
+
   // clamp gain
   gain = std::max(gain_min(), std::min(gain, gain_max()));
 
@@ -586,7 +439,7 @@ wbxng_base_rx::set_gain(float gain)
     pga_gain = 0;
     agc_gain = gain;
   }
-  
+
   return _set_attn(maxgain-agc_gain) && _set_pga(int(pga_gain));
 }
 
@@ -610,17 +463,6 @@ db_wbxng_tx::~db_wbxng_tx()
 {
 }
 
-/*
-bool
-db_wbxng_tx::_compute_regs(double freq, int &retR, int &retcontrol,
-                                int &retN, double &retfreq)
-{
-  return d_common->_compute_regs(_refclk_freq(), freq, retR,
-                                retcontrol, retN, retfreq);
-}
-*/
-
-
 db_wbxng_rx::db_wbxng_rx(usrp_basic_sptr usrp, int which)
   : wbxng_base_rx(usrp, which)
 {
@@ -655,14 +497,3 @@ db_wbxng_rx::i_and_q_swapped()
 {
   return false;
 }
-
-/*
-bool
-db_wbxng_rx::_compute_regs(double freq, int &retR, int &retcontrol,
-                                int &retN, double &retfreq)
-{
-  return d_common->_compute_regs(_refclk_freq(), freq, retR,
-                                retcontrol, retN, retfreq);
-}
-*/
-
index 73485d90cef1ab80a335cbadf610e01e9efd8fe2..af4eac573512e2260d283bdd57b70dbaa82d958d 100644 (file)
@@ -1,21 +1,33 @@
-/*
- * Copyright 2009 Ettus Research LLC
- */
+//
+// Copyright 2009 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.
 
 #ifdef HAVE_CONFIG_H
 #include <config.h>
 #endif
 
-#include <usrp/db_wbxng_adf4350.h>
-#include <usrp/db_wbxng_adf4350_regs.h>
+#include "db_wbxng_adf4350.h"
 #include <db_base_impl.h>
 #include <stdio.h>
-//#include "io.h"
-//#include "spi.h"
 
 #define INPUT_REF_FREQ FREQ_C(64e6)
 #define DIV_ROUND(num, denom) (((num) + ((denom)/2))/(denom))
-//#define FREQ_C(freq) ((uint64_t)DIV_ROUND(freq, (uint64_t)1000))
 #define FREQ_C(freq) uint64_t(freq)
 #define INPUT_REF_FREQ_2X (2*INPUT_REF_FREQ)                            /* input ref freq with doubler turned on */
 #define MIN_INT_DIV uint16_t(23)                                        /* minimum int divider, prescaler 4/5 only */
@@ -30,7 +42,8 @@
 #define MUX_PIN       (1 << 1)
 #define LD_PIN        (1 << 0)
 
-adf4350::adf4350(usrp_basic_sptr _usrp, int _which, int _spi_enable){
+adf4350::adf4350(usrp_basic_sptr _usrp, int _which, int _spi_enable)
+{
     /* Initialize the pin directions. */
 
     d_usrp = _usrp;
@@ -55,27 +68,32 @@ adf4350::adf4350(usrp_basic_sptr _usrp, int _which, int _spi_enable){
     d_regs->_load_register(0);
 }
 
-adf4350::~adf4350(){
+adf4350::~adf4350()
+{
     delete d_regs;
 }
 
-freq_t 
-adf4350::_get_max_freq(void){
+freq_t
+adf4350::_get_max_freq(void)
+{
     return MAX_FREQ;
 }
 
-freq_t 
-adf4350::_get_min_freq(void){
+freq_t
+adf4350::_get_min_freq(void)
+{
     return MIN_FREQ;
 }
 
-bool 
-adf4350::_get_locked(void){
+bool
+adf4350::_get_locked(void)
+{
     return d_usrp->read_io(d_which) & LD_PIN;
 }
 
-void 
-adf4350::_enable(bool enable){
+void
+adf4350::_enable(bool enable)
+{
     if (enable){ /* chip enable */
         d_usrp->write_io(d_which, (CE_PIN | PDB_RF_PIN), (CE_PIN | PDB_RF_PIN));
     }else{
@@ -83,8 +101,9 @@ adf4350::_enable(bool enable){
     }
 }
 
-void 
-adf4350::_write(uint8_t addr, uint32_t data){
+void
+adf4350::_write(uint8_t addr, uint32_t data)
+{
     data |= addr;
 
     // create str from data here
@@ -109,8 +128,9 @@ adf4350::_write(uint8_t addr, uint32_t data){
     //d_usrp->write_io(d_which, 0, LE_PIN);
 }
 
-bool 
-adf4350::_set_freq(freq_t freq){
+bool
+adf4350::_set_freq(freq_t freq)
+{
     /* Set the frequency by setting int, frac, mod, r, div */
     if (freq > MAX_FREQ || freq < MIN_FREQ) return false;
     /* Ramp up the RF divider until the VCO is within range. */
@@ -144,8 +164,8 @@ adf4350::_set_freq(freq_t freq){
     d_regs->d_8_bit_band_select_clock_divider_value = \
         INPUT_REF_FREQ/(FREQ_C(30e3)*d_regs->d_10_bit_r_counter) + 1;
     /*
-    fprintf(stderr, "Band Selection: Div %u, Freq %lu\n", 
-        d_regs->d_8_bit_band_select_clock_divider_value, 
+    fprintf(stderr, "Band Selection: Div %u, Freq %lu\n",
+        d_regs->d_8_bit_band_select_clock_divider_value,
         INPUT_REF_FREQ/(d_regs->d_8_bit_band_select_clock_divider_value * d_regs->d_10_bit_r_counter) + 1
     );
     */
@@ -159,8 +179,9 @@ adf4350::_set_freq(freq_t freq){
     return true;
 }
 
-freq_t 
-adf4350::_get_freq(void){
+freq_t
+adf4350::_get_freq(void)
+{
     /* Calculate the freq from int, frac, mod, ref, r, div:
      *  freq = (int + frac/mod) * (ref/r)
      * Keep precision by doing multiplies first:
diff --git a/usrp/host/lib/db_wbxng_adf4350.h b/usrp/host/lib/db_wbxng_adf4350.h
new file mode 100644 (file)
index 0000000..2b0783c
--- /dev/null
@@ -0,0 +1,53 @@
+//
+// Copyright 2009 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 INCLUDED_ADF4350_H
+#define INCLUDED_ADF4350_H
+
+#include "db_wbxng_adf4350_regs.h"
+#include <usrp/db_base.h>
+#include <stdint.h>
+
+typedef uint64_t freq_t;
+class adf4350_regs;
+
+class adf4350
+{
+public:
+    adf4350(usrp_basic_sptr _usrp, int _which, int _spi_enable);
+    ~adf4350();
+    void _update();
+    bool _get_locked();
+    void _enable(bool enable);
+    void _write(uint8_t addr, uint32_t data);
+    bool _set_freq(freq_t freq);
+    freq_t _get_freq();
+    freq_t _get_max_freq();
+    freq_t _get_min_freq();
+
+protected:
+    usrp_basic_sptr d_usrp;
+    int d_which;
+    int d_spi_enable;
+    int d_spi_format;
+    adf4350_regs *d_regs;
+};
+
+#endif /* INCLUDED_ADF4350_H */
index 2c1660f56dc1ded1558631e126087821d50d4b56..11dcf88169ab4601ba8361beae75ff66eea2056e 100644 (file)
@@ -2,8 +2,9 @@
  * Copyright 2009 Ettus Research LLC
  */
 
-#include <usrp/db_wbxng_adf4350_regs.h>
-#include <usrp/db_wbxng_adf4350.h>
+#include "db_wbxng_adf4350_regs.h"
+#include "db_wbxng_adf4350.h"
+
 //#include "cal_div.h"
 
 /* reg 0 */
@@ -59,12 +60,12 @@ adf4350_regs::adf4350_regs(adf4350* _adf4350){
 adf4350_regs::~adf4350_regs(void){
 }
 
-uint32_t 
+uint32_t
 adf4350_regs::_reg_shift(uint32_t data, uint32_t shift){
         return data << shift;
     }
 
-void 
+void
 adf4350_regs::_load_register(uint8_t addr){
        uint32_t data;
        switch (addr){
diff --git a/usrp/host/lib/db_wbxng_adf4350_regs.h b/usrp/host/lib/db_wbxng_adf4350_regs.h
new file mode 100644 (file)
index 0000000..dc941ee
--- /dev/null
@@ -0,0 +1,64 @@
+/*
+ * Copyright 2009 Ettus Research LLC
+ */
+
+#ifndef ADF4350_REGS_H
+#define ADF4350_REGS_H
+
+#include <usrp/db_base.h>
+#include <stdint.h>
+
+class adf4350;
+
+class adf4350_regs
+{
+public:
+    adf4350_regs(adf4350* _adf4350);
+    ~adf4350_regs();
+
+    adf4350* d_adf4350;
+
+    uint32_t _reg_shift(uint32_t data, uint32_t shift);
+    void _load_register(uint8_t addr);
+
+    /* reg 0 */
+    uint16_t d_int;
+    uint16_t d_frac;
+    /* reg 1 */
+    static const uint8_t s_prescaler;
+    static const uint16_t s_phase;
+    uint16_t d_mod;
+    /* reg 2 */
+    static const uint8_t s_low_noise_and_low_spur_modes;
+    static const uint8_t s_muxout;
+    static const uint8_t s_reference_doubler;
+    static const uint8_t s_rdiv2;
+    uint16_t d_10_bit_r_counter;
+    static const uint8_t s_double_buff;
+    static const uint8_t s_charge_pump_setting;
+    static const uint8_t s_ldf;
+    static const uint8_t s_ldp;
+    static const uint8_t s_pd_polarity;
+    static const uint8_t s_power_down;
+    static const uint8_t s_cp_three_state;
+    static const uint8_t s_counter_reset;
+    /* reg 3 */
+    static const uint8_t s_csr;
+    static const uint8_t s_clk_div_mode;
+    static const uint16_t s_12_bit_clock_divider_value;
+    /* reg 4 */
+    static const uint8_t s_feedback_select;
+    uint8_t d_divider_select;
+    uint8_t d_8_bit_band_select_clock_divider_value;
+    static const uint8_t s_vco_power_down;
+    static const uint8_t s_mtld;
+    static const uint8_t s_aux_output_select;
+    static const uint8_t s_aux_output_enable;
+    static const uint8_t s_aux_output_power;
+    static const uint8_t s_rf_output_enable;
+    static const uint8_t s_output_power;
+    /* reg 5 */
+    static const uint8_t s_ld_pin_mode;
+};
+
+#endif /* ADF4350_REGS_H */
index 1df28802efc516185d0098859570b2753ab1f340..7d1e1871402043e8f446cbe5adf1f8b542f3f669 100644 (file)
@@ -1,18 +1,18 @@
 #
 # Copyright 2005,2009 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 version 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 this program; if not, write to the Free Software Foundation, Inc.,
 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.