Statistics
| Branch: | Tag: | Revision:

root / host / lib / usrp / dboard / db_wbx.cpp @ fb955a50

History | View | Annotate | Download (22 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
// Common IO Pins
19
#define ANTSW_IO        ((1 << 5)|(1 << 15))    // on UNIT_TX, 0 = TX, 1 = RX, on UNIT_RX 0 = main ant, 1 = RX2
20
#define ADF4350_CE      (1 << 3)
21
#define ADF4350_PDBRF   (1 << 2)
22
#define ADF4350_MUXOUT  (1 << 1)                // INPUT!!!
23
#define LOCKDET_MASK    (1 << 0)                // INPUT!!!
24

    
25
// TX IO Pins
26
#define TX_PUP_5V       (1 << 7)                // enables 5.0V power supply
27
#define TX_PUP_3V       (1 << 6)                // enables 3.3V supply
28
#define TXMOD_EN        (1 << 4)                // on UNIT_TX, 1 enables TX Modulator
29

    
30
// RX IO Pins
31
#define RX_PUP_5V       (1 << 7)                // enables 5.0V power supply
32
#define RX_PUP_3V       (1 << 6)                // enables 3.3V supply
33
#define RXBB_PDB        (1 << 4)                // on UNIT_RX, 1 powers up RX baseband
34

    
35
// RX Attenuator Pins
36
#define RX_ATTN_SHIFT   8                       // lsb of RX Attenuator Control
37
#define RX_ATTN_MASK    (63 << RX_ATTN_SHIFT)      // valid bits of RX Attenuator Control
38

    
39
// Mixer functions
40
#define TX_MIXER_ENB    (TXMOD_EN|ADF4350_PDBRF)
41
#define TX_MIXER_DIS    0
42

    
43
#define RX_MIXER_ENB    (RXBB_PDB|ADF4350_PDBRF)
44
#define RX_MIXER_DIS    0
45

    
46
// Pin functions
47
#define TX_POWER_IO     (TX_PUP_5V|TX_PUP_3V)   // high enables power supply
48
#define TXIO_MASK       (TX_POWER_IO|ANTSW_IO|ADF4350_CE|ADF4350_PDBRF|TXMOD_EN)
49

    
50
#define RX_POWER_IO     (RX_PUP_5V|RX_PUP_3V)   // high enables power supply
51
#define RXIO_MASK       (RX_POWER_IO|ANTSW_IO|ADF4350_CE|ADF4350_PDBRF|RXBB_PDB|RX_ATTN_MASK)
52

    
53
// Power functions
54
#define TX_POWER_UP     (TX_POWER_IO|ADF4350_CE)
55
#define TX_POWER_DOWN   0
56

    
57
#define RX_POWER_UP     (RX_POWER_IO|ADF4350_CE)
58
#define RX_POWER_DOWN   0
59

    
60
// Antenna constants
61
#define ANT_TX          0                       //the tx line is transmitting
62
#define ANT_RX          ANTSW_IO                //the tx line is receiving
63
#define ANT_TXRX        0                       //the rx line is on txrx
64
#define ANT_RX2         ANTSW_IO                //the rx line in on rx2
65
#define ANT_XX          0                       //dont care how the antenna is set
66

    
67
#include "adf4350_regs.hpp"
68
#include <uhd/types/dict.hpp>
69
#include <uhd/usrp/subdev_props.hpp>
70
#include <uhd/types/ranges.hpp>
71
#include <uhd/utils/assert.hpp>
72
#include <uhd/utils/static.hpp>
73
#include <uhd/utils/algorithm.hpp>
74
#include <uhd/usrp/dboard_base.hpp>
75
#include <uhd/usrp/dboard_manager.hpp>
76
#include <boost/assign/list_of.hpp>
77
#include <boost/format.hpp>
78
#include <boost/math/special_functions/round.hpp>
79

    
80
using namespace uhd;
81
using namespace uhd::usrp;
82
using namespace boost::assign;
83

    
84
/***********************************************************************
85
 * The WBX dboard constants
86
 **********************************************************************/
87
static const bool wbx_debug = false;
88

    
89
static const freq_range_t wbx_freq_range(68.75e6, 2.2e9);
90

    
91
static const prop_names_t wbx_tx_antennas = list_of("TX/RX");
92

    
93
static const prop_names_t wbx_rx_antennas = list_of("TX/RX")("RX2");
94

    
95
static const uhd::dict<std::string, gain_range_t> wbx_tx_gain_ranges = map_list_of
96
    ("PGA0", gain_range_t(0, 25, float(0.05)))
97
;
98

    
99
static const uhd::dict<std::string, gain_range_t> wbx_rx_gain_ranges = map_list_of
100
    ("PGA0", gain_range_t(0, 31.5, float(0.5)))
101
;
102

    
103
/***********************************************************************
104
 * The WBX dboard
105
 **********************************************************************/
106
class wbx_xcvr : public xcvr_dboard_base{
107
public:
108
    wbx_xcvr(ctor_args_t args);
109
    ~wbx_xcvr(void);
110

    
111
    void rx_get(const wax::obj &key, wax::obj &val);
112
    void rx_set(const wax::obj &key, const wax::obj &val);
113

    
114
    void tx_get(const wax::obj &key, wax::obj &val);
115
    void tx_set(const wax::obj &key, const wax::obj &val);
116

    
117
private:
118
    uhd::dict<std::string, float> _tx_gains, _rx_gains;
119
    double       _rx_lo_freq, _tx_lo_freq;
120
    std::string  _tx_ant, _rx_ant;
121

    
122
    void set_rx_lo_freq(double freq);
123
    void set_tx_lo_freq(double freq);
124
    void set_rx_ant(const std::string &ant);
125
    void set_tx_ant(const std::string &ant);
126
    void set_rx_gain(float gain, const std::string &name);
127
    void set_tx_gain(float gain, const std::string &name);
128

    
129
    void update_atr(void);
130

    
131
    /*!
132
     * Set the LO frequency for the particular dboard unit.
133
     * \param unit which unit rx or tx
134
     * \param target_freq the desired frequency in Hz
135
     * \return the actual frequency in Hz
136
     */
137
    double set_lo_freq(dboard_iface::unit_t unit, double target_freq);
138

    
139
    /*!
140
     * Get the lock detect status of the LO.
141
     * \param unit which unit rx or tx
142
     * \return true for locked
143
     */
144
    bool get_locked(dboard_iface::unit_t unit){
145
        return (this->get_iface()->read_gpio(unit) & LOCKDET_MASK) != 0;
146
    }
147
};
148

    
149
/***********************************************************************
150
 * Register the WBX dboard (min freq, max freq, rx div2, tx div2)
151
 **********************************************************************/
152
static dboard_base::sptr make_wbx(dboard_base::ctor_args_t args){
153
    return dboard_base::sptr(new wbx_xcvr(args));
154
}
155

    
156
UHD_STATIC_BLOCK(reg_wbx_dboards){
157
    dboard_manager::register_dboard(0x0052, 0x0053, &make_wbx, "WBX");
158
}
159

    
160
/***********************************************************************
161
 * Structors
162
 **********************************************************************/
163
wbx_xcvr::wbx_xcvr(ctor_args_t args) : xcvr_dboard_base(args){
164

    
165
    //enable the clocks that we need
166
    this->get_iface()->set_clock_enabled(dboard_iface::UNIT_TX, true);
167
    this->get_iface()->set_clock_enabled(dboard_iface::UNIT_RX, true);
168

    
169
    //set the gpio directions and atr controls (identically)
170
    this->get_iface()->set_pin_ctrl(dboard_iface::UNIT_TX, TXIO_MASK);
171
    this->get_iface()->set_pin_ctrl(dboard_iface::UNIT_RX, RXIO_MASK);
172
    this->get_iface()->set_gpio_ddr(dboard_iface::UNIT_TX, TXIO_MASK);
173
    this->get_iface()->set_gpio_ddr(dboard_iface::UNIT_RX, RXIO_MASK);
174
    if (wbx_debug) std::cerr << boost::format(
175
        "WBX GPIO Direction: RX: 0x%08x, TX: 0x%08x"
176
    ) % RXIO_MASK % TXIO_MASK << std::endl;
177

    
178
    //set some default values
179
    set_rx_lo_freq((wbx_freq_range.min + wbx_freq_range.max)/2.0);
180
    set_tx_lo_freq((wbx_freq_range.min + wbx_freq_range.max)/2.0);
181
    set_rx_ant("RX2");
182

    
183
    BOOST_FOREACH(const std::string &name, wbx_tx_gain_ranges.keys()){
184
        set_tx_gain(wbx_tx_gain_ranges[name].min, name);
185
    }
186
    BOOST_FOREACH(const std::string &name, wbx_rx_gain_ranges.keys()){
187
        set_rx_gain(wbx_rx_gain_ranges[name].min, name);
188
    }
189
}
190

    
191
wbx_xcvr::~wbx_xcvr(void){
192
    /* NOP */
193
}
194

    
195
/***********************************************************************
196
 * Gain Handling
197
 **********************************************************************/
198
static int rx_pga0_gain_to_iobits(float &gain){
199
    //clip the input
200
    gain = std::clip<float>(gain, wbx_rx_gain_ranges["PGA0"].min, wbx_rx_gain_ranges["PGA0"].max);
201

    
202
    //convert to attenuation and update iobits for atr
203
    float attn = wbx_rx_gain_ranges["PGA0"].max - gain;
204

    
205
    //calculate the attenuation
206
    int attn_code = int(floor(attn*2));
207
    int iobits = ((~attn_code) << RX_ATTN_SHIFT) & RX_ATTN_MASK;
208

    
209
    
210
    if (wbx_debug) std::cerr << boost::format(
211
        "WBX Attenuation: %f dB, Code: %d, IO Bits %x, Mask: %x"
212
    ) % attn % attn_code % (iobits & RX_ATTN_MASK) % RX_ATTN_MASK << std::endl;
213

    
214
    //the actual gain setting
215
    gain = wbx_rx_gain_ranges["PGA0"].max - float(attn_code)/2;
216

    
217
    return iobits;
218
}
219

    
220
static float tx_pga0_gain_to_dac_volts(float &gain){
221
    //clip the input
222
    gain = std::clip<float>(gain, wbx_tx_gain_ranges["PGA0"].min, wbx_tx_gain_ranges["PGA0"].max);
223

    
224
    //voltage level constants
225
    static const float max_volts = float(0.5), min_volts = float(1.4);
226
    static const float slope = (max_volts-min_volts)/wbx_tx_gain_ranges["PGA0"].max;
227

    
228
    //calculate the voltage for the aux dac
229
    float dac_volts = gain*slope + min_volts;
230

    
231
    if (wbx_debug) std::cerr << boost::format(
232
        "WBX TX Gain: %f dB, dac_volts: %f V"
233
    ) % gain % dac_volts << std::endl;
234

    
235
    //the actual gain setting
236
    gain = (dac_volts - min_volts)/slope;
237

    
238
    return dac_volts;
239
}
240

    
241
void wbx_xcvr::set_tx_gain(float gain, const std::string &name){
242
    assert_has(wbx_tx_gain_ranges.keys(), name, "wbx tx gain name");
243
    if(name == "PGA0"){
244
        float dac_volts = tx_pga0_gain_to_dac_volts(gain);
245
        _tx_gains[name] = gain;
246

    
247
        //write the new voltage to the aux dac
248
        this->get_iface()->write_aux_dac(dboard_iface::UNIT_TX, dboard_iface::AUX_DAC_A, dac_volts);
249
    }
250
    else UHD_THROW_INVALID_CODE_PATH();
251
}
252

    
253
void wbx_xcvr::set_rx_gain(float gain, const std::string &name){
254
    assert_has(wbx_rx_gain_ranges.keys(), name, "wbx rx gain name");
255
    if(name == "PGA0"){
256
        rx_pga0_gain_to_iobits(gain);
257
        _rx_gains[name] = gain;
258

    
259
        //write the new gain to atr regs
260
        update_atr();
261
    }
262
    else UHD_THROW_INVALID_CODE_PATH();
263
}
264

    
265
/***********************************************************************
266
 * Antenna Handling
267
 **********************************************************************/
268
void wbx_xcvr::update_atr(void){
269
    //calculate atr pins
270
    int pga0_iobits = rx_pga0_gain_to_iobits(_rx_gains["PGA0"]);
271

    
272
    //setup the tx atr (this does not change with antenna)
273
    this->get_iface()->set_atr_reg(dboard_iface::UNIT_TX, dboard_iface::ATR_REG_IDLE,        TX_POWER_UP | ANT_XX | TX_MIXER_DIS);
274
    this->get_iface()->set_atr_reg(dboard_iface::UNIT_TX, dboard_iface::ATR_REG_RX_ONLY,     TX_POWER_UP | ANT_RX | TX_MIXER_DIS);
275
    this->get_iface()->set_atr_reg(dboard_iface::UNIT_TX, dboard_iface::ATR_REG_TX_ONLY,     TX_POWER_UP | ANT_TX | TX_MIXER_ENB);
276
    this->get_iface()->set_atr_reg(dboard_iface::UNIT_TX, dboard_iface::ATR_REG_FULL_DUPLEX, TX_POWER_UP | ANT_TX | TX_MIXER_ENB);
277

    
278
    //setup the rx atr (this does not change with antenna)
279
    this->get_iface()->set_atr_reg(dboard_iface::UNIT_RX, dboard_iface::ATR_REG_IDLE,
280
        pga0_iobits | RX_POWER_UP | ANT_XX | RX_MIXER_DIS);
281
    this->get_iface()->set_atr_reg(dboard_iface::UNIT_RX, dboard_iface::ATR_REG_TX_ONLY,
282
        pga0_iobits | RX_POWER_UP | ANT_XX | RX_MIXER_DIS);
283
    this->get_iface()->set_atr_reg(dboard_iface::UNIT_RX, dboard_iface::ATR_REG_FULL_DUPLEX,
284
        pga0_iobits | RX_POWER_UP | ANT_RX2| RX_MIXER_ENB);
285

    
286
    //set the rx atr regs that change with antenna setting
287
    this->get_iface()->set_atr_reg(dboard_iface::UNIT_RX, dboard_iface::ATR_REG_RX_ONLY,
288
        pga0_iobits | RX_POWER_UP | RX_MIXER_ENB | ((_rx_ant == "TX/RX")? ANT_TXRX : ANT_RX2));
289
    if (wbx_debug) std::cerr << boost::format(
290
        "WBX RXONLY ATR REG: 0x%08x"
291
    ) % (pga0_iobits | RX_POWER_UP | RX_MIXER_ENB | ((_rx_ant == "TX/RX")? ANT_TXRX : ANT_RX2)) << std::endl;
292
}
293

    
294
void wbx_xcvr::set_rx_ant(const std::string &ant){
295
    //validate input
296
    assert_has(wbx_rx_antennas, ant, "wbx rx antenna name");
297

    
298
    //shadow the setting
299
    _rx_ant = ant;
300

    
301
    //write the new antenna setting to atr regs
302
    update_atr();
303
}
304

    
305
void wbx_xcvr::set_tx_ant(const std::string &ant){
306
    assert_has(wbx_tx_antennas, ant, "wbx tx antenna name");
307
    //only one antenna option, do nothing
308
}
309

    
310
/***********************************************************************
311
 * Tuning
312
 **********************************************************************/
313
void wbx_xcvr::set_rx_lo_freq(double freq){
314
    _rx_lo_freq = set_lo_freq(dboard_iface::UNIT_RX, freq);
315
}
316

    
317
void wbx_xcvr::set_tx_lo_freq(double freq){
318
    _tx_lo_freq = set_lo_freq(dboard_iface::UNIT_TX, freq);
319
}
320

    
321
double wbx_xcvr::set_lo_freq(
322
    dboard_iface::unit_t unit,
323
    double target_freq
324
){
325
    if (wbx_debug) std::cerr << boost::format(
326
        "WBX tune: target frequency %f Mhz"
327
    ) % (target_freq/1e6) << std::endl;
328

    
329
    //clip the input
330
    target_freq = std::clip(target_freq, wbx_freq_range.min, wbx_freq_range.max);
331
    //return the clipped frequency
332
    std::cerr << boost::format(
333
        "WBX tune: target frequency %f Mhz"
334
    ) % (target_freq/1e6) << std::endl;
335

    
336
    //map prescaler setting to mininmum integer divider (N) values (pg.18 prescaler)
337
    static const uhd::dict<int, int> prescaler_to_min_int_div = map_list_of
338
        (0,23) //adf4350_regs_t::PRESCALER_4_5
339
        (1,75) //adf4350_regs_t::PRESCALER_8_9
340
    ;
341

    
342
    //map rf divider select output dividers to enums
343
    static const uhd::dict<int, adf4350_regs_t::rf_divider_select_t> rfdivsel_to_enum = map_list_of
344
        (1,  adf4350_regs_t::RF_DIVIDER_SELECT_DIV1)
345
        (2,  adf4350_regs_t::RF_DIVIDER_SELECT_DIV2)
346
        (4,  adf4350_regs_t::RF_DIVIDER_SELECT_DIV4)
347
        (8,  adf4350_regs_t::RF_DIVIDER_SELECT_DIV8)
348
        (16, adf4350_regs_t::RF_DIVIDER_SELECT_DIV16)
349
    ;
350

    
351
    double actual_freq, pfd_freq;
352
    double ref_freq = this->get_iface()->get_clock_rate(unit);
353
    int R=0, BS=0, N=0, FRAC=0, MOD=0;
354
    int RFdiv = 1;
355
    adf4350_regs_t::reference_divide_by_2_t T     = adf4350_regs_t::REFERENCE_DIVIDE_BY_2_DISABLED;
356
    adf4350_regs_t::reference_doubler_t     D     = adf4350_regs_t::REFERENCE_DOUBLER_DISABLED;    
357

    
358
    //Reference doubler for 50% duty cycle
359
    // if ref_freq < 12.5MHz enable regs.reference_divide_by_2
360
    if(ref_freq <= 12.5e6) D = adf4350_regs_t::REFERENCE_DOUBLER_ENABLED;
361

    
362
    //increase RF divider until acceptable VCO frequency
363
    //start with target_freq*2 because mixer has divide by 2
364
    double vco_freq = target_freq*2;
365
    while (vco_freq < 2.2e9) {
366
        vco_freq *= 2;
367
        RFdiv *= 2;
368
    }
369

    
370
    //use 8/9 prescaler for vco_freq > 3 GHz (pg.18 prescaler)
371
    adf4350_regs_t::prescaler_t prescaler = vco_freq > 3e9 ? adf4350_regs_t::PRESCALER_8_9 : adf4350_regs_t::PRESCALER_4_5;
372

    
373
    /*
374
     * The goal here is to loop though possible R dividers,
375
     * band select clock dividers, N (int) dividers, and FRAC 
376
     * (frac) dividers.
377
     *
378
     * Calculate the N and F dividers for each set of values.
379
     * The loop exists when it meets all of the constraints.
380
     * The resulting loop values are loaded into the registers.
381
     *
382
     * from pg.21
383
     *
384
     * f_pfd = f_ref*(1+D)/(R*(1+T))
385
     * f_vco = (N + (FRAC/MOD))*f_pfd
386
     *    N = f_vco/f_pfd - FRAC/MOD = f_vco*((R*(T+1))/(f_ref*(1+D))) - FRAC/MOD
387
     * f_rf = f_vco/RFdiv)
388
     * f_actual = f_rf/2
389
     */
390
    for(R = 1; R <= 1023; R+=1){
391
        //PFD input frequency = f_ref/R ... ignoring Reference doubler/divide-by-2 (D & T)
392
        pfd_freq = ref_freq*(1+D)/(R*(1+T));
393

    
394
        //keep the PFD frequency at or below 25MHz (Loop Filter Bandwidth)
395
        if (pfd_freq > 25e6) continue;
396

    
397
        //ignore fractional part of tuning
398
        N = int(std::floor(vco_freq/pfd_freq));
399

    
400
        //keep N > minimum int divider requirement
401
        if (N < prescaler_to_min_int_div[prescaler]) continue;
402

    
403
        for(BS=1; BS <= 255; BS+=1){
404
            //keep the band select frequency at or below 100KHz
405
            //constraint on band select clock
406
            if (pfd_freq/BS > 100e3) continue;
407
            goto done_loop;
408
        }
409
    } done_loop:
410

    
411
    //Fractional-N calculation
412
    MOD = 4095; //max fractional accuracy
413
    FRAC = int((vco_freq/pfd_freq - N)*MOD);
414

    
415
    //Reference divide-by-2 for 50% duty cycle
416
    // if R even, move one divide by 2 to to regs.reference_divide_by_2
417
    if(R % 2 == 0){
418
        T = adf4350_regs_t::REFERENCE_DIVIDE_BY_2_ENABLED;
419
        R /= 2;
420
    }
421

    
422
    //actual frequency calculation
423
    actual_freq = double((N + (double(FRAC)/double(MOD)))*ref_freq*(1+int(D))/(R*(1+int(T)))/RFdiv/2);
424

    
425

    
426
    if (wbx_debug) {
427
        std::cerr << boost::format("WBX Intermediates: ref=%0.2f, outdiv=%f, fbdiv=%f") % (ref_freq*(1+int(D))/(R*(1+int(T)))) % double(RFdiv*2) % double(N + double(FRAC)/double(MOD)) << std::endl;
428

    
429
        std::cerr << boost::format("WBX tune: R=%d, BS=%d, N=%d, FRAC=%d, MOD=%d, T=%d, D=%d, RFdiv=%d, LD=%d"
430
            ) % R % BS % N % FRAC % MOD % T % D % RFdiv % get_locked(unit)<< std::endl
431
        << boost::format("WBX Frequencies (MHz): REQ=%0.2f, ACT=%0.2f, VCO=%0.2f, PFD=%0.2f, BAND=%0.2f"
432
            ) % (target_freq/1e6) % (actual_freq/1e6) % (vco_freq/1e6) % (pfd_freq/1e6) % (pfd_freq/BS/1e6) << std::endl;
433
    }
434

    
435
    //load the register values
436
    adf4350_regs_t regs;
437

    
438
    regs.frac_12_bit = FRAC;
439
    regs.int_16_bit = N;
440
    regs.mod_12_bit = MOD;
441
    regs.prescaler = prescaler;
442
    regs.r_counter_10_bit = R;
443
    regs.reference_divide_by_2 = T;
444
    regs.reference_doubler = D;
445
    regs.band_select_clock_div = BS;
446
    UHD_ASSERT_THROW(rfdivsel_to_enum.has_key(RFdiv));
447
    regs.rf_divider_select = rfdivsel_to_enum[RFdiv];
448

    
449
    //write the registers
450
    //correct power-up sequence to write registers (5, 4, 3, 2, 1, 0)
451
    int addr;
452

    
453
    for(addr=5; addr>=0; addr--){
454
        if (wbx_debug) std::cerr << boost::format(
455
            "WBX SPI Reg (0x%02x): 0x%08x"
456
        ) % addr % regs.get_reg(addr) << std::endl;
457
        this->get_iface()->write_spi(
458
            unit, spi_config_t::EDGE_RISE,
459
            regs.get_reg(addr), 32
460
        );
461
    }
462

    
463
    //return the actual frequency
464
    if (wbx_debug) std::cerr << boost::format(
465
        "WBX tune: actual frequency %f Mhz"
466
    ) % (actual_freq/1e6) << std::endl;
467
    return actual_freq;
468
}
469

    
470
/***********************************************************************
471
 * RX Get and Set
472
 **********************************************************************/
473
void wbx_xcvr::rx_get(const wax::obj &key_, wax::obj &val){
474
    wax::obj key; std::string name;
475
    boost::tie(key, name) = extract_named_prop(key_);
476

    
477
    //handle the get request conditioned on the key
478
    switch(key.as<subdev_prop_t>()){
479
    case SUBDEV_PROP_NAME:
480
        val = get_rx_id().to_pp_string();
481
        return;
482

    
483
    case SUBDEV_PROP_OTHERS:
484
        val = prop_names_t(); //empty
485
        return;
486

    
487
    case SUBDEV_PROP_GAIN:
488
        assert_has(_rx_gains.keys(), name, "wbx rx gain name");
489
        val = _rx_gains[name];
490
        return;
491

    
492
    case SUBDEV_PROP_GAIN_RANGE:
493
        assert_has(wbx_rx_gain_ranges.keys(), name, "wbx rx gain name");
494
        val = wbx_rx_gain_ranges[name];
495
        return;
496

    
497
    case SUBDEV_PROP_GAIN_NAMES:
498
        val = prop_names_t(wbx_rx_gain_ranges.keys());
499
        return;
500

    
501
    case SUBDEV_PROP_FREQ:
502
        val = _rx_lo_freq;
503
        return;
504

    
505
    case SUBDEV_PROP_FREQ_RANGE:
506
        val = wbx_freq_range;
507
        return;
508

    
509
    case SUBDEV_PROP_ANTENNA:
510
        val = _rx_ant;
511
        return;
512

    
513
    case SUBDEV_PROP_ANTENNA_NAMES:
514
        val = wbx_rx_antennas;
515
        return;
516

    
517
    case SUBDEV_PROP_QUADRATURE:
518
        val = true;
519
        return;
520

    
521
    case SUBDEV_PROP_IQ_SWAPPED:
522
        val = false;
523
        return;
524

    
525
    case SUBDEV_PROP_SPECTRUM_INVERTED:
526
        val = false;
527
        return;
528

    
529
    case SUBDEV_PROP_USE_LO_OFFSET:
530
        val = false;
531
        return;
532

    
533
    case SUBDEV_PROP_LO_LOCKED:
534
        val = this->get_locked(dboard_iface::UNIT_RX);
535
        return;
536

    
537
    default: UHD_THROW_PROP_GET_ERROR();
538
    }
539
}
540

    
541
void wbx_xcvr::rx_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_rx_lo_freq(val.as<double>());
550
        return;
551

    
552
    case SUBDEV_PROP_GAIN:
553
        this->set_rx_gain(val.as<float>(), name);
554
        return;
555

    
556
    case SUBDEV_PROP_ANTENNA:
557
        this->set_rx_ant(val.as<std::string>());
558
        return;
559

    
560
    default: UHD_THROW_PROP_SET_ERROR();
561
    }
562
}
563

    
564
/***********************************************************************
565
 * TX Get and Set
566
 **********************************************************************/
567
void wbx_xcvr::tx_get(const wax::obj &key_, wax::obj &val){
568
    wax::obj key; std::string name;
569
    boost::tie(key, name) = extract_named_prop(key_);
570

    
571
    //handle the get request conditioned on the key
572
    switch(key.as<subdev_prop_t>()){
573
    case SUBDEV_PROP_NAME:
574
        val = get_tx_id().to_pp_string();
575
        return;
576

    
577
    case SUBDEV_PROP_OTHERS:
578
        val = prop_names_t(); //empty
579
        return;
580

    
581
    case SUBDEV_PROP_GAIN:
582
        assert_has(_tx_gains.keys(), name, "wbx tx gain name");
583
        val = _tx_gains[name];
584
        return;
585

    
586
    case SUBDEV_PROP_GAIN_RANGE:
587
        assert_has(wbx_tx_gain_ranges.keys(), name, "wbx tx gain name");
588
        val = wbx_tx_gain_ranges[name];
589
        return;
590

    
591
    case SUBDEV_PROP_GAIN_NAMES:
592
        val = prop_names_t(wbx_tx_gain_ranges.keys());
593
        return;
594

    
595
    case SUBDEV_PROP_FREQ:
596
        val = _tx_lo_freq;
597
        return;
598

    
599
    case SUBDEV_PROP_FREQ_RANGE:
600
        val = wbx_freq_range;
601
        return;
602

    
603
    case SUBDEV_PROP_ANTENNA:
604
        val = std::string("TX/RX");
605
        return;
606

    
607
    case SUBDEV_PROP_ANTENNA_NAMES:
608
        val = wbx_tx_antennas;
609
        return;
610

    
611
    case SUBDEV_PROP_QUADRATURE:
612
        val = true;
613
        return;
614

    
615
    case SUBDEV_PROP_IQ_SWAPPED:
616
        val = false;
617
        return;
618

    
619
    case SUBDEV_PROP_SPECTRUM_INVERTED:
620
        val = false;
621
        return;
622

    
623
    case SUBDEV_PROP_USE_LO_OFFSET:
624
        val = false;
625
        return;
626

    
627
    case SUBDEV_PROP_LO_LOCKED:
628
        val = this->get_locked(dboard_iface::UNIT_TX);
629
        return;
630

    
631
    default: UHD_THROW_PROP_GET_ERROR();
632
    }
633
}
634

    
635
void wbx_xcvr::tx_set(const wax::obj &key_, const wax::obj &val){
636
    wax::obj key; std::string name;
637
    boost::tie(key, name) = extract_named_prop(key_);
638

    
639
    //handle the get request conditioned on the key
640
    switch(key.as<subdev_prop_t>()){
641

    
642
    case SUBDEV_PROP_FREQ:
643
        this->set_tx_lo_freq(val.as<double>());
644
        return;
645

    
646
    case SUBDEV_PROP_GAIN:
647
        this->set_tx_gain(val.as<float>(), name);
648
        return;
649

    
650
    case SUBDEV_PROP_ANTENNA:
651
        this->set_tx_ant(val.as<std::string>());
652
        return;
653

    
654
    default: UHD_THROW_PROP_SET_ERROR();
655
    }
656
}