root / host / lib / usrp / dboard / db_rfx.cpp @ a809e3c2
History | View | Annotate | Download (19.7 kB)
| 1 |
//
|
|---|---|
| 2 |
// Copyright 2010 Ettus Research LLC
|
| 3 |
//
|
| 4 |
// This program is free software: you can redistribute it and/or modify
|
| 5 |
// it under the terms of the GNU General Public License as published by
|
| 6 |
// the Free Software Foundation, either version 3 of the License, or
|
| 7 |
// (at your option) any later version.
|
| 8 |
//
|
| 9 |
// This program is distributed in the hope that it will be useful,
|
| 10 |
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 11 |
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
| 12 |
// GNU General Public License for more details.
|
| 13 |
//
|
| 14 |
// You should have received a copy of the GNU General Public License
|
| 15 |
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
| 16 |
//
|
| 17 |
|
| 18 |
// IO Pin functions
|
| 19 |
#define POWER_IO (1 << 7) // Low enables power supply |
| 20 |
#define ANTSW_IO (1 << 6) // On TX DB, 0 = TX, 1 = RX, on RX DB 0 = main ant, 1 = RX2 |
| 21 |
#define MIXER_IO (1 << 5) // Enable appropriate mixer |
| 22 |
#define LOCKDET_MASK (1 << 2) // Input pin |
| 23 |
|
| 24 |
// Mixer constants
|
| 25 |
#define MIXER_ENB MIXER_IO
|
| 26 |
#define MIXER_DIS 0 |
| 27 |
|
| 28 |
// Power constants
|
| 29 |
#define POWER_UP 0 |
| 30 |
#define POWER_DOWN POWER_IO
|
| 31 |
|
| 32 |
// Antenna constants
|
| 33 |
#define ANT_TX 0 //the tx line is transmitting |
| 34 |
#define ANT_RX ANTSW_IO //the tx line is receiving |
| 35 |
#define ANT_TXRX 0 //the rx line is on txrx |
| 36 |
#define ANT_RX2 ANTSW_IO //the rx line in on rx2 |
| 37 |
#define ANT_XX 0 //dont care how the antenna is set |
| 38 |
|
| 39 |
#include "adf4360_regs.hpp" |
| 40 |
#include <uhd/types/dict.hpp> |
| 41 |
#include <uhd/usrp/subdev_props.hpp> |
| 42 |
#include <uhd/types/ranges.hpp> |
| 43 |
#include <uhd/utils/assert.hpp> |
| 44 |
#include <uhd/utils/static.hpp> |
| 45 |
#include <uhd/utils/algorithm.hpp> |
| 46 |
#include <uhd/usrp/dboard_id.hpp> |
| 47 |
#include <uhd/usrp/dboard_base.hpp> |
| 48 |
#include <uhd/usrp/dboard_manager.hpp> |
| 49 |
#include <boost/assign/list_of.hpp> |
| 50 |
#include <boost/format.hpp> |
| 51 |
#include <boost/math/special_functions/round.hpp> |
| 52 |
|
| 53 |
using namespace uhd; |
| 54 |
using namespace uhd::usrp; |
| 55 |
using namespace boost::assign; |
| 56 |
|
| 57 |
/***********************************************************************
|
| 58 |
* The RFX Series constants
|
| 59 |
**********************************************************************/
|
| 60 |
static const bool rfx_debug = false; |
| 61 |
|
| 62 |
static const prop_names_t rfx_tx_antennas = list_of("TX/RX"); |
| 63 |
|
| 64 |
static const prop_names_t rfx_rx_antennas = list_of("TX/RX")("RX2"); |
| 65 |
|
| 66 |
static const uhd::dict<std::string, gain_range_t> rfx_tx_gain_ranges; //empty |
| 67 |
|
| 68 |
static const uhd::dict<std::string, gain_range_t> rfx_rx_gain_ranges = map_list_of |
| 69 |
("PGA0", gain_range_t(0, 70, float(0.022))) |
| 70 |
; |
| 71 |
|
| 72 |
static const uhd::dict<std::string, gain_range_t> rfx400_rx_gain_ranges = map_list_of |
| 73 |
("PGA0", gain_range_t(0, 45, float(0.022))) |
| 74 |
; |
| 75 |
|
| 76 |
/***********************************************************************
|
| 77 |
* The RFX series of dboards
|
| 78 |
**********************************************************************/
|
| 79 |
class rfx_xcvr : public xcvr_dboard_base{ |
| 80 |
public:
|
| 81 |
rfx_xcvr( |
| 82 |
ctor_args_t args, |
| 83 |
const freq_range_t &freq_range,
|
| 84 |
bool rx_div2, bool tx_div2 |
| 85 |
); |
| 86 |
~rfx_xcvr(void);
|
| 87 |
|
| 88 |
void rx_get(const wax::obj &key, wax::obj &val); |
| 89 |
void rx_set(const wax::obj &key, const wax::obj &val); |
| 90 |
|
| 91 |
void tx_get(const wax::obj &key, wax::obj &val); |
| 92 |
void tx_set(const wax::obj &key, const wax::obj &val); |
| 93 |
|
| 94 |
private:
|
| 95 |
freq_range_t _freq_range; |
| 96 |
uhd::dict<std::string, gain_range_t> _rx_gain_ranges;
|
| 97 |
uhd::dict<dboard_iface::unit_t, bool> _div2;
|
| 98 |
double _rx_lo_freq, _tx_lo_freq;
|
| 99 |
std::string _rx_ant;
|
| 100 |
uhd::dict<std::string, float> _rx_gains; |
| 101 |
|
| 102 |
void set_rx_lo_freq(double freq); |
| 103 |
void set_tx_lo_freq(double freq); |
| 104 |
void set_rx_ant(const std::string &ant); |
| 105 |
void set_tx_ant(const std::string &ant); |
| 106 |
void set_rx_gain(float gain, const std::string &name); |
| 107 |
void set_tx_gain(float gain, const std::string &name); |
| 108 |
|
| 109 |
/*!
|
| 110 |
* Set the LO frequency for the particular dboard unit.
|
| 111 |
* \param unit which unit rx or tx
|
| 112 |
* \param target_freq the desired frequency in Hz
|
| 113 |
* \return the actual frequency in Hz
|
| 114 |
*/
|
| 115 |
double set_lo_freq(dboard_iface::unit_t unit, double target_freq); |
| 116 |
|
| 117 |
/*!
|
| 118 |
* Get the lock detect status of the LO.
|
| 119 |
* \param unit which unit rx or tx
|
| 120 |
* \return true for locked
|
| 121 |
*/
|
| 122 |
bool get_locked(dboard_iface::unit_t unit){
|
| 123 |
return (this->get_iface()->read_gpio(unit) & LOCKDET_MASK) != 0; |
| 124 |
} |
| 125 |
}; |
| 126 |
|
| 127 |
/***********************************************************************
|
| 128 |
* Register the RFX dboards (min freq, max freq, rx div2, tx div2)
|
| 129 |
**********************************************************************/
|
| 130 |
static dboard_base::sptr make_rfx_flex400(dboard_base::ctor_args_t args){
|
| 131 |
return dboard_base::sptr(new rfx_xcvr(args, freq_range_t(400e6, 500e6), false, true)); |
| 132 |
} |
| 133 |
|
| 134 |
static dboard_base::sptr make_rfx_flex900(dboard_base::ctor_args_t args){
|
| 135 |
return dboard_base::sptr(new rfx_xcvr(args, freq_range_t(750e6, 1050e6), true, true)); |
| 136 |
} |
| 137 |
|
| 138 |
static dboard_base::sptr make_rfx_flex1800(dboard_base::ctor_args_t args){
|
| 139 |
return dboard_base::sptr(new rfx_xcvr(args, freq_range_t(1500e6, 2100e6), false, false)); |
| 140 |
} |
| 141 |
|
| 142 |
static dboard_base::sptr make_rfx_flex1200(dboard_base::ctor_args_t args){
|
| 143 |
return dboard_base::sptr(new rfx_xcvr(args, freq_range_t(1150e6, 1450e6), true, true)); |
| 144 |
} |
| 145 |
|
| 146 |
static dboard_base::sptr make_rfx_flex2200(dboard_base::ctor_args_t args){
|
| 147 |
return dboard_base::sptr(new rfx_xcvr(args, freq_range_t(2000e6, 2400e6), false, false)); |
| 148 |
} |
| 149 |
|
| 150 |
static dboard_base::sptr make_rfx_flex2400(dboard_base::ctor_args_t args){
|
| 151 |
return dboard_base::sptr(new rfx_xcvr(args, freq_range_t(2300e6, 2900e6), false, false)); |
| 152 |
} |
| 153 |
|
| 154 |
UHD_STATIC_BLOCK(reg_rfx_dboards){
|
| 155 |
dboard_manager::register_dboard(0x0024, 0x0028, &make_rfx_flex400, "Flex 400 MIMO B"); |
| 156 |
dboard_manager::register_dboard(0x0025, 0x0029, &make_rfx_flex900, "Flex 900 MIMO B"); |
| 157 |
dboard_manager::register_dboard(0x0034, 0x0035, &make_rfx_flex1800, "Flex 1800 MIMO B"); |
| 158 |
dboard_manager::register_dboard(0x0026, 0x002a, &make_rfx_flex1200, "Flex 1200 MIMO B"); |
| 159 |
dboard_manager::register_dboard(0x002c, 0x002d, &make_rfx_flex2200, "Flex 2200 MIMO B"); |
| 160 |
dboard_manager::register_dboard(0x0027, 0x002b, &make_rfx_flex2400, "Flex 2400 MIMO B"); |
| 161 |
} |
| 162 |
|
| 163 |
/***********************************************************************
|
| 164 |
* Structors
|
| 165 |
**********************************************************************/
|
| 166 |
rfx_xcvr::rfx_xcvr( |
| 167 |
ctor_args_t args, |
| 168 |
const freq_range_t &freq_range,
|
| 169 |
bool rx_div2, bool tx_div2 |
| 170 |
) : xcvr_dboard_base(args){
|
| 171 |
_freq_range = freq_range; |
| 172 |
_div2[dboard_iface::UNIT_RX] = rx_div2; |
| 173 |
_div2[dboard_iface::UNIT_TX] = tx_div2; |
| 174 |
|
| 175 |
if(this->get_rx_id() == 0x0024) { //RFX400 |
| 176 |
_rx_gain_ranges = rfx400_rx_gain_ranges; |
| 177 |
} |
| 178 |
else {
|
| 179 |
_rx_gain_ranges = rfx_rx_gain_ranges; |
| 180 |
} |
| 181 |
|
| 182 |
|
| 183 |
//enable the clocks that we need
|
| 184 |
this->get_iface()->set_clock_enabled(dboard_iface::UNIT_TX, true); |
| 185 |
this->get_iface()->set_clock_enabled(dboard_iface::UNIT_RX, true); |
| 186 |
|
| 187 |
//set the gpio directions and atr controls (identically)
|
| 188 |
boost::uint16_t output_enables = POWER_IO | ANTSW_IO | MIXER_IO; |
| 189 |
this->get_iface()->set_pin_ctrl(dboard_iface::UNIT_TX, output_enables);
|
| 190 |
this->get_iface()->set_pin_ctrl(dboard_iface::UNIT_RX, output_enables);
|
| 191 |
this->get_iface()->set_gpio_ddr(dboard_iface::UNIT_TX, output_enables);
|
| 192 |
this->get_iface()->set_gpio_ddr(dboard_iface::UNIT_RX, output_enables);
|
| 193 |
|
| 194 |
//setup the tx atr (this does not change with antenna)
|
| 195 |
this->get_iface()->set_atr_reg(dboard_iface::UNIT_TX, dboard_iface::ATR_REG_IDLE, POWER_UP | ANT_XX | MIXER_DIS);
|
| 196 |
this->get_iface()->set_atr_reg(dboard_iface::UNIT_TX, dboard_iface::ATR_REG_RX_ONLY, POWER_UP | ANT_RX | MIXER_DIS);
|
| 197 |
this->get_iface()->set_atr_reg(dboard_iface::UNIT_TX, dboard_iface::ATR_REG_TX_ONLY, POWER_UP | ANT_TX | MIXER_ENB);
|
| 198 |
this->get_iface()->set_atr_reg(dboard_iface::UNIT_TX, dboard_iface::ATR_REG_FULL_DUPLEX, POWER_UP | ANT_TX | MIXER_ENB);
|
| 199 |
|
| 200 |
//setup the rx atr (this does not change with antenna)
|
| 201 |
this->get_iface()->set_atr_reg(dboard_iface::UNIT_RX, dboard_iface::ATR_REG_IDLE, POWER_UP | ANT_XX | MIXER_DIS);
|
| 202 |
this->get_iface()->set_atr_reg(dboard_iface::UNIT_RX, dboard_iface::ATR_REG_TX_ONLY, POWER_UP | ANT_XX | MIXER_DIS);
|
| 203 |
this->get_iface()->set_atr_reg(dboard_iface::UNIT_RX, dboard_iface::ATR_REG_FULL_DUPLEX, POWER_UP | ANT_RX2| MIXER_ENB);
|
| 204 |
|
| 205 |
//set some default values
|
| 206 |
set_rx_lo_freq((_freq_range.min + _freq_range.max)/2.0); |
| 207 |
set_tx_lo_freq((_freq_range.min + _freq_range.max)/2.0); |
| 208 |
set_rx_ant("RX2");
|
| 209 |
|
| 210 |
BOOST_FOREACH(const std::string &name, _rx_gain_ranges.keys()){ |
| 211 |
set_rx_gain(_rx_gain_ranges[name].min, name); |
| 212 |
} |
| 213 |
} |
| 214 |
|
| 215 |
rfx_xcvr::~rfx_xcvr(void){
|
| 216 |
/* NOP */
|
| 217 |
} |
| 218 |
|
| 219 |
/***********************************************************************
|
| 220 |
* Antenna Handling
|
| 221 |
**********************************************************************/
|
| 222 |
void rfx_xcvr::set_rx_ant(const std::string &ant){ |
| 223 |
//validate input
|
| 224 |
assert_has(rfx_rx_antennas, ant, "rfx rx antenna name");
|
| 225 |
|
| 226 |
//set the rx atr regs that change with antenna setting
|
| 227 |
this->get_iface()->set_atr_reg(
|
| 228 |
dboard_iface::UNIT_RX, dboard_iface::ATR_REG_RX_ONLY, |
| 229 |
POWER_UP | MIXER_ENB | ((ant == "TX/RX")? ANT_TXRX : ANT_RX2)
|
| 230 |
); |
| 231 |
|
| 232 |
//shadow the setting
|
| 233 |
_rx_ant = ant; |
| 234 |
} |
| 235 |
|
| 236 |
void rfx_xcvr::set_tx_ant(const std::string &ant){ |
| 237 |
assert_has(rfx_tx_antennas, ant, "rfx tx antenna name");
|
| 238 |
//only one antenna option, do nothing
|
| 239 |
} |
| 240 |
|
| 241 |
/***********************************************************************
|
| 242 |
* Gain Handling
|
| 243 |
**********************************************************************/
|
| 244 |
static float rx_pga0_gain_to_dac_volts(float &gain){ |
| 245 |
//voltage level constants (negative slope)
|
| 246 |
static const float max_volts = float(.2), min_volts = float(1.2); |
| 247 |
static const float slope = (max_volts-min_volts)/45; |
| 248 |
|
| 249 |
//calculate the voltage for the aux dac
|
| 250 |
float dac_volts = std::clip<float>(gain*slope + min_volts, max_volts, min_volts); |
| 251 |
|
| 252 |
//the actual gain setting
|
| 253 |
gain = (dac_volts - min_volts)/slope; |
| 254 |
|
| 255 |
return dac_volts;
|
| 256 |
} |
| 257 |
|
| 258 |
void rfx_xcvr::set_tx_gain(float, const std::string &name){ |
| 259 |
assert_has(rfx_tx_gain_ranges.keys(), name, "rfx tx gain name");
|
| 260 |
UHD_THROW_INVALID_CODE_PATH(); //no gains to set
|
| 261 |
} |
| 262 |
|
| 263 |
void rfx_xcvr::set_rx_gain(float gain, const std::string &name){ |
| 264 |
assert_has(_rx_gain_ranges.keys(), name, "rfx rx gain name");
|
| 265 |
if(name == "PGA0"){ |
| 266 |
float dac_volts = rx_pga0_gain_to_dac_volts(gain);
|
| 267 |
_rx_gains[name] = gain; |
| 268 |
|
| 269 |
//write the new voltage to the aux dac
|
| 270 |
this->get_iface()->write_aux_dac(dboard_iface::UNIT_RX, dboard_iface::AUX_DAC_A, dac_volts);
|
| 271 |
} |
| 272 |
else UHD_THROW_INVALID_CODE_PATH();
|
| 273 |
} |
| 274 |
|
| 275 |
/***********************************************************************
|
| 276 |
* Tuning
|
| 277 |
**********************************************************************/
|
| 278 |
void rfx_xcvr::set_rx_lo_freq(double freq){ |
| 279 |
_rx_lo_freq = set_lo_freq(dboard_iface::UNIT_RX, freq); |
| 280 |
} |
| 281 |
|
| 282 |
void rfx_xcvr::set_tx_lo_freq(double freq){ |
| 283 |
_tx_lo_freq = set_lo_freq(dboard_iface::UNIT_TX, freq); |
| 284 |
} |
| 285 |
|
| 286 |
double rfx_xcvr::set_lo_freq(
|
| 287 |
dboard_iface::unit_t unit, |
| 288 |
double target_freq
|
| 289 |
){
|
| 290 |
if (rfx_debug) std::cerr << boost::format(
|
| 291 |
"RFX tune: target frequency %f Mhz"
|
| 292 |
) % (target_freq/1e6) << std::endl;
|
| 293 |
|
| 294 |
//clip the input
|
| 295 |
target_freq = std::clip(target_freq, _freq_range.min, _freq_range.max); |
| 296 |
if (_div2[unit]) target_freq *= 2; |
| 297 |
|
| 298 |
//map prescalers to the register enums
|
| 299 |
static const uhd::dict<int, adf4360_regs_t::prescaler_value_t> prescaler_to_enum = map_list_of |
| 300 |
(8, adf4360_regs_t::PRESCALER_VALUE_8_9)
|
| 301 |
(16, adf4360_regs_t::PRESCALER_VALUE_16_17)
|
| 302 |
(32, adf4360_regs_t::PRESCALER_VALUE_32_33)
|
| 303 |
; |
| 304 |
|
| 305 |
//map band select clock dividers to enums
|
| 306 |
static const uhd::dict<int, adf4360_regs_t::band_select_clock_div_t> bandsel_to_enum = map_list_of |
| 307 |
(1, adf4360_regs_t::BAND_SELECT_CLOCK_DIV_1)
|
| 308 |
(2, adf4360_regs_t::BAND_SELECT_CLOCK_DIV_2)
|
| 309 |
(4, adf4360_regs_t::BAND_SELECT_CLOCK_DIV_4)
|
| 310 |
(8, adf4360_regs_t::BAND_SELECT_CLOCK_DIV_8)
|
| 311 |
; |
| 312 |
|
| 313 |
double actual_freq=0, ref_freq = this->get_iface()->get_clock_rate(unit); |
| 314 |
int R=0, BS=0, P=0, B=0, A=0; |
| 315 |
|
| 316 |
/*
|
| 317 |
* The goal here to to loop though possible R dividers,
|
| 318 |
* band select clock dividers, and prescaler values.
|
| 319 |
* Calculate the A and B counters for each set of values.
|
| 320 |
* The loop exists when it meets all of the constraints.
|
| 321 |
* The resulting loop values are loaded into the registers.
|
| 322 |
*
|
| 323 |
* fvco = [P*B + A] * fref/R
|
| 324 |
* fvco*R/fref = P*B + A = N
|
| 325 |
*/
|
| 326 |
for(R = 2; R <= 32; R+=2){ |
| 327 |
BOOST_FOREACH(BS, bandsel_to_enum.keys()){
|
| 328 |
if (ref_freq/R/BS > 1e6) continue; //constraint on band select clock |
| 329 |
BOOST_FOREACH(P, prescaler_to_enum.keys()){
|
| 330 |
//calculate B and A from N
|
| 331 |
double N = target_freq*R/ref_freq;
|
| 332 |
B = int(std::floor(N/P));
|
| 333 |
A = boost::math::iround(N - P*B); |
| 334 |
if (B < A or B > 8191 or B < 3 or A > 31) continue; //constraints on A, B |
| 335 |
//calculate the actual frequency
|
| 336 |
actual_freq = double(P*B + A)*ref_freq/R;
|
| 337 |
if (actual_freq/P > 300e6) continue; //constraint on prescaler output |
| 338 |
//constraints met: exit loop
|
| 339 |
goto done_loop;
|
| 340 |
} |
| 341 |
} |
| 342 |
} done_loop:
|
| 343 |
|
| 344 |
if (rfx_debug) std::cerr << boost::format(
|
| 345 |
"RFX tune: R=%d, BS=%d, P=%d, B=%d, A=%d"
|
| 346 |
) % R % BS % P % B % A << std::endl; |
| 347 |
|
| 348 |
//load the register values
|
| 349 |
adf4360_regs_t regs; |
| 350 |
regs.core_power_level = adf4360_regs_t::CORE_POWER_LEVEL_10MA; |
| 351 |
regs.counter_operation = adf4360_regs_t::COUNTER_OPERATION_NORMAL; |
| 352 |
regs.muxout_control = adf4360_regs_t::MUXOUT_CONTROL_DLD; |
| 353 |
regs.phase_detector_polarity = adf4360_regs_t::PHASE_DETECTOR_POLARITY_POS; |
| 354 |
regs.charge_pump_output = adf4360_regs_t::CHARGE_PUMP_OUTPUT_NORMAL; |
| 355 |
regs.cp_gain_0 = adf4360_regs_t::CP_GAIN_0_SET1; |
| 356 |
regs.mute_till_ld = adf4360_regs_t::MUTE_TILL_LD_ENB; |
| 357 |
regs.output_power_level = adf4360_regs_t::OUTPUT_POWER_LEVEL_3_5MA; |
| 358 |
regs.current_setting1 = adf4360_regs_t::CURRENT_SETTING1_0_31MA; |
| 359 |
regs.current_setting2 = adf4360_regs_t::CURRENT_SETTING2_0_31MA; |
| 360 |
regs.power_down = adf4360_regs_t::POWER_DOWN_NORMAL_OP; |
| 361 |
regs.prescaler_value = prescaler_to_enum[P]; |
| 362 |
regs.a_counter = A; |
| 363 |
regs.b_counter = B; |
| 364 |
regs.cp_gain_1 = adf4360_regs_t::CP_GAIN_1_SET1; |
| 365 |
regs.divide_by_2_output = (_div2[unit])? |
| 366 |
adf4360_regs_t::DIVIDE_BY_2_OUTPUT_DIV2 : |
| 367 |
adf4360_regs_t::DIVIDE_BY_2_OUTPUT_FUND ; |
| 368 |
regs.divide_by_2_prescaler = adf4360_regs_t::DIVIDE_BY_2_PRESCALER_FUND; |
| 369 |
regs.r_counter = R; |
| 370 |
regs.ablpw = adf4360_regs_t::ABLPW_3_0NS; |
| 371 |
regs.lock_detect_precision = adf4360_regs_t::LOCK_DETECT_PRECISION_5CYCLES; |
| 372 |
regs.test_mode_bit = 0;
|
| 373 |
regs.band_select_clock_div = bandsel_to_enum[BS]; |
| 374 |
|
| 375 |
//write the registers
|
| 376 |
std::vector<adf4360_regs_t::addr_t> addrs = list_of //correct power-up sequence to write registers (R, C, N)
|
| 377 |
(adf4360_regs_t::ADDR_RCOUNTER) |
| 378 |
(adf4360_regs_t::ADDR_CONTROL) |
| 379 |
(adf4360_regs_t::ADDR_NCOUNTER) |
| 380 |
; |
| 381 |
BOOST_FOREACH(adf4360_regs_t::addr_t addr, addrs){
|
| 382 |
this->get_iface()->write_spi(
|
| 383 |
unit, spi_config_t::EDGE_RISE, |
| 384 |
regs.get_reg(addr), 24
|
| 385 |
); |
| 386 |
} |
| 387 |
|
| 388 |
//return the actual frequency
|
| 389 |
if (_div2[unit]) actual_freq /= 2; |
| 390 |
if (rfx_debug) std::cerr << boost::format(
|
| 391 |
"RFX tune: actual frequency %f Mhz"
|
| 392 |
) % (actual_freq/1e6) << std::endl;
|
| 393 |
return actual_freq;
|
| 394 |
} |
| 395 |
|
| 396 |
/***********************************************************************
|
| 397 |
* RX Get and Set
|
| 398 |
**********************************************************************/
|
| 399 |
void rfx_xcvr::rx_get(const wax::obj &key_, wax::obj &val){ |
| 400 |
wax::obj key; std::string name;
|
| 401 |
boost::tie(key, name) = extract_named_prop(key_); |
| 402 |
|
| 403 |
//handle the get request conditioned on the key
|
| 404 |
switch(key.as<subdev_prop_t>()){
|
| 405 |
case SUBDEV_PROP_NAME:
|
| 406 |
val = get_rx_id().to_pp_string(); |
| 407 |
return;
|
| 408 |
|
| 409 |
case SUBDEV_PROP_OTHERS:
|
| 410 |
val = prop_names_t(); //empty
|
| 411 |
return;
|
| 412 |
|
| 413 |
case SUBDEV_PROP_GAIN:
|
| 414 |
assert_has(_rx_gains.keys(), name, "rfx rx gain name");
|
| 415 |
val = _rx_gains[name]; |
| 416 |
return;
|
| 417 |
|
| 418 |
case SUBDEV_PROP_GAIN_RANGE:
|
| 419 |
assert_has(_rx_gain_ranges.keys(), name, "rfx rx gain name");
|
| 420 |
val = _rx_gain_ranges[name]; |
| 421 |
return;
|
| 422 |
|
| 423 |
case SUBDEV_PROP_GAIN_NAMES:
|
| 424 |
val = prop_names_t(_rx_gain_ranges.keys()); |
| 425 |
return;
|
| 426 |
|
| 427 |
case SUBDEV_PROP_FREQ:
|
| 428 |
val = _rx_lo_freq; |
| 429 |
return;
|
| 430 |
|
| 431 |
case SUBDEV_PROP_FREQ_RANGE:
|
| 432 |
val = _freq_range; |
| 433 |
return;
|
| 434 |
|
| 435 |
case SUBDEV_PROP_ANTENNA:
|
| 436 |
val = _rx_ant; |
| 437 |
return;
|
| 438 |
|
| 439 |
case SUBDEV_PROP_ANTENNA_NAMES:
|
| 440 |
val = rfx_rx_antennas; |
| 441 |
return;
|
| 442 |
|
| 443 |
case SUBDEV_PROP_CONNECTION:
|
| 444 |
val = SUBDEV_CONN_COMPLEX_QI; |
| 445 |
return;
|
| 446 |
|
| 447 |
case SUBDEV_PROP_USE_LO_OFFSET:
|
| 448 |
val = false;
|
| 449 |
return;
|
| 450 |
|
| 451 |
case SUBDEV_PROP_LO_LOCKED:
|
| 452 |
val = this->get_locked(dboard_iface::UNIT_RX);
|
| 453 |
return;
|
| 454 |
|
| 455 |
default: UHD_THROW_PROP_GET_ERROR();
|
| 456 |
} |
| 457 |
} |
| 458 |
|
| 459 |
void rfx_xcvr::rx_set(const wax::obj &key_, const wax::obj &val){ |
| 460 |
wax::obj key; std::string name;
|
| 461 |
boost::tie(key, name) = extract_named_prop(key_); |
| 462 |
|
| 463 |
//handle the get request conditioned on the key
|
| 464 |
switch(key.as<subdev_prop_t>()){
|
| 465 |
|
| 466 |
case SUBDEV_PROP_FREQ:
|
| 467 |
this->set_rx_lo_freq(val.as<double>()); |
| 468 |
return;
|
| 469 |
|
| 470 |
case SUBDEV_PROP_GAIN:
|
| 471 |
this->set_rx_gain(val.as<float>(), name); |
| 472 |
return;
|
| 473 |
|
| 474 |
case SUBDEV_PROP_ANTENNA:
|
| 475 |
this->set_rx_ant(val.as<std::string>()); |
| 476 |
return;
|
| 477 |
|
| 478 |
default: UHD_THROW_PROP_SET_ERROR();
|
| 479 |
} |
| 480 |
} |
| 481 |
|
| 482 |
/***********************************************************************
|
| 483 |
* TX Get and Set
|
| 484 |
**********************************************************************/
|
| 485 |
void rfx_xcvr::tx_get(const wax::obj &key_, wax::obj &val){ |
| 486 |
wax::obj key; std::string name;
|
| 487 |
boost::tie(key, name) = extract_named_prop(key_); |
| 488 |
|
| 489 |
//handle the get request conditioned on the key
|
| 490 |
switch(key.as<subdev_prop_t>()){
|
| 491 |
case SUBDEV_PROP_NAME:
|
| 492 |
val = get_tx_id().to_pp_string(); |
| 493 |
return;
|
| 494 |
|
| 495 |
case SUBDEV_PROP_OTHERS:
|
| 496 |
val = prop_names_t(); //empty
|
| 497 |
return;
|
| 498 |
|
| 499 |
case SUBDEV_PROP_GAIN:
|
| 500 |
case SUBDEV_PROP_GAIN_RANGE:
|
| 501 |
assert_has(rfx_tx_gain_ranges.keys(), name, "rfx tx gain name");
|
| 502 |
//no controllable tx gains, will not get here
|
| 503 |
return;
|
| 504 |
|
| 505 |
case SUBDEV_PROP_GAIN_NAMES:
|
| 506 |
val = prop_names_t(rfx_tx_gain_ranges.keys()); |
| 507 |
return;
|
| 508 |
|
| 509 |
case SUBDEV_PROP_FREQ:
|
| 510 |
val = _tx_lo_freq; |
| 511 |
return;
|
| 512 |
|
| 513 |
case SUBDEV_PROP_FREQ_RANGE:
|
| 514 |
val = _freq_range; |
| 515 |
return;
|
| 516 |
|
| 517 |
case SUBDEV_PROP_ANTENNA:
|
| 518 |
val = std::string("TX/RX"); |
| 519 |
return;
|
| 520 |
|
| 521 |
case SUBDEV_PROP_ANTENNA_NAMES:
|
| 522 |
val = rfx_tx_antennas; |
| 523 |
return;
|
| 524 |
|
| 525 |
case SUBDEV_PROP_CONNECTION:
|
| 526 |
val = SUBDEV_CONN_COMPLEX_IQ; |
| 527 |
return;
|
| 528 |
|
| 529 |
case SUBDEV_PROP_USE_LO_OFFSET:
|
| 530 |
val = true;
|
| 531 |
return;
|
| 532 |
|
| 533 |
case SUBDEV_PROP_LO_LOCKED:
|
| 534 |
val = this->get_locked(dboard_iface::UNIT_TX);
|
| 535 |
return;
|
| 536 |
|
| 537 |
default: UHD_THROW_PROP_GET_ERROR();
|
| 538 |
} |
| 539 |
} |
| 540 |
|
| 541 |
void rfx_xcvr::tx_set(const wax::obj &key_, const wax::obj &val){ |
| 542 |
wax::obj key; std::string name;
|
| 543 |
boost::tie(key, name) = extract_named_prop(key_); |
| 544 |
|
| 545 |
//handle the get request conditioned on the key
|
| 546 |
switch(key.as<subdev_prop_t>()){
|
| 547 |
|
| 548 |
case SUBDEV_PROP_FREQ:
|
| 549 |
this->set_tx_lo_freq(val.as<double>()); |
| 550 |
return;
|
| 551 |
|
| 552 |
case SUBDEV_PROP_GAIN:
|
| 553 |
this->set_tx_gain(val.as<float>(), name); |
| 554 |
return;
|
| 555 |
|
| 556 |
case SUBDEV_PROP_ANTENNA:
|
| 557 |
this->set_tx_ant(val.as<std::string>()); |
| 558 |
return;
|
| 559 |
|
| 560 |
default: UHD_THROW_PROP_SET_ERROR();
|
| 561 |
} |
| 562 |
} |