[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] r9911 - gnuradio/branches/developers/eb/cppdb-wip/gr-u
From: |
eb |
Subject: |
[Commit-gnuradio] r9911 - gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src |
Date: |
Sun, 2 Nov 2008 17:37:41 -0700 (MST) |
Author: eb
Date: 2008-11-02 17:37:38 -0700 (Sun, 02 Nov 2008)
New Revision: 9911
Modified:
gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src/usrp_sink_base.cc
gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src/usrp_sink_base.h
gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src/usrp_source_base.cc
Log:
refactored usrp_sink_base to use usrp_base
Modified:
gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src/usrp_sink_base.cc
===================================================================
--- gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src/usrp_sink_base.cc
2008-11-03 00:31:14 UTC (rev 9910)
+++ gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src/usrp_sink_base.cc
2008-11-03 00:37:38 UTC (rev 9911)
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2004 Free Software Foundation, Inc.
+ * Copyright 2004,2008 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -21,7 +21,7 @@
*/
#ifdef HAVE_CONFIG_H
-#include "config.h"
+#include <config.h>
#endif
#include <usrp_sink_base.h>
@@ -42,9 +42,9 @@
const std::string fpga_filename,
const std::string firmware_filename
) throw (std::runtime_error)
- : gr_sync_block (name,
- input_signature,
- gr_make_io_signature (0, 0, 0)),
+ : usrp_base(name,
+ input_signature,
+ gr_make_io_signature (0, 0, 0)),
d_nunderruns (0)
{
d_usrp = usrp_standard_tx::make (which_board,
@@ -58,6 +58,8 @@
if (d_usrp == 0)
throw std::runtime_error ("can't open usrp");
+ set_usrp_basic(d_usrp);
+
// All calls to d_usrp->write must be multiples of 512 bytes.
set_output_multiple (OUTPUT_MULTIPLE_SAMPLES);
@@ -65,21 +67,9 @@
usrp_sink_base::~usrp_sink_base ()
{
- delete d_usrp;
+ // delete d_usrp; // The base class deletes this via its d_usrp_basic
instance var
}
-bool
-usrp_sink_base::start()
-{
- return d_usrp->start();
-}
-
-bool
-usrp_sink_base::stop()
-{
- return d_usrp->stop();
-}
-
int
usrp_sink_base::work (int noutput_items,
gr_vector_const_void_star &input_items,
@@ -162,18 +152,6 @@
return d_usrp->set_tx_freq (channel, freq);
}
-long
-usrp_sink_base::fpga_master_clock_freq() const
-{
- return d_usrp->fpga_master_clock_freq();
-}
-
-long
-usrp_sink_base::converter_rate () const
-{
- return d_usrp->converter_rate ();
-}
-
unsigned int
usrp_sink_base::interp_rate () const
{
@@ -198,162 +176,3 @@
{
return d_usrp->tx_freq (channel);
}
-
-void
-usrp_sink_base::set_verbose (bool verbose)
-{
- d_usrp->set_verbose (verbose);
-}
-
-bool
-usrp_sink_base::write_aux_dac (int which_dboard, int which_dac, int value)
-{
- return d_usrp->write_aux_dac (which_dboard, which_dac, value);
-}
-
-int
-usrp_sink_base::read_aux_adc (int which_dboard, int which_adc)
-{
- return d_usrp->read_aux_adc (which_dboard, which_adc);
-}
-
-bool
-usrp_sink_base::write_eeprom (int i2c_addr, int eeprom_offset, const
std::string buf)
-{
- return d_usrp->write_eeprom (i2c_addr, eeprom_offset, buf);
-}
-
-std::string
-usrp_sink_base::read_eeprom (int i2c_addr, int eeprom_offset, int len)
-{
- return d_usrp->read_eeprom (i2c_addr, eeprom_offset, len);
-}
-
-bool
-usrp_sink_base::write_i2c (int i2c_addr, const std::string buf)
-{
- return d_usrp->write_i2c (i2c_addr, buf);
-}
-
-std::string
-usrp_sink_base::read_i2c (int i2c_addr, int len)
-{
- return d_usrp->read_i2c (i2c_addr, len);
-}
-
-bool
-usrp_sink_base::set_pga (int which, double gain)
-{
- return d_usrp->set_pga (which, gain);
-}
-
-double
-usrp_sink_base::pga (int which) const
-{
- return d_usrp->pga (which);
-}
-
-double
-usrp_sink_base::pga_min () const
-{
- return d_usrp->pga_min ();
-}
-
-double
-usrp_sink_base::pga_max () const
-{
- return d_usrp->pga_max ();
-}
-
-double
-usrp_sink_base::pga_db_per_step () const
-{
- return d_usrp->pga_db_per_step ();
-}
-
-int
-usrp_sink_base::daughterboard_id (int which) const
-{
- return d_usrp->daughterboard_id (which);
-}
-
-bool
-usrp_sink_base::set_adc_offset (int which, int offset)
-{
- return d_usrp->set_adc_offset (which, offset);
-}
-
-bool
-usrp_sink_base::set_dac_offset (int which, int offset, int offset_pin)
-{
- return d_usrp->set_dac_offset (which, offset, offset_pin);
-}
-
-bool
-usrp_sink_base::set_adc_buffer_bypass (int which, bool bypass)
-{
- return d_usrp->set_adc_buffer_bypass (which, bypass);
-}
-
-std::string
-usrp_sink_base::serial_number()
-{
- return d_usrp->serial_number();
-}
-
-bool
-usrp_sink_base::_write_oe (int which_dboard, int value, int mask)
-{
- return d_usrp->_write_oe (which_dboard, value, mask);
-}
-
-bool
-usrp_sink_base::write_io (int which_dboard, int value, int mask)
-{
- return d_usrp->write_io (which_dboard, value, mask);
-}
-
-int
-usrp_sink_base::read_io (int which_dboard)
-{
- return d_usrp->read_io (which_dboard);
-}
-
-// internal routines...
-
-bool
-usrp_sink_base::_write_fpga_reg (int regno, int value)
-{
- return d_usrp->_write_fpga_reg (regno, value);
-}
-
-int
-usrp_sink_base::_read_fpga_reg (int regno)
-{
- return d_usrp->_read_fpga_reg (regno);
-}
-
-bool
-usrp_sink_base::_write_9862 (int which_codec, int regno, unsigned char value)
-{
- return d_usrp->_write_9862 (which_codec, regno, value);
-}
-
-int
-usrp_sink_base::_read_9862 (int which_codec, int regno) const
-{
- return d_usrp->_read_9862 (which_codec, regno);
-}
-
-bool
-usrp_sink_base::_write_spi (int optional_header, int enables,
- int format, std::string buf)
-{
- return d_usrp->_write_spi (optional_header, enables, format, buf);
-}
-
-std::string
-usrp_sink_base::_read_spi (int optional_header, int enables, int format, int
len)
-{
- return d_usrp->_read_spi (optional_header, enables, format, len);
-}
Modified: gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src/usrp_sink_base.h
===================================================================
--- gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src/usrp_sink_base.h
2008-11-03 00:31:14 UTC (rev 9910)
+++ gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src/usrp_sink_base.h
2008-11-03 00:37:38 UTC (rev 9911)
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2004,2006 Free Software Foundation, Inc.
+ * Copyright 2004,2006,2008 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -23,7 +23,7 @@
#ifndef INCLUDED_USRP_SINK_BASE_H
#define INCLUDED_USRP_SINK_BASE_H
-#include <gr_sync_block.h>
+#include <usrp_base.h>
#include <stdexcept>
class usrp_standard_tx;
@@ -32,7 +32,7 @@
/*!
* \brief abstract interface to Universal Software Radio Peripheral Tx path
(Rev 1)
*/
-class usrp_sink_base : public gr_sync_block {
+class usrp_sink_base : public usrp_base {
private:
usrp_standard_tx *d_usrp;
int d_nunderruns;
@@ -70,19 +70,12 @@
int &bytes_written) = 0;
public:
- //! magic value used on alternate register read interfaces
- static const int READ_FAILED = -99999;
-
-
~usrp_sink_base ();
int work (int noutput_items,
gr_vector_const_void_star &input_items,
gr_vector_void_star &output_items);
- bool start();
- bool stop();
-
/*!
* \brief Set interpolator rate. \p rate must be in [4, 1024] and a
multiple of 4.
*
@@ -102,51 +95,6 @@
*/
bool set_tx_freq (int channel, double freq);
- void set_verbose (bool verbose);
-
- /*!
- * \brief Set Programmable Gain Amplifier (PGA)
- *
- * \param which which D/A [0,3]
- * \param gain_in_db gain value (linear in dB)
- *
- * gain is rounded to closest setting supported by hardware.
- * Note that DAC 0 and DAC 1 share a gain setting as do DAC 2 and DAC 3.
- * Setting DAC 0 affects DAC 1 and vice versa. Same with DAC 2 and DAC 3.
- *
- * \returns true iff sucessful.
- *
- * \sa pga_min(), pga_max(), pga_db_per_step()
- */
- bool set_pga (int which, double gain_in_db);
-
- /*!
- * \brief Return programmable gain amplifier gain in dB.
- *
- * \param which which D/A [0,3]
- */
- double pga (int which) const;
-
- /*!
- * \brief Return minimum legal PGA gain in dB.
- */
- double pga_min () const;
-
- /*!
- * \brief Return maximum legal PGA gain in dB.
- */
- double pga_max () const;
-
- /*!
- * \brief Return hardware step size of PGA (linear in dB).
- */
- double pga_db_per_step () const;
-
-
- // ACCESSORS
-
- long fpga_master_clock_freq() const;
- long converter_rate() const;
long dac_rate() const { return converter_rate(); } // alias
long dac_freq() const { return converter_rate(); } // deprecated alias
@@ -156,204 +104,6 @@
double tx_freq (int channel) const;
int nunderruns () const { return d_nunderruns; }
- /*!
- * \brief Return daughterboard ID for given Rx daughterboard slot [0,1].
- *
- * \return daughterboard id >= 0 if successful
- * \return -1 if no daugherboard
- * \return -2 if invalid EEPROM on daughterboard
- */
- int daughterboard_id (int which_dboard) const;
-
- /*!
- * \brief Write auxiliary digital to analog converter.
- *
- * \param which_dboard [0,1] which d'board
- * N.B., SLOT_TX_A and SLOT_RX_A share the same
AUX DAC's.
- * SLOT_TX_B and SLOT_RX_B share the same AUX
DAC's.
- * \param which_dac [2,3] TX slots must use only 2 and 3.
- * \param value [0,4095]
- * \returns true iff successful
- */
- bool write_aux_dac (int which_board, int which_dac, int value);
-
- /*!
- * \brief Read auxiliary analog to digital converter.
- *
- * \param which_dboard [0,1] which d'board
- * \param which_adc [0,1]
- * \returns value in the range [0,4095] if successful, else READ_FAILED.
- */
- int read_aux_adc (int which_dboard, int which_adc);
-
- /*!
- * \brief Write EEPROM on motherboard or any daughterboard.
- * \param i2c_addr I2C bus address of EEPROM
- * \param eeprom_offset byte offset in EEPROM to begin writing
- * \param buf the data to write
- * \returns true iff sucessful
- */
- bool write_eeprom (int i2c_addr, int eeprom_offset, const std::string buf);
-
- /*!
- * \brief Write EEPROM on motherboard or any daughterboard.
- * \param i2c_addr I2C bus address of EEPROM
- * \param eeprom_offset byte offset in EEPROM to begin reading
- * \param len number of bytes to read
- * \returns the data read if successful, else a zero length string.
- */
- std::string read_eeprom (int i2c_addr, int eeprom_offset, int len);
-
- /*!
- * \brief Write to I2C peripheral
- * \param i2c_addr I2C bus address (7-bits)
- * \param buf the data to write
- * \returns true iff successful
- * Writes are limited to a maximum of of 64 bytes.
- */
- bool write_i2c (int i2c_addr, const std::string buf);
-
- /*!
- * \brief Read from I2C peripheral
- * \param i2c_addr I2C bus address (7-bits)
- * \param len number of bytes to read
- * \returns the data read if successful, else a zero length string.
- * Reads are limited to a maximum of of 64 bytes.
- */
- std::string read_i2c (int i2c_addr, int len);
-
- /*!
- * \brief Set ADC offset correction
- * \param which which ADC[0,3]: 0 = RX_A I, 1 = RX_A Q...
- * \param offset 16-bit value to subtract from raw ADC input.
- */
- bool set_adc_offset (int which, int offset);
-
- /*!
- * \brief Set DAC offset correction
- * \param which which DAC[0,3]: 0 = TX_A I, 1 = TX_A Q...
- * \param offset 10-bit offset value (ambiguous format: See AD9862
datasheet).
- * \param offset_pin 1-bit value. If 0 offset applied to -ve differential
pin;
- * If 1 offset applied to +ve differential
pin.
- */
- bool set_dac_offset (int which, int offset, int offset_pin);
-
- /*!
- * \brief Control ADC input buffer
- * \param which which ADC[0,3]
- * \param bypass if non-zero, bypass input buffer and connect input
- * directly to switched cap SHA input of RxPGA.
- */
- bool set_adc_buffer_bypass (int which, bool bypass);
-
- /*!
- * \brief return the usrp's serial number.
- *
- * \returns non-zero length string iff successful.
- */
- std::string serial_number();
-
- /*!
- * \brief Write direction register (output enables) for pins that go to
daughterboard.
- *
- * \param which_dboard [0,1] which d'board
- * \param value value to write into register
- * \param mask which bits of value to write into reg
- *
- * Each d'board has 16-bits of general purpose i/o.
- * Setting the bit makes it an output from the FPGA to the d'board.
- *
- * This register is initialized based on a value stored in the
- * d'board EEPROM. In general, you shouldn't be using this routine
- * without a very good reason. Using this method incorrectly will
- * kill your USRP motherboard and/or daughterboard.
- */
- bool _write_oe (int which_dboard, int value, int mask);
-
- /*!
- * \brief Write daughterboard i/o pin value
- *
- * \param which_dboard [0,1] which d'board
- * \param value value to write into register
- * \param mask which bits of value to write into reg
- */
- bool write_io (int which_dboard, int value, int mask);
-
- /*!
- * \brief Read daughterboard i/o pin value
- *
- * \param which_dboard [0,1] which d'board
- * \returns register value if successful, else READ_FAILED
- */
- int read_io (int which_dboard);
-
- //
- // internal routines...
- // You probably shouldn't be using these...
- //
- /*!
- * \brief Write FPGA register.
- * \param regno 7-bit register number
- * \param value 32-bit value
- * \returns true iff successful
- */
- bool _write_fpga_reg (int regno, int value); //< 7-bit regno, 32-bit value
-
- /*!
- * \brief Read FPGA register.
- * \param regno 7-bit register number
- * \returns register value if successful, else READ_FAILED
- */
- int _read_fpga_reg (int regno);
-
- /*!
- * \brief Write AD9862 register.
- * \param which_codec 0 or 1
- * \param regno 6-bit register number
- * \param value 8-bit value
- * \returns true iff successful
- */
- bool _write_9862 (int which_codec, int regno, unsigned char value);
-
- /*!
- * \brief Read AD9862 register.
- * \param which_codec 0 or 1
- * \param regno 6-bit register number
- * \returns register value if successful, else READ_FAILED
- */
- int _read_9862 (int which_codec, int regno) const;
-
- /*!
- * \brief Write data to SPI bus peripheral.
- *
- * \param optional_header 0,1 or 2 bytes to write before buf.
- * \param enables bitmask of peripherals to write. See
usrp_spi_defs.h
- * \param format transaction format. See usrp_spi_defs.h
SPI_FMT_*
- * \param buf the data to write
- * \returns true iff successful
- * Writes are limited to a maximum of 64 bytes.
- *
- * If \p format specifies that optional_header bytes are present, they are
- * written to the peripheral immediately prior to writing \p buf.
- */
- bool _write_spi (int optional_header, int enables, int format, std::string
buf);
-
- /*
- * \brief Read data from SPI bus peripheral.
- *
- * \param optional_header 0,1 or 2 bytes to write before buf.
- * \param enables bitmask of peripheral to read. See
usrp_spi_defs.h
- * \param format transaction format. See usrp_spi_defs.h
SPI_FMT_*
- * \param len number of bytes to read. Must be in
[0,64].
- * \returns the data read if sucessful, else a zero length string.
- *
- * Reads are limited to a maximum of 64 bytes.
- *
- * If \p format specifies that optional_header bytes are present, they
- * are written to the peripheral first. Then \p len bytes are read from
- * the peripheral and returned.
- */
- std::string _read_spi (int optional_header, int enables, int format, int
len);
};
#endif /* INCLUDED_USRP_SINK_BASE_H */
Modified:
gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src/usrp_source_base.cc
===================================================================
--- gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src/usrp_source_base.cc
2008-11-03 00:31:14 UTC (rev 9910)
+++ gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src/usrp_source_base.cc
2008-11-03 00:37:38 UTC (rev 9911)
@@ -67,7 +67,7 @@
usrp_source_base::~usrp_source_base ()
{
- // delete d_usrp; // The base class deletes this via the d_usrp_basic
instance var
+ // delete d_usrp; // The base class deletes this via its d_usrp_basic
instance var
}
unsigned int
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Commit-gnuradio] r9911 - gnuradio/branches/developers/eb/cppdb-wip/gr-usrp/src,
eb <=