[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] r7153 - gnuradio/branches/developers/jcorgan/t127/usrp
From: |
jcorgan |
Subject: |
[Commit-gnuradio] r7153 - gnuradio/branches/developers/jcorgan/t127/usrpdb/src |
Date: |
Thu, 13 Dec 2007 13:02:16 -0700 (MST) |
Author: jcorgan
Date: 2007-12-13 13:02:12 -0700 (Thu, 13 Dec 2007)
New Revision: 7153
Added:
gnuradio/branches/developers/jcorgan/t127/usrpdb/src/qa_basic_tx.py
gnuradio/branches/developers/jcorgan/t127/usrpdb/src/usrpdb_basic_tx.cc
gnuradio/branches/developers/jcorgan/t127/usrpdb/src/usrpdb_basic_tx.h
gnuradio/branches/developers/jcorgan/t127/usrpdb/src/usrpdb_basic_tx.i
Modified:
gnuradio/branches/developers/jcorgan/t127/usrpdb/src/Makefile.am
gnuradio/branches/developers/jcorgan/t127/usrpdb/src/usrpdb.i
gnuradio/branches/developers/jcorgan/t127/usrpdb/src/usrpdb_base.h
gnuradio/branches/developers/jcorgan/t127/usrpdb/src/usrpdb_hwa.h
gnuradio/branches/developers/jcorgan/t127/usrpdb/src/usrpdb_qa_hwa.cc
gnuradio/branches/developers/jcorgan/t127/usrpdb/src/usrpdb_qa_hwa.h
gnuradio/branches/developers/jcorgan/t127/usrpdb/src/usrpdb_qa_hwa.i
Log:
Created usrpdb.basic_tx class. Still issues with inheritance and SWIG to
resolve.
Modified: gnuradio/branches/developers/jcorgan/t127/usrpdb/src/Makefile.am
===================================================================
--- gnuradio/branches/developers/jcorgan/t127/usrpdb/src/Makefile.am
2007-12-13 18:03:29 UTC (rev 7152)
+++ gnuradio/branches/developers/jcorgan/t127/usrpdb/src/Makefile.am
2007-12-13 20:02:12 UTC (rev 7153)
@@ -33,6 +33,7 @@
LOCAL_IFILES = \
$(top_srcdir)/usrpdb/src/usrpdb.i \
+ $(top_srcdir)/usrpdb/src/usrpdb_basic_tx.i \
$(top_srcdir)/usrpdb/src/usrpdb_qa_hwa.i
REMOTE_IFILES = \
@@ -55,6 +56,7 @@
libusrpdb_la_SOURCES = \
usrpdb_base.cc \
+ usrpdb_basic_tx.cc \
usrpdb_hwa.cc \
usrpdb_qa_hwa.cc
@@ -68,12 +70,13 @@
libusrpdb.la \
-lstdc++
-libusrp_la_LDFLAGS = $(NO_UNDEFINED)
+libusrpdb_la_LDFLAGS = $(NO_UNDEFINED)
_usrpdb_la_LDFLAGS = $(NO_UNDEFINED) -module -avoid-version
grinclude_HEADERS = \
usrpdb_base.h \
+ usrpdb_basic_tx.h \
usrpdb_hwa.h \
usrpdb_qa_hwa.h
Added: gnuradio/branches/developers/jcorgan/t127/usrpdb/src/qa_basic_tx.py
===================================================================
--- gnuradio/branches/developers/jcorgan/t127/usrpdb/src/qa_basic_tx.py
(rev 0)
+++ gnuradio/branches/developers/jcorgan/t127/usrpdb/src/qa_basic_tx.py
2007-12-13 20:02:12 UTC (rev 7153)
@@ -0,0 +1,41 @@
+#!/usr/bin/env python
+#
+# Copyright 2007 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 gnuradio import gr, gr_unittest
+import usrpdb
+
+class qa_basic_tx(gr_unittest.TestCase):
+
+ def setUp(self):
+ self.hwa = usrpdb.qa_hwa()
+ self.db = usrpdb.basic_tx(self.hwa)
+
+ def tearDown(self):
+ self.db = None
+ self.hwa = None
+
+ def test_000_gain(self):
+ self.db.set_gain(-10.0)
+ self.assertEqual(self.hwa.dac_pga_gain(), -10.0)
+
+if __name__ == '__main__':
+ gr_unittest.main ()
Property changes on:
gnuradio/branches/developers/jcorgan/t127/usrpdb/src/qa_basic_tx.py
___________________________________________________________________
Name: svn:executable
+ *
Modified: gnuradio/branches/developers/jcorgan/t127/usrpdb/src/usrpdb.i
===================================================================
--- gnuradio/branches/developers/jcorgan/t127/usrpdb/src/usrpdb.i
2007-12-13 18:03:29 UTC (rev 7152)
+++ gnuradio/branches/developers/jcorgan/t127/usrpdb/src/usrpdb.i
2007-12-13 20:02:12 UTC (rev 7153)
@@ -24,3 +24,4 @@
%include <shared_ptr.i>
%include "usrpdb_qa_hwa.i"
+%include "usrpdb_basic_tx.i"
Modified: gnuradio/branches/developers/jcorgan/t127/usrpdb/src/usrpdb_base.h
===================================================================
--- gnuradio/branches/developers/jcorgan/t127/usrpdb/src/usrpdb_base.h
2007-12-13 18:03:29 UTC (rev 7152)
+++ gnuradio/branches/developers/jcorgan/t127/usrpdb/src/usrpdb_base.h
2007-12-13 20:02:12 UTC (rev 7153)
@@ -25,13 +25,9 @@
#include <usrpdb_hwa.h>
-// Would rather make this a std::vector<float>, but don't want to use
-// STL so this code can be cross-compiled on the USRP2 FPGA CPU
-typedef float *freq_range_t; // min, max, step
-typedef float *gain_range_t; // min, max, step
-
class usrpdb_base
{
+protected:
usrpdb_hwa_sptr d_hwa;
public:
@@ -40,10 +36,10 @@
// These methods MUST be overridden in derived classes
// (they raised NotImplemented exceptions in old db_base.py)
- virtual const freq_range_t freq_range() = 0;
- virtual const gain_range_t gain_range() = 0;
- virtual void set_freq(float target_freq, const float &actual_baseband_freq)
= 0;
- virtual bool set_gain(float gain) = 0;
+ virtual void freq_range(float &min, float &max, float &step) = 0;
+ virtual void gain_range(float &min, float &max, float &step) = 0;
+ virtual void set_freq(float target_freq, float &actual_baseband_freq) = 0;
+ virtual void set_gain(float gain) = 0;
virtual bool is_quadrature() = 0;
// These methods MAY be overriden in derived classes, but have default ops
Added: gnuradio/branches/developers/jcorgan/t127/usrpdb/src/usrpdb_basic_tx.cc
===================================================================
--- gnuradio/branches/developers/jcorgan/t127/usrpdb/src/usrpdb_basic_tx.cc
(rev 0)
+++ gnuradio/branches/developers/jcorgan/t127/usrpdb/src/usrpdb_basic_tx.cc
2007-12-13 20:02:12 UTC (rev 7153)
@@ -0,0 +1,91 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2007 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.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <usrpdb_basic_tx.h>
+#include <stdexcept>
+
+// BasicTX boards report they can do essentially anything
+const static float s_freq_min = -90e9;
+const static float s_freq_max = 90e9;
+const static float s_freq_step = 1e-6;
+
+usrpdb_basic_tx_sptr
+usrpdb_make_basic_tx(usrpdb_hwa_sptr hwa)
+{
+ return usrpdb_basic_tx_sptr(new usrpdb_basic_tx(hwa));
+}
+
+usrpdb_basic_tx::usrpdb_basic_tx(usrpdb_hwa_sptr hwa)
+ : usrpdb_base(hwa)
+{
+ // nop
+}
+
+void
+usrpdb_basic_tx::freq_range(float &min, float &max, float &step)
+{
+ min = s_freq_min;
+ max = s_freq_max;
+ step = s_freq_step;
+}
+
+void
+usrpdb_basic_tx::set_freq(float target_freq, float &actual_baseband_freq)
+{
+ // BasicTX boards don't have an LO, so they always return 0.0 as result
+ actual_baseband_freq = 0.0;
+}
+
+void
+usrpdb_basic_tx::gain_range(float &min, float &max, float &step)
+{
+ // BasicTX boards have no gain, but report the DAC PGA setting
+ min = d_hwa->dac_pga_min();
+ max = d_hwa->dac_pga_max();
+ step = d_hwa->dac_pga_db_per_step();
+}
+
+void
+usrpdb_basic_tx::set_gain(float gain)
+{
+ // BasicTX boards have no gain, but adjust the DAC PGA setting
+ if (gain < d_hwa->dac_pga_min() || gain > d_hwa->dac_pga_max()) {
+ throw std::invalid_argument("gain value is out of range");
+ }
+
+ d_hwa->set_dac_pga(gain);
+}
+
+bool
+usrpdb_basic_tx::is_quadrature()
+{
+ // Basic boards have I and Q
+ return true;
+}
+
+usrpdb_basic_tx::~usrpdb_basic_tx()
+{
+}
Added: gnuradio/branches/developers/jcorgan/t127/usrpdb/src/usrpdb_basic_tx.h
===================================================================
--- gnuradio/branches/developers/jcorgan/t127/usrpdb/src/usrpdb_basic_tx.h
(rev 0)
+++ gnuradio/branches/developers/jcorgan/t127/usrpdb/src/usrpdb_basic_tx.h
2007-12-13 20:02:12 UTC (rev 7153)
@@ -0,0 +1,50 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2007 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.
+ */
+
+#ifndef INCLUDED_USRPDB_BASIC_TX_H
+#define INCLUDED_USRPDB_BASIC_TX_H
+
+#include <usrpdb_base.h>
+
+class usrpdb_basic_tx;
+typedef boost::shared_ptr<usrpdb_basic_tx> usrpdb_basic_tx_sptr;
+
+usrpdb_basic_tx_sptr usrpdb_make_basic_tx(usrpdb_hwa_sptr hwa);
+
+class usrpdb_basic_tx : protected usrpdb_base
+{
+private:
+ usrpdb_basic_tx(usrpdb_hwa_sptr hwa);
+
+ friend usrpdb_basic_tx_sptr usrpdb_make_basic_tx(usrpdb_hwa_sptr hwa);
+
+public:
+ virtual ~usrpdb_basic_tx();
+
+ virtual void freq_range(float &min, float &max, float &step);
+ virtual void set_freq(float target_freq, float &actual_baseband_freq);
+ virtual void gain_range(float &min, float &max, float &step);
+ virtual void set_gain(float gain);
+ virtual bool is_quadrature();
+};
+
+#endif /* INCLUDED_USRPDB_BASIC_TX_H */
Added: gnuradio/branches/developers/jcorgan/t127/usrpdb/src/usrpdb_basic_tx.i
===================================================================
--- gnuradio/branches/developers/jcorgan/t127/usrpdb/src/usrpdb_basic_tx.i
(rev 0)
+++ gnuradio/branches/developers/jcorgan/t127/usrpdb/src/usrpdb_basic_tx.i
2007-12-13 20:02:12 UTC (rev 7153)
@@ -0,0 +1,51 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2007 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 <usrpdb_basic_tx.h>
+%}
+
+%include "usrpdb_base.h"
+
+class usrpdb_basic_tx;
+typedef boost::shared_ptr<usrpdb_basic_tx> usrpdb_basic_tx_sptr;
+%template(usrpdb_basic_tx_sptr) boost::shared_ptr<usrpdb_basic_tx>;
+%rename(basic_tx) usrpdb_make_basic_tx;
+%ignore basic_tx;
+
+usrpdb_basic_tx_sptr usrpdb_make_basic_tx(usrpdb_hwa_sptr hwa);
+
+class usrpdb_basic_tx : protected usrpdb_base
+{
+private:
+ usrpdb_basic_tx(usrpdb_hwa_sptr hwa);
+
+public:
+ ~usrpdb_basic_tx();
+
+ void freq_range(float &min, float &max, float &step);
+ void set_freq(float target_freq, float &actual_baseband_freq);
+ void gain_range(float &min, float &max, float &step);
+ void set_gain(float gain);
+ bool is_quadrature();
+};
+
Modified: gnuradio/branches/developers/jcorgan/t127/usrpdb/src/usrpdb_hwa.h
===================================================================
--- gnuradio/branches/developers/jcorgan/t127/usrpdb/src/usrpdb_hwa.h
2007-12-13 18:03:29 UTC (rev 7152)
+++ gnuradio/branches/developers/jcorgan/t127/usrpdb/src/usrpdb_hwa.h
2007-12-13 20:02:12 UTC (rev 7153)
@@ -30,6 +30,11 @@
public:
usrpdb_hwa();
+ virtual float dac_pga_gain() = 0;
+ virtual float dac_pga_min() = 0;
+ virtual float dac_pga_max() = 0;
+ virtual float dac_pga_db_per_step() = 0;
+ virtual void set_dac_pga(float gain) = 0;
virtual ~usrpdb_hwa() = 0;
};
Modified: gnuradio/branches/developers/jcorgan/t127/usrpdb/src/usrpdb_qa_hwa.cc
===================================================================
--- gnuradio/branches/developers/jcorgan/t127/usrpdb/src/usrpdb_qa_hwa.cc
2007-12-13 18:03:29 UTC (rev 7152)
+++ gnuradio/branches/developers/jcorgan/t127/usrpdb/src/usrpdb_qa_hwa.cc
2007-12-13 20:02:12 UTC (rev 7153)
@@ -26,15 +26,50 @@
#include <usrpdb_qa_hwa.h>
-usrpdb_qa_hwa_sptr usrpdb_make_qa_hwa()
+usrpdb_qa_hwa_sptr
+usrpdb_make_qa_hwa()
{
return usrpdb_qa_hwa_sptr(new usrpdb_qa_hwa());
}
usrpdb_qa_hwa::usrpdb_qa_hwa()
+ : d_dac_pga_gain(0.0)
{
}
+float
+usrpdb_qa_hwa::dac_pga_gain()
+{
+ return d_dac_pga_gain;
+}
+
+float
+usrpdb_qa_hwa::dac_pga_min()
+{
+ // mimic USRP1
+ return -20.0;
+}
+
+float
+usrpdb_qa_hwa::dac_pga_max()
+{
+ // mimic USRP1
+ return 0.0;
+}
+
+float
+usrpdb_qa_hwa::dac_pga_db_per_step()
+{
+ // mimic USRP1
+ return (dac_pga_max()-dac_pga_min())/100.0;
+}
+
+void
+usrpdb_qa_hwa::set_dac_pga(float gain)
+{
+ d_dac_pga_gain = gain;
+}
+
usrpdb_qa_hwa::~usrpdb_qa_hwa()
{
}
Modified: gnuradio/branches/developers/jcorgan/t127/usrpdb/src/usrpdb_qa_hwa.h
===================================================================
--- gnuradio/branches/developers/jcorgan/t127/usrpdb/src/usrpdb_qa_hwa.h
2007-12-13 18:03:29 UTC (rev 7152)
+++ gnuradio/branches/developers/jcorgan/t127/usrpdb/src/usrpdb_qa_hwa.h
2007-12-13 20:02:12 UTC (rev 7153)
@@ -36,11 +36,20 @@
usrpdb_qa_hwa();
friend usrpdb_qa_hwa_sptr usrpdb_make_qa_hwa();
+
+ // Mimic dummy hardware
+ float d_dac_pga_gain;
public:
int foo() const { return 42; }
~usrpdb_qa_hwa();
+
+ float dac_pga_gain();
+ float dac_pga_min();
+ float dac_pga_max();
+ float dac_pga_db_per_step();
+ void set_dac_pga(float gain);
};
#endif /* INCLUDED_USRPDB_QA_HWA_H */
Modified: gnuradio/branches/developers/jcorgan/t127/usrpdb/src/usrpdb_qa_hwa.i
===================================================================
--- gnuradio/branches/developers/jcorgan/t127/usrpdb/src/usrpdb_qa_hwa.i
2007-12-13 18:03:29 UTC (rev 7152)
+++ gnuradio/branches/developers/jcorgan/t127/usrpdb/src/usrpdb_qa_hwa.i
2007-12-13 20:02:12 UTC (rev 7153)
@@ -24,6 +24,8 @@
#include <usrpdb_qa_hwa.h>
%}
+#include <usrpdb_hwa.h>
+
class usrpdb_qa_hwa;
typedef boost::shared_ptr<usrpdb_qa_hwa> usrpdb_qa_hwa_sptr;
%template(usrpdb_qa_hwa_sptr) boost::shared_ptr<usrpdb_qa_hwa>;
@@ -32,7 +34,7 @@
usrpdb_qa_hwa_sptr usrpdb_make_qa_hwa();
-class usrpdb_qa_hwa
+class usrpdb_qa_hwa : public usrpdb_hwa
{
protected:
usrpdb_qa_hwa();
@@ -40,4 +42,10 @@
public:
int foo() const { return 42; }
~usrpdb_qa_hwa();
+
+ float dac_pga_gain();
+ float dac_pga_min();
+ float dac_pga_max();
+ float dac_pga_db_per_step();
+ void set_dac_pga(float gain);
};
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Commit-gnuradio] r7153 - gnuradio/branches/developers/jcorgan/t127/usrpdb/src,
jcorgan <=