From 7d97ab60012b99ed92fb122a3a68d68515a404fa Mon Sep 17 00:00:00 2001 From: Martin Braun Date: Tue, 3 Feb 2015 17:20:09 +0100 Subject: multi_usrp: Added a normalized gain setting Adds more methods: {set,get}_normalized_{tx,rx}_gain() which allow changing and reading back the gain within [0, 1]. --- host/include/uhd/usrp/multi_usrp.hpp | 57 ++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) (limited to 'host/include') diff --git a/host/include/uhd/usrp/multi_usrp.hpp b/host/include/uhd/usrp/multi_usrp.hpp index 2362ebcd7..cebfda5a2 100644 --- a/host/include/uhd/usrp/multi_usrp.hpp +++ b/host/include/uhd/usrp/multi_usrp.hpp @@ -26,6 +26,7 @@ #define UHD_USRP_MULTI_USRP_BW_RANGE_API #define UHD_USRP_MULTI_USRP_USER_REGS_API #define UHD_USRP_MULTI_USRP_GET_USRP_INFO_API +#define UHD_USRP_MULTI_USRP_NORMALIZED_GAIN #include #include @@ -494,6 +495,24 @@ public: return this->set_rx_gain(gain, ALL_GAINS, chan); } + /*! + * Set the normalized RX gain value. + * + * The normalized gain is a value in [0, 1], where 0 is the + * smallest gain value available, and 1 is the largest, independent + * of the device. In between, gains are linearly interpolated. + * + * Check the individual device manual for notes on the gain range. + * + * Note that it is not possible to specify a gain name for + * this function, it will always set the overall gain. + * + * \param gain the normalized gain value + * \param chan the channel index 0 to N-1 + * \throws A uhd::runtime_error if the gain value is outside [0, 1]. + */ + virtual void set_normalized_rx_gain(double gain, size_t chan = 0) = 0; + /*! * Get the RX gain value for the specified gain element. * For an empty name, sum across all gain elements. @@ -508,6 +527,19 @@ public: return this->get_rx_gain(ALL_GAINS, chan); } + /*! + * Return the normalized RX gain value. + * + * See set_normalized_rx_gain() for a discussion of normalized + * gains. + * + * \param gain the normalized gain value + * \param chan the channel index 0 to N-1 + * \returns The normalized gain (in [0, 1]) + * \throws A uhd::runtime_error if the gain value is outside [0, 1]. + */ + virtual double get_normalized_rx_gain(size_t chan = 0) = 0; + /*! * Get the RX gain range for the specified gain element. * For an empty name, calculate the overall gain range. @@ -732,6 +764,18 @@ public: return this->set_tx_gain(gain, ALL_GAINS, chan); } + /*! + * Set the normalized TX gain value. + * + * See set_normalized_rx_gain() for a discussion on normalized + * gains. + * + * \param gain the normalized gain value + * \param chan the channel index 0 to N-1 + * \throws A uhd::runtime_error if the gain value is outside [0, 1]. + */ + virtual void set_normalized_tx_gain(double gain, size_t chan = 0) = 0; + /*! * Get the TX gain value for the specified gain element. * For an empty name, sum across all gain elements. @@ -746,6 +790,19 @@ public: return this->get_tx_gain(ALL_GAINS, chan); } + /*! + * Return the normalized TX gain value. + * + * See set_normalized_rx_gain() for a discussion of normalized + * gains. + * + * \param gain the normalized gain value + * \param chan the channel index 0 to N-1 + * \returns The normalized gain (in [0, 1]) + * \throws A uhd::runtime_error if the gain value is outside [0, 1]. + */ + virtual double get_normalized_tx_gain(size_t chan = 0) = 0; + /*! * Get the TX gain range for the specified gain element. * For an empty name, calculate the overall gain range. -- cgit v1.2.3