Statistics
| Branch: | Tag: | Revision:

root / host / lib / usrp / dboard / db_dbsrx.cpp @ af0543a8

History | View | Annotate | Download (21.1 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
// No RX IO Pins Used
19

    
20
// RX IO Functions
21

    
22
#include "max2118_regs.hpp"
23
#include <uhd/utils/static.hpp>
24
#include <uhd/utils/assert.hpp>
25
#include <uhd/utils/algorithm.hpp>
26
#include <uhd/utils/warning.hpp>
27
#include <uhd/types/ranges.hpp>
28
#include <uhd/types/dict.hpp>
29
#include <uhd/usrp/subdev_props.hpp>
30
#include <uhd/usrp/dboard_base.hpp>
31
#include <uhd/usrp/dboard_manager.hpp>
32
#include <boost/assign/list_of.hpp>
33
#include <boost/format.hpp>
34
#include <boost/thread.hpp>
35
#include <boost/math/special_functions/round.hpp>
36
#include <utility>
37
#include <cmath>
38

    
39
using namespace uhd;
40
using namespace uhd::usrp;
41
using namespace boost::assign;
42

    
43
/***********************************************************************
44
 * The DBSRX constants
45
 **********************************************************************/
46
static const bool dbsrx_debug = false;
47

    
48
static const freq_range_t dbsrx_freq_range(0.8e9, 2.4e9);
49

    
50
static const freq_range_t dbsrx_pfd_freq_range(0.15e6, 2.01e6);
51

    
52
static const prop_names_t dbsrx_antennas = list_of("J3");
53

    
54
static const uhd::dict<std::string, gain_range_t> dbsrx_gain_ranges = map_list_of
55
    ("GC1", gain_range_t(0, 56, 0.5))
56
    ("GC2", gain_range_t(0, 24, 1))
57
;
58

    
59
/***********************************************************************
60
 * The DBSRX dboard class
61
 **********************************************************************/
62
class dbsrx : public rx_dboard_base{
63
public:
64
    dbsrx(ctor_args_t args);
65
    ~dbsrx(void);
66

    
67
    void rx_get(const wax::obj &key, wax::obj &val);
68
    void rx_set(const wax::obj &key, const wax::obj &val);
69

    
70
private:
71
    double _lo_freq;
72
    float _bandwidth;
73
    uhd::dict<std::string, float> _gains;
74
    max2118_write_regs_t _max2118_write_regs;
75
    max2118_read_regs_t _max2118_read_regs;
76
    boost::uint8_t _max2118_addr(void){
77
        return (this->get_iface()->get_special_props().mangle_i2c_addrs)? 0x65 : 0x67;
78
    };
79

    
80
    void set_lo_freq(double target_freq);
81
    void set_gain(float gain, const std::string &name);
82
    void set_bandwidth(float bandwidth);
83

    
84
    void send_reg(boost::uint8_t start_reg, boost::uint8_t stop_reg){
85
        start_reg = boost::uint8_t(std::clip(int(start_reg), 0x0, 0x5));
86
        stop_reg = boost::uint8_t(std::clip(int(stop_reg), 0x0, 0x5));
87

    
88
        for(boost::uint8_t start_addr=start_reg; start_addr <= stop_reg; start_addr += sizeof(boost::uint32_t) - 1){
89
            int num_bytes = int(stop_reg - start_addr + 1) > int(sizeof(boost::uint32_t)) - 1 ? sizeof(boost::uint32_t) - 1 : stop_reg - start_addr + 1;
90

    
91
            //create buffer for register data (+1 for start address)
92
            byte_vector_t regs_vector(num_bytes + 1);
93

    
94
            //first byte is the address of first register
95
            regs_vector[0] = start_addr;
96

    
97
            //get the register data
98
            for(int i=0; i<num_bytes; i++){
99
                regs_vector[1+i] = _max2118_write_regs.get_reg(start_addr+i);
100
                if(dbsrx_debug) std::cerr << boost::format(
101
                    "DBSRX: send reg 0x%02x, value 0x%04x, start_addr = 0x%04x, num_bytes %d"
102
                ) % int(start_addr+i) % int(regs_vector[1+i]) % int(start_addr) % num_bytes << std::endl;
103
            }
104

    
105
            //send the data
106
            this->get_iface()->write_i2c(
107
                _max2118_addr(), regs_vector
108
            );
109
        }
110
    }
111

    
112
    void read_reg(boost::uint8_t start_reg, boost::uint8_t stop_reg){
113
        static const boost::uint8_t status_addr = 0x0;
114
        start_reg = boost::uint8_t(std::clip(int(start_reg), 0x0, 0x1));
115
        stop_reg = boost::uint8_t(std::clip(int(stop_reg), 0x0, 0x1));
116

    
117
        for(boost::uint8_t start_addr=start_reg; start_addr <= stop_reg; start_addr += sizeof(boost::uint32_t)){
118
            int num_bytes = int(stop_reg - start_addr + 1) > int(sizeof(boost::uint32_t)) ? sizeof(boost::uint32_t) : stop_reg - start_addr + 1;
119

    
120
            //create buffer for register data
121
            byte_vector_t regs_vector(num_bytes);
122

    
123
            //read from i2c
124
            regs_vector = this->get_iface()->read_i2c(
125
                _max2118_addr(), num_bytes
126
            );
127

    
128
            for(boost::uint8_t i=0; i < num_bytes; i++){
129
                if (i + start_addr >= status_addr){
130
                    _max2118_read_regs.set_reg(i + start_addr, regs_vector[i]);
131
                }
132
                if(dbsrx_debug) std::cerr << boost::format(
133
                    "DBSRX: read reg 0x%02x, value 0x%04x, start_addr = 0x%04x, num_bytes %d"
134
                ) % int(start_addr+i) % int(regs_vector[i]) % int(start_addr) % num_bytes << std::endl;
135
            }
136
        }
137
    }
138

    
139
    /*!
140
     * Is the LO locked?
141
     * \return true for locked
142
     */
143
    bool get_locked(void){
144
        read_reg(0x0, 0x0);
145

    
146
        //mask and return lock detect
147
        bool locked = 5 >= _max2118_read_regs.adc and _max2118_read_regs.adc >= 2;
148

    
149
        if(dbsrx_debug) std::cerr << boost::format(
150
            "DBSRX: locked %d"
151
        ) % locked << std::endl;
152

    
153
        return locked;
154
    }
155

    
156
};
157

    
158
/***********************************************************************
159
 * Register the DBSRX dboard
160
 **********************************************************************/
161
static dboard_base::sptr make_dbsrx(dboard_base::ctor_args_t args){
162
    return dboard_base::sptr(new dbsrx(args));
163
}
164

    
165
//dbid for USRP2 version
166
UHD_STATIC_BLOCK(reg_dbsrx_dboard){
167
    //register the factory function for the rx dbid
168
    dboard_manager::register_dboard(0x000D, &make_dbsrx, "DBSRX");
169
}
170

    
171
//dbid for USRP1 version
172
UHD_STATIC_BLOCK(reg_dbsrx_on_usrp1_dboard){
173
    //register the factory function for the rx dbid
174
    dboard_manager::register_dboard(0x0002, &make_dbsrx, "DBSRX");
175
}
176

    
177
/***********************************************************************
178
 * Structors
179
 **********************************************************************/
180
dbsrx::dbsrx(ctor_args_t args) : rx_dboard_base(args){
181
    //warn user about incorrect DBID on USRP1, requires R193 populated
182
    if (this->get_iface()->get_special_props().soft_clock_divider and this->get_rx_id() == 0x000D)
183
        uhd::print_warning(
184
            str(boost::format(
185
                "DBSRX: incorrect dbid\n"
186
                "Expected dbid 0x0002 and R193\n"
187
                "found dbid == %d\n"
188
                "Please see the daughterboard app notes" 
189
                ) % this->get_rx_id().to_pp_string())
190
        );
191

    
192
    //warn user about incorrect DBID on non-USRP1, requires R194 populated
193
    if (not this->get_iface()->get_special_props().soft_clock_divider and this->get_rx_id() == 0x0002)
194
        uhd::print_warning(
195
            str(boost::format(
196
                "DBSRX: incorrect dbid\n"
197
                "Expected dbid 0x000D and R194\n"
198
                "found dbid == %d\n"
199
                "Please see the daughterboard app notes" 
200
                ) % this->get_rx_id().to_pp_string())
201
        );
202

    
203
    //enable only the clocks we need
204
    this->get_iface()->set_clock_enabled(dboard_iface::UNIT_RX, true);
205

    
206
    //set the gpio directions and atr controls (identically)
207
    this->get_iface()->set_pin_ctrl(dboard_iface::UNIT_RX, 0x0); // All unused in atr
208
    if (this->get_iface()->get_special_props().soft_clock_divider){
209
        this->get_iface()->set_gpio_ddr(dboard_iface::UNIT_RX, 0x1); // GPIO0 is clock
210
    }
211
    else{
212
        this->get_iface()->set_gpio_ddr(dboard_iface::UNIT_RX, 0x0); // All Inputs
213
    }
214

    
215
    //send initial register settings
216
    this->send_reg(0x0, 0x5);
217

    
218
    //set defaults for LO, gains, and filter bandwidth
219
    _bandwidth = 33e6;
220
    set_lo_freq(dbsrx_freq_range.min);
221

    
222
    BOOST_FOREACH(const std::string &name, dbsrx_gain_ranges.keys()){
223
        set_gain(dbsrx_gain_ranges[name].min, name);
224
    }
225

    
226
    set_bandwidth(33e6); // default bandwidth from datasheet
227
}
228

    
229
dbsrx::~dbsrx(void){
230
}
231

    
232

    
233
/***********************************************************************
234
 * Tuning
235
 **********************************************************************/
236
void dbsrx::set_lo_freq(double target_freq){
237
    target_freq = std::clip(target_freq, dbsrx_freq_range.min, dbsrx_freq_range.max);
238

    
239
    double actual_freq=0.0, pfd_freq=0.0, ref_clock=0.0;
240
    int R=0, N=0, r=0, m=0;
241
    bool update_filter_settings = false;
242

    
243
    //choose refclock
244
    std::vector<double> clock_rates = this->get_iface()->get_clock_rates(dboard_iface::UNIT_RX);
245
    BOOST_FOREACH(ref_clock, std::reversed(std::sorted(clock_rates))){
246
        if (ref_clock > 27.0e6) continue;
247

    
248
        //choose m_divider such that filter tuning constraint is met
249
        m = 31;
250
        while ((ref_clock/m < 1e6 or ref_clock/m > 2.5e6) and m > 0){ m--; }
251

    
252
        if(dbsrx_debug) std::cerr << boost::format(
253
            "DBSRX: trying ref_clock %f and m_divider %d"
254
        ) % (this->get_iface()->get_clock_rate(dboard_iface::UNIT_RX)) % m << std::endl;
255

    
256
        if (m >= 32) continue;
257

    
258
        //choose R
259
        for(r = 0; r <= 6; r += 1) {
260
            //compute divider from setting
261
            R = 1 << (r+1);
262
            if (dbsrx_debug) std::cerr << boost::format("DBSRX R:%d\n") % R << std::endl;
263

    
264
            //compute PFD compare frequency = ref_clock/R
265
            pfd_freq = ref_clock / R;
266

    
267
            //constrain the PFD frequency to specified range
268
            if ((pfd_freq < dbsrx_pfd_freq_range.min) or (pfd_freq > dbsrx_pfd_freq_range.max)) continue;
269

    
270
            //compute N
271
            N = int(std::floor(target_freq/pfd_freq));
272

    
273
            //constrain N to specified range
274
            if ((N < 256) or (N > 32768)) continue;
275

    
276
            goto done_loop;
277
        }
278
    } 
279

    
280
    //Assert because we failed to find a suitable combination of ref_clock, R and N 
281
    UHD_ASSERT_THROW(ref_clock/(1 << m) < 1e6 or ref_clock/(1 << m) > 2.5e6);
282
    UHD_ASSERT_THROW((pfd_freq < dbsrx_pfd_freq_range.min) or (pfd_freq > dbsrx_pfd_freq_range.max));
283
    UHD_ASSERT_THROW((N < 256) or (N > 32768));
284
    done_loop:
285

    
286
    if(dbsrx_debug) std::cerr << boost::format(
287
        "DBSRX: choose ref_clock %f and m_divider %d"
288
    ) % (this->get_iface()->get_clock_rate(dboard_iface::UNIT_RX)) % m << std::endl;
289

    
290
    //if ref_clock or m divider changed, we need to update the filter settings
291
    if (ref_clock != this->get_iface()->get_clock_rate(dboard_iface::UNIT_RX) or m != _max2118_write_regs.m_divider) update_filter_settings = true;
292

    
293
    //compute resulting output frequency
294
    actual_freq = pfd_freq * N;
295

    
296
    //apply ref_clock, R, and N settings
297
    this->get_iface()->set_clock_rate(dboard_iface::UNIT_RX, ref_clock);
298
    ref_clock = this->get_iface()->get_clock_rate(dboard_iface::UNIT_RX);
299
    _max2118_write_regs.m_divider = m;
300
    _max2118_write_regs.r_divider = (max2118_write_regs_t::r_divider_t) r;
301
    _max2118_write_regs.set_n_divider(N);
302
    _max2118_write_regs.ade_vco_ade_read = max2118_write_regs_t::ADE_VCO_ADE_READ_ENABLED;
303
    
304
    //compute prescaler variables
305
    int scaler = actual_freq > 1125e6 ? 2 : 4;
306
    _max2118_write_regs.div2 = scaler == 4 ? max2118_write_regs_t::DIV2_DIV4 : max2118_write_regs_t::DIV2_DIV2;
307

    
308
    if(dbsrx_debug) std::cerr << boost::format(
309
        "DBSRX: scaler %d, actual_freq %f MHz, register bit: %d"
310
    ) % scaler % (actual_freq/1e6) % int(_max2118_write_regs.div2) << std::endl;
311

    
312
    //compute vco frequency and select vco
313
    double vco_freq = actual_freq * scaler;
314
    if (vco_freq < 2433e6)
315
        _max2118_write_regs.osc_band = 0;
316
    else if (vco_freq < 2711e6)
317
        _max2118_write_regs.osc_band = 1;
318
    else if (vco_freq < 3025e6)
319
        _max2118_write_regs.osc_band = 2;
320
    else if (vco_freq < 3341e6)
321
        _max2118_write_regs.osc_band = 3;
322
    else if (vco_freq < 3727e6)
323
        _max2118_write_regs.osc_band = 4;
324
    else if (vco_freq < 4143e6)
325
        _max2118_write_regs.osc_band = 5;
326
    else if (vco_freq < 4493e6)
327
        _max2118_write_regs.osc_band = 6;
328
    else
329
        _max2118_write_regs.osc_band = 7;
330

    
331
    //send settings over i2c
332
    send_reg(0x0, 0x4);
333

    
334
    //check vtune for lock condition
335
    read_reg(0x0, 0x0);
336

    
337
    if(dbsrx_debug) std::cerr << boost::format(
338
        "DBSRX: initial guess for vco %d, vtune adc %d"
339
    ) % int(_max2118_write_regs.osc_band) % int(_max2118_read_regs.adc) << std::endl;
340

    
341
    //if we are out of lock for chosen vco, change vco
342
    while ((_max2118_read_regs.adc == 0) or (_max2118_read_regs.adc == 7)){
343

    
344
        //vtune is too low, try lower frequency vco
345
        if (_max2118_read_regs.adc == 0){
346
            if (_max2118_write_regs.osc_band == 0){
347
                uhd::print_warning(
348
                    str(boost::format(
349
                        "DBSRX: Tuning exceeded vco range, _max2118_write_regs.osc_band == %d\n" 
350
                        ) % int(_max2118_write_regs.osc_band))
351
                );
352
                UHD_ASSERT_THROW(_max2118_read_regs.adc == 0);
353
            }
354
            if (_max2118_write_regs.osc_band <= 0) break;
355
            _max2118_write_regs.osc_band -= 1;
356
        }
357

    
358
        //vtune is too high, try higher frequency vco
359
        if (_max2118_read_regs.adc == 7){
360
            if (_max2118_write_regs.osc_band == 7){
361
                uhd::print_warning(
362
                    str(boost::format(
363
                        "DBSRX: Tuning exceeded vco range, _max2118_write_regs.osc_band == %d\n" 
364
                        ) % int(_max2118_write_regs.osc_band))
365
                );
366
                UHD_ASSERT_THROW(_max2118_read_regs.adc == 0);
367
            }
368
            if (_max2118_write_regs.osc_band >= 7) break;
369
            _max2118_write_regs.osc_band += 1;
370
        }
371

    
372
        if(dbsrx_debug) std::cerr << boost::format(
373
            "DBSRX: trying vco %d, vtune adc %d"
374
        ) % int(_max2118_write_regs.osc_band) % int(_max2118_read_regs.adc) << std::endl;
375

    
376
        //update vco selection and check vtune
377
        send_reg(0x2, 0x2);
378
        read_reg(0x0, 0x0);
379
    }
380
      
381
    if(dbsrx_debug) std::cerr << boost::format(
382
        "DBSRX: final vco %d, vtune adc %d"
383
    ) % int(_max2118_write_regs.osc_band) % int(_max2118_read_regs.adc) << std::endl;
384

    
385
    //select charge pump bias current
386
    if (_max2118_read_regs.adc <= 2) _max2118_write_regs.cp_current = max2118_write_regs_t::CP_CURRENT_I_CP_100UA;
387
    else if (_max2118_read_regs.adc >= 5) _max2118_write_regs.cp_current = max2118_write_regs_t::CP_CURRENT_I_CP_400UA;
388
    else _max2118_write_regs.cp_current = max2118_write_regs_t::CP_CURRENT_I_CP_200UA;
389
    
390
    //update charge pump bias current setting
391
    send_reg(0x2, 0x2);
392

    
393
    //compute actual tuned frequency
394
    _lo_freq = this->get_iface()->get_clock_rate(dboard_iface::UNIT_RX) / std::pow(2.0,(1 + _max2118_write_regs.r_divider)) * _max2118_write_regs.get_n_divider();
395

    
396
    //debug output of calculated variables
397
    if (dbsrx_debug) std::cerr
398
        << boost::format("DBSRX tune:\n")
399
        << boost::format("    VCO=%d, CP=%d, PFD Freq=%fMHz\n") % int(_max2118_write_regs.osc_band) % _max2118_write_regs.cp_current % (pfd_freq/1e6)
400
        << boost::format("    R=%d, N=%f, scaler=%d, div2=%d\n") % R % N % scaler % int(_max2118_write_regs.div2)
401
        << boost::format("    Ref    Freq=%fMHz\n") % (ref_clock/1e6)
402
        << boost::format("    Target Freq=%fMHz\n") % (target_freq/1e6)
403
        << boost::format("    Actual Freq=%fMHz\n") % (_lo_freq/1e6)
404
        << std::endl;
405

    
406
    if (update_filter_settings) set_bandwidth(_bandwidth);
407
    get_locked();
408
}
409

    
410
/***********************************************************************
411
 * Gain Handling
412
 **********************************************************************/
413
/*!
414
 * Convert a requested gain for the GC2 vga into the integer register value.
415
 * The gain passed into the function will be set to the actual value.
416
 * \param gain the requested gain in dB
417
 * \return 5 bit the register value
418
 */
419
static int gain_to_gc2_vga_reg(float &gain){
420
    int reg = 0;
421
    gain = std::clip<float>(float(boost::math::iround(gain)), dbsrx_gain_ranges["GC2"].min, dbsrx_gain_ranges["GC2"].max);
422

    
423
    // Half dB steps from 0-5dB, 1dB steps from 5-24dB
424
    if (gain < 5) {
425
        reg = boost::math::iround(31.0 - gain/0.5);
426
        gain = float(boost::math::iround(gain) * 0.5);
427
    } else {
428
        reg = boost::math::iround(22.0 - (gain - 4.0));
429
        gain = float(boost::math::iround(gain));
430
    }
431

    
432
    if (dbsrx_debug) std::cerr << boost::format(
433
        "DBSRX GC2 Gain: %f dB, reg: %d"
434
    ) % gain % reg << std::endl;
435

    
436
    return reg;
437
}
438

    
439
/*!
440
 * Convert a requested gain for the GC1 rf vga into the dac_volts value.
441
 * The gain passed into the function will be set to the actual value.
442
 * \param gain the requested gain in dB
443
 * \return dac voltage value
444
 */
445
static float gain_to_gc1_rfvga_dac(float &gain){
446
    //clip the input
447
    gain = std::clip<float>(gain, dbsrx_gain_ranges["GC1"].min, dbsrx_gain_ranges["GC1"].max);
448

    
449
    //voltage level constants
450
    static const float max_volts = float(1.2), min_volts = float(2.7);
451
    static const float slope = (max_volts-min_volts)/dbsrx_gain_ranges["GC1"].max;
452

    
453
    //calculate the voltage for the aux dac
454
    float dac_volts = gain*slope + min_volts;
455

    
456
    if (dbsrx_debug) std::cerr << boost::format(
457
        "DBSRX GC1 Gain: %f dB, dac_volts: %f V"
458
    ) % gain % dac_volts << std::endl;
459

    
460
    //the actual gain setting
461
    gain = (dac_volts - min_volts)/slope;
462

    
463
    return dac_volts;
464
}
465

    
466
void dbsrx::set_gain(float gain, const std::string &name){
467
    assert_has(dbsrx_gain_ranges.keys(), name, "dbsrx gain name");
468
    if (name == "GC2"){
469
        _max2118_write_regs.gc2 = gain_to_gc2_vga_reg(gain);
470
        send_reg(0x5, 0x5);
471
    }
472
    else if(name == "GC1"){
473
        //write the new voltage to the aux dac
474
        this->get_iface()->write_aux_dac(dboard_iface::UNIT_RX, dboard_iface::AUX_DAC_A, gain_to_gc1_rfvga_dac(gain));
475
    }
476
    else UHD_THROW_INVALID_CODE_PATH();
477
    _gains[name] = gain;
478
}
479

    
480
/***********************************************************************
481
 * Bandwidth Handling
482
 **********************************************************************/
483
void dbsrx::set_bandwidth(float bandwidth){
484
    //clip the input
485
    bandwidth = std::clip<float>(bandwidth, 4e6, 33e6);
486

    
487
    double ref_clock = this->get_iface()->get_clock_rate(dboard_iface::UNIT_RX);
488
    
489
    //NOTE: _max2118_write_regs.m_divider set in set_lo_freq
490

    
491
    //compute f_dac setting
492
    _max2118_write_regs.f_dac = std::clip<int>(int((((bandwidth*_max2118_write_regs.m_divider)/ref_clock) - 4)/0.145),0,127);
493

    
494
    //determine actual bandwidth
495
    _bandwidth = float((ref_clock/(_max2118_write_regs.m_divider))*(4+0.145*_max2118_write_regs.f_dac));
496

    
497
    if (dbsrx_debug) std::cerr << boost::format(
498
        "DBSRX Filter Bandwidth: %f MHz, m: %d, f_dac: %d\n"
499
    ) % (_bandwidth/1e6) % int(_max2118_write_regs.m_divider) % int(_max2118_write_regs.f_dac) << std::endl;
500

    
501
    this->send_reg(0x3, 0x4);
502
}
503

    
504
/***********************************************************************
505
 * RX Get and Set
506
 **********************************************************************/
507
void dbsrx::rx_get(const wax::obj &key_, wax::obj &val){
508
    named_prop_t key = named_prop_t::extract(key_);
509

    
510
    //handle the get request conditioned on the key
511
    switch(key.as<subdev_prop_t>()){
512
    case SUBDEV_PROP_NAME:
513
        val = get_rx_id().to_pp_string();
514
        return;
515

    
516
    case SUBDEV_PROP_OTHERS:
517
        val = prop_names_t(); //empty
518
        return;
519

    
520
    case SUBDEV_PROP_GAIN:
521
        assert_has(_gains.keys(), key.name, "dbsrx gain name");
522
        val = _gains[key.name];
523
        return;
524

    
525
    case SUBDEV_PROP_GAIN_RANGE:
526
        assert_has(dbsrx_gain_ranges.keys(), key.name, "dbsrx gain name");
527
        val = dbsrx_gain_ranges[key.name];
528
        return;
529

    
530
    case SUBDEV_PROP_GAIN_NAMES:
531
        val = prop_names_t(dbsrx_gain_ranges.keys());
532
        return;
533

    
534
    case SUBDEV_PROP_FREQ:
535
        val = _lo_freq;
536
        return;
537

    
538
    case SUBDEV_PROP_FREQ_RANGE:
539
        val = dbsrx_freq_range;
540
        return;
541

    
542
    case SUBDEV_PROP_ANTENNA:
543
        val = std::string("J3");
544
        return;
545

    
546
    case SUBDEV_PROP_ANTENNA_NAMES:
547
        val = dbsrx_antennas;
548
        return;
549

    
550
    case SUBDEV_PROP_CONNECTION:
551
        val = SUBDEV_CONN_COMPLEX_IQ;
552
        return;
553

    
554
    case SUBDEV_PROP_USE_LO_OFFSET:
555
        val = false;
556
        return;
557

    
558
    case SUBDEV_PROP_LO_LOCKED:
559
        val = this->get_locked();
560
        return;
561

    
562
/*
563
    case SUBDEV_PROP_RSSI:
564
        val = this->get_rssi();
565
        return;
566
*/
567

    
568
    case SUBDEV_PROP_BANDWIDTH:
569
        val = _bandwidth;
570
        return;
571

    
572
    default: UHD_THROW_PROP_GET_ERROR();
573
    }
574
}
575

    
576
void dbsrx::rx_set(const wax::obj &key_, const wax::obj &val){
577
    named_prop_t key = named_prop_t::extract(key_);
578

    
579
    //handle the get request conditioned on the key
580
    switch(key.as<subdev_prop_t>()){
581

    
582
    case SUBDEV_PROP_FREQ:
583
        this->set_lo_freq(val.as<double>());
584
        return;
585

    
586
    case SUBDEV_PROP_GAIN:
587
        this->set_gain(val.as<float>(), key.name);
588
        return;
589

    
590
    case SUBDEV_PROP_BANDWIDTH:
591
        this->set_bandwidth(val.as<float>());
592
        return;
593

    
594
    default: UHD_THROW_PROP_SET_ERROR();
595
    }
596
}
597