summaryrefslogtreecommitdiff
path: root/usrp/host
diff options
context:
space:
mode:
Diffstat (limited to 'usrp/host')
-rwxr-xr-xusrp/host/apps/burn-db-eeprom18
-rw-r--r--usrp/host/include/usrp/Makefile.am14
-rw-r--r--usrp/host/include/usrp/db_wbxng.h37
-rw-r--r--usrp/host/include/usrp/db_wbxng_adf4350.h37
-rw-r--r--usrp/host/lib/Makefile.am12
-rw-r--r--usrp/host/lib/db_boards.cc14
-rw-r--r--usrp/host/lib/db_wbxng.cc227
-rw-r--r--usrp/host/lib/db_wbxng_adf4350.cc73
-rw-r--r--usrp/host/lib/db_wbxng_adf4350.h53
-rw-r--r--usrp/host/lib/db_wbxng_adf4350_regs.cc9
-rw-r--r--usrp/host/lib/db_wbxng_adf4350_regs.h (renamed from usrp/host/include/usrp/db_wbxng_adf4350_regs.h)1
-rw-r--r--usrp/host/lib/usrp_dbid.dat8
12 files changed, 177 insertions, 326 deletions
diff --git a/usrp/host/apps/burn-db-eeprom b/usrp/host/apps/burn-db-eeprom
index 195c4e897..7ff1e9736 100755
--- a/usrp/host/apps/burn-db-eeprom
+++ b/usrp/host/apps/burn-db-eeprom
@@ -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 ()
-
+
diff --git a/usrp/host/include/usrp/Makefile.am b/usrp/host/include/usrp/Makefile.am
index 7c868e061..cfce51443 100644
--- a/usrp/host/include/usrp/Makefile.am
+++ b/usrp/host/include/usrp/Makefile.am
@@ -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 \
diff --git a/usrp/host/include/usrp/db_wbxng.h b/usrp/host/include/usrp/db_wbxng.h
index fb5c8da71..2158face2 100644
--- a/usrp/host/include/usrp/db_wbxng.h
+++ b/usrp/host/include/usrp/db_wbxng.h
@@ -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
index d7b8dd99b..000000000
--- a/usrp/host/include/usrp/db_wbxng_adf4350.h
+++ /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/lib/Makefile.am b/usrp/host/lib/Makefile.am
index 13f25d69b..72312ebbb 100644
--- a/usrp/host/lib/Makefile.am
+++ b/usrp/host/lib/Makefile.am
@@ -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 \
diff --git a/usrp/host/lib/db_boards.cc b/usrp/host/lib/db_boards.cc
index 53304bd1a..590d8132d 100644
--- a/usrp/host/lib/db_boards.cc
+++ b/usrp/host/lib/db_boards.cc
@@ -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)){
diff --git a/usrp/host/lib/db_wbxng.cc b/usrp/host/lib/db_wbxng.cc
index 0dd8b0d38..c23fc47ed 100644
--- a/usrp/host/lib/db_wbxng.cc
+++ b/usrp/host/lib/db_wbxng.cc
@@ -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);
-}
-*/
-
diff --git a/usrp/host/lib/db_wbxng_adf4350.cc b/usrp/host/lib/db_wbxng_adf4350.cc
index 73485d90c..af4eac573 100644
--- a/usrp/host/lib/db_wbxng_adf4350.cc
+++ b/usrp/host/lib/db_wbxng_adf4350.cc
@@ -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
index 000000000..2b0783c20
--- /dev/null
+++ b/usrp/host/lib/db_wbxng_adf4350.h
@@ -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 */
diff --git a/usrp/host/lib/db_wbxng_adf4350_regs.cc b/usrp/host/lib/db_wbxng_adf4350_regs.cc
index 2c1660f56..11dcf8816 100644
--- a/usrp/host/lib/db_wbxng_adf4350_regs.cc
+++ b/usrp/host/lib/db_wbxng_adf4350_regs.cc
@@ -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/include/usrp/db_wbxng_adf4350_regs.h b/usrp/host/lib/db_wbxng_adf4350_regs.h
index 6a5b77a4b..dc941ee87 100644
--- a/usrp/host/include/usrp/db_wbxng_adf4350_regs.h
+++ b/usrp/host/lib/db_wbxng_adf4350_regs.h
@@ -5,7 +5,6 @@
#ifndef ADF4350_REGS_H
#define ADF4350_REGS_H
-#include <usrp/db_wbxng_adf4350.h>
#include <usrp/db_base.h>
#include <stdint.h>
diff --git a/usrp/host/lib/usrp_dbid.dat b/usrp/host/lib/usrp_dbid.dat
index 1df28802e..7d1e18714 100644
--- a/usrp/host/lib/usrp_dbid.dat
+++ b/usrp/host/lib/usrp_dbid.dat
@@ -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.