summaryrefslogtreecommitdiffstats
path: root/host/include
diff options
context:
space:
mode:
authorJosh Blum <josh@joshknows.com>2010-07-15 22:59:37 -0700
committerJosh Blum <josh@joshknows.com>2010-07-16 16:51:30 -0700
commitb25e610868752ac55b6f8e0c05bc2e0f7b18e223 (patch)
tree50ca897af5ab54b3d104a03fc9ec11058bfea55d /host/include
parent2ff23daec6e82661499a7cbbdea8d2ef7cc8711b (diff)
downloaduhd-b25e610868752ac55b6f8e0c05bc2e0f7b18e223.tar.gz
uhd-b25e610868752ac55b6f8e0c05bc2e0f7b18e223.tar.bz2
uhd-b25e610868752ac55b6f8e0c05bc2e0f7b18e223.zip
usrp: added functions to derive tuned frequency, tweaked logic, added unit test
Diffstat (limited to 'host/include')
-rw-r--r--host/include/uhd/types/tune_result.hpp10
-rw-r--r--host/include/uhd/usrp/mimo_usrp.hpp2
-rw-r--r--host/include/uhd/usrp/simple_usrp.hpp2
-rw-r--r--host/include/uhd/usrp/tune_helper.hpp112
4 files changed, 77 insertions, 49 deletions
diff --git a/host/include/uhd/types/tune_result.hpp b/host/include/uhd/types/tune_result.hpp
index c428a7692..9eebc161a 100644
--- a/host/include/uhd/types/tune_result.hpp
+++ b/host/include/uhd/types/tune_result.hpp
@@ -19,6 +19,7 @@
#define INCLUDED_UHD_TYPES_TUNE_RESULT_HPP
#include <uhd/config.hpp>
+#include <string>
namespace uhd{
@@ -28,15 +29,18 @@ namespace uhd{
* the target and actual intermediate frequency.
* The struct hold the result of tuning the DSP as
* the target and actual digital converter frequency.
- * It also tell us weather or not the spectrum is inverted.
*/
struct UHD_API tune_result_t{
double target_inter_freq;
double actual_inter_freq;
double target_dsp_freq;
double actual_dsp_freq;
- bool spectrum_inverted;
- tune_result_t(void);
+
+ /*!
+ * Create a pretty print string for this tune result struct.
+ * \return the printable string
+ */
+ std::string to_pp_string(void) const;
};
} //namespace uhd
diff --git a/host/include/uhd/usrp/mimo_usrp.hpp b/host/include/uhd/usrp/mimo_usrp.hpp
index 68a42cad8..fd0f4596f 100644
--- a/host/include/uhd/usrp/mimo_usrp.hpp
+++ b/host/include/uhd/usrp/mimo_usrp.hpp
@@ -124,6 +124,7 @@ public:
virtual tune_result_t set_rx_freq(size_t chan, double freq) = 0;
virtual tune_result_t set_rx_freq(size_t chan, double freq, double lo_off) = 0;
+ virtual double get_rx_freq(size_t chan) = 0;
virtual freq_range_t get_rx_freq_range(size_t chan) = 0;
virtual void set_rx_gain(size_t chan, float gain) = 0;
@@ -152,6 +153,7 @@ public:
virtual tune_result_t set_tx_freq(size_t chan, double freq) = 0;
virtual tune_result_t set_tx_freq(size_t chan, double freq, double lo_off) = 0;
+ virtual double get_tx_freq(size_t chan) = 0;
virtual freq_range_t get_tx_freq_range(size_t chan) = 0;
virtual void set_tx_gain(size_t chan, float gain) = 0;
diff --git a/host/include/uhd/usrp/simple_usrp.hpp b/host/include/uhd/usrp/simple_usrp.hpp
index 1d9136f08..a100579ce 100644
--- a/host/include/uhd/usrp/simple_usrp.hpp
+++ b/host/include/uhd/usrp/simple_usrp.hpp
@@ -112,6 +112,7 @@ public:
virtual tune_result_t set_rx_freq(double freq) = 0;
virtual tune_result_t set_rx_freq(double freq, double lo_off) = 0;
+ virtual double get_rx_freq(void) = 0;
virtual freq_range_t get_rx_freq_range(void) = 0;
virtual void set_rx_gain(float gain) = 0;
@@ -139,6 +140,7 @@ public:
virtual tune_result_t set_tx_freq(double freq) = 0;
virtual tune_result_t set_tx_freq(double freq, double lo_off) = 0;
+ virtual double get_tx_freq(void) = 0;
virtual freq_range_t get_tx_freq_range(void) = 0;
virtual void set_tx_gain(float gain) = 0;
diff --git a/host/include/uhd/usrp/tune_helper.hpp b/host/include/uhd/usrp/tune_helper.hpp
index f1e276d4f..df3907b3e 100644
--- a/host/include/uhd/usrp/tune_helper.hpp
+++ b/host/include/uhd/usrp/tune_helper.hpp
@@ -24,55 +24,75 @@
namespace uhd{ namespace usrp{
-/*!
- * Tune a rx chain to the desired frequency:
- * The IF of the subdevice is set as close as possible to
- * the given target frequency + the LO offset (when applicable).
- * The ddc cordic is setup to bring the IF down to baseband.
- * \param subdev the dboard subdevice object with properties
- * \param ddc the ddc properties object (with "if_rate", "bb_rate", "freq")
- * \param target_freq the desired center frequency
- * \param lo_offset an offset for the subdevice IF from center
- * \return a tune result struct
- */
-UHD_API tune_result_t tune_rx_subdev_and_ddc(
- wax::obj subdev, wax::obj ddc,
- double target_freq, double lo_offset
-);
+ /*!
+ * Tune a rx chain to the desired frequency:
+ * The IF of the subdevice is set as close as possible to
+ * the given target frequency + the LO offset (when applicable).
+ * The ddc cordic is setup to bring the IF down to baseband.
+ * \param subdev the dboard subdevice object with properties
+ * \param ddc the mboard dsp object with properties
+ * \param target_freq the desired center frequency
+ * \param lo_offset an offset for the subdevice IF from center
+ * \return a tune result struct
+ */
+ UHD_API tune_result_t tune_rx_subdev_and_dsp(
+ wax::obj subdev, wax::obj ddc,
+ double target_freq, double lo_offset
+ );
-/*!
- * Tune a rx chain to the desired frequency:
- * Same as the above, except the LO offset
- * is calculated based on the subdevice and BW.
- */
-UHD_API tune_result_t tune_rx_subdev_and_ddc(
- wax::obj subdev, wax::obj ddc, double target_freq
-);
+ /*!
+ * Tune a rx chain to the desired frequency:
+ * Same as the above, except the LO offset
+ * is calculated based on the subdevice and BW.
+ */
+ UHD_API tune_result_t tune_rx_subdev_and_dsp(
+ wax::obj subdev, wax::obj ddc, double target_freq
+ );
-/*!
- * Tune a tx chain to the desired frequency:
- * The IF of the subdevice is set as close as possible to
- * the given target frequency + the LO offset (when applicable).
- * The duc cordic is setup to bring the baseband up to IF.
- * \param subdev the dboard subdevice object with properties
- * \param duc the duc properties object (with "if_rate", "bb_rate", "freq")
- * \param target_freq the desired center frequency
- * \param lo_offset an offset for the subdevice IF from center
- * \return a tune result struct
- */
-UHD_API tune_result_t tune_tx_subdev_and_duc(
- wax::obj subdev, wax::obj duc,
- double target_freq, double lo_offset
-);
+ /*!
+ * Calculate the overall frequency from the combination of dboard IF and DDC shift.
+ * \param subdev the dboard subdevice object with properties
+ * \param ddc the mboard dsp object with properties
+ * \return the overall tune frequency of the system in Hz
+ */
+ UHD_API double derive_freq_from_rx_subdev_and_dsp(
+ wax::obj subdev, wax::obj ddc
+ );
-/*!
- * Tune a tx chain to the desired frequency:
- * Same as the above, except the LO offset
- * is calculated based on the subdevice and BW.
- */
-UHD_API tune_result_t tune_tx_subdev_and_duc(
- wax::obj subdev, wax::obj duc, double target_freq
-);
+ /*!
+ * Tune a tx chain to the desired frequency:
+ * The IF of the subdevice is set as close as possible to
+ * the given target frequency + the LO offset (when applicable).
+ * The duc cordic is setup to bring the baseband up to IF.
+ * \param subdev the dboard subdevice object with properties
+ * \param duc the mboard dsp object with properties
+ * \param target_freq the desired center frequency
+ * \param lo_offset an offset for the subdevice IF from center
+ * \return a tune result struct
+ */
+ UHD_API tune_result_t tune_tx_subdev_and_dsp(
+ wax::obj subdev, wax::obj duc,
+ double target_freq, double lo_offset
+ );
+
+ /*!
+ * Tune a tx chain to the desired frequency:
+ * Same as the above, except the LO offset
+ * is calculated based on the subdevice and BW.
+ */
+ UHD_API tune_result_t tune_tx_subdev_and_dsp(
+ wax::obj subdev, wax::obj duc, double target_freq
+ );
+
+ /*!
+ * Calculate the overall frequency from the combination of dboard IF and DUC shift.
+ * \param subdev the dboard subdevice object with properties
+ * \param duc the mboard dsp object with properties
+ * \return the overall tune frequency of the system in Hz
+ */
+ UHD_API double derive_freq_from_tx_subdev_and_dsp(
+ wax::obj subdev, wax::obj duc
+ );
}}