Statistics
| Branch: | Tag: | Revision:

root / host / lib / usrp / dboard / db_xcvr2450.cpp @ 98ba0cc0

History | View | Annotate | Download (21.4 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
// TX IO Pins
19
#define HB_PA_OFF_TXIO      (1 << 15)    // 5GHz PA, 1 = off, 0 = on
20
#define LB_PA_OFF_TXIO      (1 << 14)    // 2.4GHz PA, 1 = off, 0 = on
21
#define ANTSEL_TX1_RX2_TXIO (1 << 13)    // 1 = Ant 1 to TX, Ant 2 to RX
22
#define ANTSEL_TX2_RX1_TXIO (1 << 12)    // 1 = Ant 2 to TX, Ant 1 to RX
23
#define TX_EN_TXIO          (1 << 11)    // 1 = TX on, 0 = TX off
24
#define AD9515DIV_TXIO      (1 << 4)     // 1 = Div  by 3, 0 = Div by 2
25

    
26
#define TXIO_MASK (HB_PA_OFF_TXIO | LB_PA_OFF_TXIO | ANTSEL_TX1_RX2_TXIO | ANTSEL_TX2_RX1_TXIO | TX_EN_TXIO | AD9515DIV_TXIO)
27

    
28
// TX IO Functions
29
#define HB_PA_TXIO               LB_PA_OFF_TXIO
30
#define LB_PA_TXIO               HB_PA_OFF_TXIO
31
#define TX_ENB_TXIO              TX_EN_TXIO
32
#define TX_DIS_TXIO              0
33
#define AD9515DIV_3_TXIO         AD9515DIV_TXIO
34
#define AD9515DIV_2_TXIO         0
35

    
36
// RX IO Pins
37
#define LOCKDET_RXIO (1 << 15)           // This is an INPUT!!!
38
#define POWER_RXIO   (1 << 14)           // 1 = power on, 0 = shutdown
39
#define RX_EN_RXIO   (1 << 13)           // 1 = RX on, 0 = RX off
40
#define RX_HP_RXIO   (1 << 12)           // 0 = Fc set by rx_hpf, 1 = 600 KHz
41

    
42
#define RXIO_MASK (POWER_RXIO | RX_EN_RXIO | RX_HP_RXIO)
43

    
44
// RX IO Functions
45
#define POWER_UP_RXIO            POWER_RXIO
46
#define POWER_DOWN_RXIO          0
47
#define RX_ENB_RXIO              RX_EN_RXIO
48
#define RX_DIS_RXIO              0
49

    
50
#include "max2829_regs.hpp"
51
#include <uhd/utils/static.hpp>
52
#include <uhd/utils/assert.hpp>
53
#include <uhd/utils/algorithm.hpp>
54
#include <uhd/types/ranges.hpp>
55
#include <uhd/types/dict.hpp>
56
#include <uhd/usrp/subdev_props.hpp>
57
#include <uhd/usrp/dboard_base.hpp>
58
#include <uhd/usrp/dboard_manager.hpp>
59
#include <boost/assign/list_of.hpp>
60
#include <boost/format.hpp>
61
#include <boost/thread.hpp>
62
#include <boost/math/special_functions/round.hpp>
63
#include <utility>
64

    
65
using namespace uhd;
66
using namespace uhd::usrp;
67
using namespace boost::assign;
68

    
69
/***********************************************************************
70
 * The XCVR 2450 constants
71
 **********************************************************************/
72
static const bool xcvr2450_debug = false;
73

    
74
static const freq_range_t xcvr_freq_range(2.4e9, 6.0e9);
75

    
76
static const prop_names_t xcvr_antennas = list_of("J1")("J2");
77

    
78
static const uhd::dict<std::string, gain_range_t> xcvr_tx_gain_ranges = map_list_of
79
    ("VGA", gain_range_t(0, 30, 0.5))
80
    ("BB", gain_range_t(0, 5, 1.5))
81
;
82
static const uhd::dict<std::string, gain_range_t> xcvr_rx_gain_ranges = map_list_of
83
    ("LNA", gain_range_t(0, 30.5, 15))
84
    ("VGA", gain_range_t(0, 62, 2.0))
85
;
86

    
87
/***********************************************************************
88
 * The XCVR 2450 dboard class
89
 **********************************************************************/
90
class xcvr2450 : public xcvr_dboard_base{
91
public:
92
    xcvr2450(ctor_args_t args);
93
    ~xcvr2450(void);
94

    
95
    void rx_get(const wax::obj &key, wax::obj &val);
96
    void rx_set(const wax::obj &key, const wax::obj &val);
97

    
98
    void tx_get(const wax::obj &key, wax::obj &val);
99
    void tx_set(const wax::obj &key, const wax::obj &val);
100

    
101
private:
102
    double _lo_freq;
103
    uhd::dict<std::string, float> _tx_gains, _rx_gains;
104
    std::string _tx_ant, _rx_ant;
105
    int _ad9515div;
106
    max2829_regs_t _max2829_regs;
107

    
108
    void set_lo_freq(double target_freq);
109
    void set_tx_ant(const std::string &ant);
110
    void set_rx_ant(const std::string &ant);
111
    void set_tx_gain(float gain, const std::string &name);
112
    void set_rx_gain(float gain, const std::string &name);
113

    
114
    void update_atr(void);
115
    void spi_reset(void);
116
    void send_reg(boost::uint8_t addr){
117
        boost::uint32_t value = _max2829_regs.get_reg(addr);
118
        if(xcvr2450_debug) std::cerr << boost::format(
119
            "XCVR2450: send reg 0x%02x, value 0x%05x"
120
        ) % int(addr) % value << std::endl;
121
        this->get_iface()->write_spi(
122
            dboard_iface::UNIT_RX,
123
            spi_config_t::EDGE_RISE,
124
            value, 24
125
        );
126
    }
127

    
128
    static bool is_highband(double freq){return freq > 3e9;}
129

    
130
    /*!
131
     * Is the LO locked?
132
     * \return true for locked
133
     */
134
    bool get_locked(void){
135
        return (this->get_iface()->read_gpio(dboard_iface::UNIT_RX) & LOCKDET_RXIO) != 0;
136
    }
137

    
138
    /*!
139
     * Read the RSSI from the aux adc
140
     * \return the rssi in dB
141
     */
142
    float get_rssi(void){
143
        //constants for the rssi calculation
144
        static const float min_v = float(0.5), max_v = float(2.5);
145
        static const float rssi_dyn_range = 60;
146
        //calculate the rssi from the voltage
147
        float voltage = this->get_iface()->read_aux_adc(dboard_iface::UNIT_RX, dboard_iface::AUX_ADC_B);
148
        return rssi_dyn_range*(voltage - min_v)/(max_v - min_v);
149
    }
150
};
151

    
152
/***********************************************************************
153
 * Register the XCVR 2450 dboard
154
 **********************************************************************/
155
static dboard_base::sptr make_xcvr2450(dboard_base::ctor_args_t args){
156
    return dboard_base::sptr(new xcvr2450(args));
157
}
158

    
159
UHD_STATIC_BLOCK(reg_xcvr2450_dboard){
160
    //register the factory function for the rx and tx dbids
161
    dboard_manager::register_dboard(0x0061, 0x0060, &make_xcvr2450, "XCVR2450");
162
}
163

    
164
/***********************************************************************
165
 * Structors
166
 **********************************************************************/
167
xcvr2450::xcvr2450(ctor_args_t args) : xcvr_dboard_base(args){
168
    //enable only the clocks we need
169
    this->get_iface()->set_clock_enabled(dboard_iface::UNIT_TX, true);
170

    
171
    //set the gpio directions and atr controls (identically)
172
    this->get_iface()->set_pin_ctrl(dboard_iface::UNIT_TX, TXIO_MASK);
173
    this->get_iface()->set_pin_ctrl(dboard_iface::UNIT_RX, RXIO_MASK);
174
    this->get_iface()->set_gpio_ddr(dboard_iface::UNIT_TX, TXIO_MASK);
175
    this->get_iface()->set_gpio_ddr(dboard_iface::UNIT_RX, RXIO_MASK);
176

    
177
    spi_reset(); //prepare the spi
178

    
179
    //setup the misc max2829 registers
180
    _max2829_regs.mimo_select         = max2829_regs_t::MIMO_SELECT_MIMO;
181
    _max2829_regs.band_sel_mimo       = max2829_regs_t::BAND_SEL_MIMO_MIMO;
182
    _max2829_regs.pll_cp_select       = max2829_regs_t::PLL_CP_SELECT_4MA;
183
    _max2829_regs.rssi_high_bw        = max2829_regs_t::RSSI_HIGH_BW_6MHZ;
184
    _max2829_regs.tx_lpf_coarse_adj   = max2829_regs_t::TX_LPF_COARSE_ADJ_12MHZ;
185
    _max2829_regs.rx_lpf_coarse_adj   = max2829_regs_t::RX_LPF_COARSE_ADJ_9_5MHZ;
186
    _max2829_regs.rx_lpf_fine_adj     = max2829_regs_t::RX_LPF_FINE_ADJ_95;
187
    _max2829_regs.rx_vga_gain_spi     = max2829_regs_t::RX_VGA_GAIN_SPI_SPI;
188
    _max2829_regs.rssi_output_range   = max2829_regs_t::RSSI_OUTPUT_RANGE_HIGH;
189
    _max2829_regs.rssi_op_mode        = max2829_regs_t::RSSI_OP_MODE_ENABLED;
190
    _max2829_regs.rssi_pin_fcn        = max2829_regs_t::RSSI_PIN_FCN_RSSI;
191
    _max2829_regs.rx_highpass         = max2829_regs_t::RX_HIGHPASS_100HZ;
192
    _max2829_regs.tx_vga_gain_spi     = max2829_regs_t::TX_VGA_GAIN_SPI_SPI;
193
    _max2829_regs.pa_driver_linearity = max2829_regs_t::PA_DRIVER_LINEARITY_78;
194
    _max2829_regs.tx_vga_linearity    = max2829_regs_t::TX_VGA_LINEARITY_78;
195
    _max2829_regs.tx_upconv_linearity = max2829_regs_t::TX_UPCONV_LINEARITY_78;
196

    
197
    //send initial register settings
198
    for(boost::uint8_t reg = 0x2; reg <= 0xC; reg++){
199
        this->send_reg(reg);
200
    }
201

    
202
    //set defaults for LO, gains, antennas
203
    set_lo_freq(2.45e9);
204
    set_rx_ant(xcvr_antennas.at(0));
205
    set_tx_ant(xcvr_antennas.at(1));
206
    BOOST_FOREACH(const std::string &name, xcvr_tx_gain_ranges.keys()){
207
        set_tx_gain(xcvr_tx_gain_ranges[name].min, name);
208
    }
209
    BOOST_FOREACH(const std::string &name, xcvr_rx_gain_ranges.keys()){
210
        set_rx_gain(xcvr_rx_gain_ranges[name].min, name);
211
    }
212
}
213

    
214
xcvr2450::~xcvr2450(void){
215
    spi_reset();
216
}
217

    
218
void xcvr2450::spi_reset(void){
219
    //spi reset mode: global enable = off, tx and rx enable = on
220
    this->get_iface()->set_atr_reg(dboard_iface::UNIT_TX, dboard_iface::ATR_REG_IDLE, TX_ENB_TXIO);
221
    this->get_iface()->set_atr_reg(dboard_iface::UNIT_RX, dboard_iface::ATR_REG_IDLE, RX_ENB_RXIO | POWER_DOWN_RXIO);
222
    boost::this_thread::sleep(boost::posix_time::milliseconds(10));
223

    
224
    //take it back out of spi reset mode and wait a bit
225
    this->get_iface()->set_atr_reg(dboard_iface::UNIT_RX, dboard_iface::ATR_REG_IDLE, RX_DIS_RXIO | POWER_UP_RXIO);
226
    boost::this_thread::sleep(boost::posix_time::milliseconds(10));
227
}
228

    
229
void xcvr2450::update_atr(void){
230
    //calculate tx atr pins
231
    int band_sel   = (xcvr2450::is_highband(_lo_freq))? HB_PA_TXIO : LB_PA_TXIO;
232
    int tx_ant_sel = (_tx_ant == "J1")? ANTSEL_TX1_RX2_TXIO : ANTSEL_TX2_RX1_TXIO;
233
    int rx_ant_sel = (_rx_ant == "J2")? ANTSEL_TX1_RX2_TXIO : ANTSEL_TX2_RX1_TXIO;
234
    int xx_ant_sel = tx_ant_sel; //prefer the tx antenna selection for full duplex (rx will get the other antenna)
235
    int ad9515div  = (_ad9515div == 3)? AD9515DIV_3_TXIO : AD9515DIV_2_TXIO;
236

    
237
    //set the tx registers
238
    this->get_iface()->set_atr_reg(dboard_iface::UNIT_TX, dboard_iface::ATR_REG_IDLE,        band_sel | ad9515div | TX_DIS_TXIO);
239
    this->get_iface()->set_atr_reg(dboard_iface::UNIT_TX, dboard_iface::ATR_REG_RX_ONLY,     band_sel | ad9515div | TX_DIS_TXIO | rx_ant_sel);
240
    this->get_iface()->set_atr_reg(dboard_iface::UNIT_TX, dboard_iface::ATR_REG_TX_ONLY,     band_sel | ad9515div | TX_ENB_TXIO | tx_ant_sel);
241
    this->get_iface()->set_atr_reg(dboard_iface::UNIT_TX, dboard_iface::ATR_REG_FULL_DUPLEX, band_sel | ad9515div | TX_ENB_TXIO | xx_ant_sel);
242

    
243
    //set the rx registers
244
    this->get_iface()->set_atr_reg(dboard_iface::UNIT_RX, dboard_iface::ATR_REG_IDLE,        POWER_UP_RXIO | RX_DIS_RXIO);
245
    this->get_iface()->set_atr_reg(dboard_iface::UNIT_RX, dboard_iface::ATR_REG_RX_ONLY,     POWER_UP_RXIO | RX_ENB_RXIO);
246
    this->get_iface()->set_atr_reg(dboard_iface::UNIT_RX, dboard_iface::ATR_REG_TX_ONLY,     POWER_UP_RXIO | RX_DIS_RXIO);
247
    this->get_iface()->set_atr_reg(dboard_iface::UNIT_RX, dboard_iface::ATR_REG_FULL_DUPLEX, POWER_UP_RXIO | RX_ENB_RXIO);
248
}
249

    
250
/***********************************************************************
251
 * Tuning
252
 **********************************************************************/
253
void xcvr2450::set_lo_freq(double target_freq){
254
    target_freq = std::clip(target_freq, xcvr_freq_range.min, xcvr_freq_range.max);
255
    //TODO: clip for highband and lowband
256

    
257
    //variables used in the calculation below
258
    double scaler = xcvr2450::is_highband(target_freq)? (4.0/5.0) : (4.0/3.0);
259
    double ref_freq = this->get_iface()->get_clock_rate(dboard_iface::UNIT_TX);
260
    int R, intdiv, fracdiv;
261

    
262
    //loop through values until we get a match
263
    for(_ad9515div = 2; _ad9515div <= 3; _ad9515div++){
264
        for(R = 1; R <= 7; R++){
265
            double N = (target_freq*scaler*R*_ad9515div)/ref_freq;
266
            intdiv = int(std::floor(N));
267
            fracdiv = boost::math::iround((N - intdiv)*double(1 << 16));
268
            //actual minimum is 128, but most chips seems to require higher to lock
269
            if (intdiv < 131 or intdiv > 255) continue;
270
            //constraints met: exit loop
271
            goto done_loop;
272
        }
273
    } done_loop:
274

    
275
    //calculate the actual freq from the values above
276
    double N = double(intdiv) + double(fracdiv)/double(1 << 16);
277
    _lo_freq = (N*ref_freq)/(scaler*R*_ad9515div);
278

    
279
    if (xcvr2450_debug) std::cerr
280
        << boost::format("XCVR2450 tune:\n")
281
        << boost::format("    R=%d, N=%f, ad9515=%d, scaler=%f\n") % R % N % _ad9515div % scaler
282
        << boost::format("    Ref    Freq=%fMHz\n") % (ref_freq/1e6)
283
        << boost::format("    Target Freq=%fMHz\n") % (target_freq/1e6)
284
        << boost::format("    Actual Freq=%fMHz\n") % (_lo_freq/1e6)
285
        << std::endl;
286

    
287
    //high-high band or low-high band?
288
    if(_lo_freq > (5.35e9 + 5.47e9)/2.0){
289
        if (xcvr2450_debug) std::cerr << "XCVR2450 tune: Using  high-high band" << std::endl;
290
        _max2829_regs.band_select_802_11a = max2829_regs_t::BAND_SELECT_802_11A_5_47GHZ_TO_5_875GHZ;
291
    }else{
292
        if (xcvr2450_debug) std::cerr << "XCVR2450 tune: Using  low-high band" << std::endl;
293
        _max2829_regs.band_select_802_11a = max2829_regs_t::BAND_SELECT_802_11A_4_9GHZ_TO_5_35GHZ;
294
    }
295

    
296
    //new band select settings and ad9515 divider
297
    this->update_atr();
298

    
299
    //load new counters into registers
300
    _max2829_regs.int_div_ratio_word = intdiv;
301
    _max2829_regs.frac_div_ratio_lsb = fracdiv & 0x3;
302
    _max2829_regs.frac_div_ratio_msb = fracdiv >> 2;
303
    this->send_reg(0x3); //integer
304
    this->send_reg(0x4); //fractional
305

    
306
    //load the reference divider and band select into registers
307
    //toggle the bandswitch from off to automatic (which really means start)
308
    _max2829_regs.ref_divider = R;
309
    _max2829_regs.band_select = (xcvr2450::is_highband(_lo_freq))?
310
                                max2829_regs_t::BAND_SELECT_5GHZ   :
311
                                max2829_regs_t::BAND_SELECT_2_4GHZ ;
312
    _max2829_regs.vco_bandswitch = max2829_regs_t::VCO_BANDSWITCH_DISABLE;
313
    this->send_reg(0x5);
314
    _max2829_regs.vco_bandswitch = max2829_regs_t::VCO_BANDSWITCH_AUTOMATIC;;
315
    this->send_reg(0x5);
316
}
317

    
318
/***********************************************************************
319
 * Antenna Handling
320
 **********************************************************************/
321
void xcvr2450::set_tx_ant(const std::string &ant){
322
    assert_has(xcvr_antennas, ant, "xcvr antenna name");
323
   _tx_ant = ant;
324
    this->update_atr(); //sets the atr to the new antenna setting
325
}
326

    
327
void xcvr2450::set_rx_ant(const std::string &ant){
328
    assert_has(xcvr_antennas, ant, "xcvr antenna name");
329
    _rx_ant = ant;
330
    this->update_atr(); //sets the atr to the new antenna setting
331
}
332

    
333
/***********************************************************************
334
 * Gain Handling
335
 **********************************************************************/
336
/*!
337
 * Convert a requested gain for the tx vga into the integer register value.
338
 * The gain passed into the function will be set to the actual value.
339
 * \param gain the requested gain in dB
340
 * \return 6 bit the register value
341
 */
342
static int gain_to_tx_vga_reg(float &gain){
343
    //calculate the register value
344
    int reg = std::clip(boost::math::iround(gain*60/30.0) + 3, 0, 63);
345

    
346
    //calculate the actual gain value
347
    if (reg < 4)       gain = 0;
348
    else if (reg < 48) gain = float(reg/2 - 1);
349
    else               gain = float(reg/2.0 - 1.5);
350

    
351
    //return register value
352
    return reg;
353
}
354

    
355
/*!
356
 * Convert a requested gain for the tx bb into the integer register value.
357
 * The gain passed into the function will be set to the actual value.
358
 * \param gain the requested gain in dB
359
 * \return gain enum value
360
 */
361
static max2829_regs_t::tx_baseband_gain_t gain_to_tx_bb_reg(float &gain){
362
    int reg = std::clip(boost::math::iround(gain*3/5.0), 0, 3);
363
    switch(reg){
364
    case 0:
365
        gain = 0;
366
        return max2829_regs_t::TX_BASEBAND_GAIN_0DB;
367
    case 1:
368
        gain = 2;
369
        return max2829_regs_t::TX_BASEBAND_GAIN_2DB;
370
    case 2:
371
        gain = 3.5;
372
        return max2829_regs_t::TX_BASEBAND_GAIN_3_5DB;
373
    case 3:
374
        gain = 5;
375
        return max2829_regs_t::TX_BASEBAND_GAIN_5DB;
376
    }
377
    UHD_THROW_INVALID_CODE_PATH();
378
}
379

    
380
/*!
381
 * Convert a requested gain for the rx vga into the integer register value.
382
 * The gain passed into the function will be set to the actual value.
383
 * \param gain the requested gain in dB
384
 * \return 5 bit the register value
385
 */
386
static int gain_to_rx_vga_reg(float &gain){
387
    int reg = std::clip(boost::math::iround(gain/2.0), 0, 31);
388
    gain = float(reg*2);
389
    return reg;
390
}
391

    
392
/*!
393
 * Convert a requested gain for the rx lna into the integer register value.
394
 * The gain passed into the function will be set to the actual value.
395
 * \param gain the requested gain in dB
396
 * \return 2 bit the register value
397
 */
398
static int gain_to_rx_lna_reg(float &gain){
399
    int reg = std::clip(boost::math::iround(gain*2/30.5) + 1, 0, 3);
400
    switch(reg){
401
    case 0:
402
    case 1: gain = 0;    break;
403
    case 2: gain = 15;   break;
404
    case 3: gain = 30.5; break;
405
    }
406
    return reg;
407
}
408

    
409
void xcvr2450::set_tx_gain(float gain, const std::string &name){
410
    assert_has(xcvr_tx_gain_ranges.keys(), name, "xcvr tx gain name");
411
    if (name == "VGA"){
412
        _max2829_regs.tx_vga_gain = gain_to_tx_vga_reg(gain);
413
        send_reg(0xC);
414
    }
415
    else if(name == "BB"){
416
        _max2829_regs.tx_baseband_gain = gain_to_tx_bb_reg(gain);
417
        send_reg(0x9);
418
    }
419
    else UHD_THROW_INVALID_CODE_PATH();
420
    _tx_gains[name] = gain;
421
}
422

    
423
void xcvr2450::set_rx_gain(float gain, const std::string &name){
424
    assert_has(xcvr_rx_gain_ranges.keys(), name, "xcvr rx gain name");
425
    if (name == "VGA"){
426
        _max2829_regs.rx_vga_gain = gain_to_rx_vga_reg(gain);
427
        send_reg(0xB);
428
    }
429
    else if(name == "LNA"){
430
        _max2829_regs.rx_lna_gain = gain_to_rx_lna_reg(gain);
431
        send_reg(0xB);
432
    }
433
    else UHD_THROW_INVALID_CODE_PATH();
434
    _rx_gains[name] = gain;
435
}
436

    
437
/***********************************************************************
438
 * RX Get and Set
439
 **********************************************************************/
440
void xcvr2450::rx_get(const wax::obj &key_, wax::obj &val){
441
    named_prop_t key = named_prop_t::extract(key_);
442

    
443
    //handle the get request conditioned on the key
444
    switch(key.as<subdev_prop_t>()){
445
    case SUBDEV_PROP_NAME:
446
        val = get_rx_id().to_pp_string();
447
        return;
448

    
449
    case SUBDEV_PROP_OTHERS:
450
        val = prop_names_t(); //empty
451
        return;
452

    
453
    case SUBDEV_PROP_GAIN:
454
        assert_has(_rx_gains.keys(), key.name, "xcvr rx gain name");
455
        val = _rx_gains[key.name];
456
        return;
457

    
458
    case SUBDEV_PROP_GAIN_RANGE:
459
        assert_has(xcvr_rx_gain_ranges.keys(), key.name, "xcvr rx gain name");
460
        val = xcvr_rx_gain_ranges[key.name];
461
        return;
462

    
463
    case SUBDEV_PROP_GAIN_NAMES:
464
        val = prop_names_t(xcvr_rx_gain_ranges.keys());
465
        return;
466

    
467
    case SUBDEV_PROP_FREQ:
468
        val = _lo_freq;
469
        return;
470

    
471
    case SUBDEV_PROP_FREQ_RANGE:
472
        val = xcvr_freq_range;
473
        return;
474

    
475
    case SUBDEV_PROP_ANTENNA:
476
        val = _rx_ant;
477
        return;
478

    
479
    case SUBDEV_PROP_ANTENNA_NAMES:
480
        val = xcvr_antennas;
481
        return;
482

    
483
    case SUBDEV_PROP_CONNECTION:
484
        val = SUBDEV_CONN_COMPLEX_IQ;
485
        return;
486

    
487
    case SUBDEV_PROP_USE_LO_OFFSET:
488
        val = false;
489
        return;
490

    
491
    case SUBDEV_PROP_LO_LOCKED:
492
        val = this->get_locked();
493
        return;
494

    
495
    case SUBDEV_PROP_RSSI:
496
        val = this->get_rssi();
497
        return;
498

    
499
    default: UHD_THROW_PROP_GET_ERROR();
500
    }
501
}
502

    
503
void xcvr2450::rx_set(const wax::obj &key_, const wax::obj &val){
504
    named_prop_t key = named_prop_t::extract(key_);
505

    
506
    //handle the get request conditioned on the key
507
    switch(key.as<subdev_prop_t>()){
508

    
509
    case SUBDEV_PROP_FREQ:
510
        this->set_lo_freq(val.as<double>());
511
        return;
512

    
513
    case SUBDEV_PROP_GAIN:
514
        this->set_rx_gain(val.as<float>(), key.name);
515
        return;
516

    
517
    case SUBDEV_PROP_ANTENNA:
518
        this->set_rx_ant(val.as<std::string>());
519
        return;
520

    
521
    default: UHD_THROW_PROP_SET_ERROR();
522
    }
523
}
524

    
525
/***********************************************************************
526
 * TX Get and Set
527
 **********************************************************************/
528
void xcvr2450::tx_get(const wax::obj &key_, wax::obj &val){
529
    named_prop_t key = named_prop_t::extract(key_);
530

    
531
    //handle the get request conditioned on the key
532
    switch(key.as<subdev_prop_t>()){
533
    case SUBDEV_PROP_NAME:
534
        val = get_tx_id().to_pp_string();
535
        return;
536

    
537
    case SUBDEV_PROP_OTHERS:
538
        val = prop_names_t(); //empty
539
        return;
540

    
541
    case SUBDEV_PROP_GAIN:
542
        assert_has(_tx_gains.keys(), key.name, "xcvr tx gain name");
543
        val = _tx_gains[key.name];
544
        return;
545

    
546
    case SUBDEV_PROP_GAIN_RANGE:
547
        assert_has(xcvr_tx_gain_ranges.keys(), key.name, "xcvr tx gain name");
548
        val = xcvr_tx_gain_ranges[key.name];
549
        return;
550

    
551
    case SUBDEV_PROP_GAIN_NAMES:
552
        val = prop_names_t(xcvr_tx_gain_ranges.keys());
553
        return;
554

    
555
    case SUBDEV_PROP_FREQ:
556
        val = _lo_freq;
557
        return;
558

    
559
    case SUBDEV_PROP_FREQ_RANGE:
560
        val = xcvr_freq_range;
561
        return;
562

    
563
    case SUBDEV_PROP_ANTENNA:
564
        val = _tx_ant;
565
        return;
566

    
567
    case SUBDEV_PROP_ANTENNA_NAMES:
568
        val = xcvr_antennas;
569
        return;
570

    
571
    case SUBDEV_PROP_CONNECTION:
572
        val = SUBDEV_CONN_COMPLEX_QI;
573
        return;
574

    
575
    case SUBDEV_PROP_USE_LO_OFFSET:
576
        val = false;
577
        return;
578

    
579
    case SUBDEV_PROP_LO_LOCKED:
580
        val = this->get_locked();
581
        return;
582

    
583
    default: UHD_THROW_PROP_GET_ERROR();
584
    }
585
}
586

    
587
void xcvr2450::tx_set(const wax::obj &key_, const wax::obj &val){
588
    named_prop_t key = named_prop_t::extract(key_);
589

    
590
    //handle the get request conditioned on the key
591
    switch(key.as<subdev_prop_t>()){
592

    
593
    case SUBDEV_PROP_FREQ:
594
        set_lo_freq(val.as<double>());
595
        return;
596

    
597
    case SUBDEV_PROP_GAIN:
598
        this->set_tx_gain(val.as<float>(), key.name);
599
        return;
600

    
601
    case SUBDEV_PROP_ANTENNA:
602
        this->set_tx_ant(val.as<std::string>());
603
        return;
604

    
605
    default: UHD_THROW_PROP_SET_ERROR();
606
    }
607
}