Merged r10071:10164 from features/cppdb-test into trunk. Implements the fully native...
[debian/gnuradio] / usrp / host / lib / legacy / db_dbs_rx.h
1 /* -*- c++ -*- */
2 //
3 // Copyright 2008 Free Software Foundation, Inc.
4 // 
5 // This file is part of GNU Radio
6 // 
7 // GNU Radio is free software; you can redistribute it and/or modify
8 // it under the terms of the GNU General Public License as published by
9 // the Free Software Foundation; either asversion 3, or (at your option)
10 // any later version.
11 // 
12 // GNU Radio is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 // GNU General Public License for more details.
16 // 
17 // You should have received a copy of the GNU General Public License
18 // along with GNU Radio; see the file COPYING.  If not, write to
19 // the Free Software Foundation, Inc., 51 Franklin Street,
20 // Boston, MA 02110-1301, USA.
21
22 #ifndef DB_DBS_RX_H
23 #define DB_DBS_RX_H
24
25 #include <db_base.h>
26 #include <vector>
27
28 struct bw_t {
29   int m;
30   int fdac;
31   float div;
32 };
33
34 class db_dbs_rx : public db_base
35 {
36 private:
37   int d_osc, d_cp, d_n, d_div2, d_r, d_r_int;
38   int d_fdac, d_m, d_dl, d_ade, d_adl, d_gc1, d_gc2, d_diag;
39   int d_i2c_addr;
40   
41   // Internal gain functions
42   void _write_reg(int regno, int v);
43   void _write_regs(int starting_regno, const std::vector<int> &vals);
44   std::vector<int> _read_status();
45   void _send_reg(int regno);
46   void _set_m(int m);
47   void _set_fdac(int fdac);
48   bw_t set_bw(float bw);
49   void _set_dl(int dl);
50   void _set_gc2(int gc2);
51   void _set_gc1(int gc1);
52   void _set_pga(int pga_gain);
53
54   // Internal frequency function
55   void _set_osc(int osc);
56   void _set_cp(int cp);
57   void _set_n(int n);
58   void _set_div2(int div2);
59   void _set_r(int r);
60   void _set_ade(int ade);
61
62   int _refclk_divisor();
63
64 protected:
65   void shutdown();
66
67 public:
68   db_dbs_rx(usrp_basic_sptr usrp, int which);
69   ~db_dbs_rx();
70
71   float gain_min();
72   float gain_max();
73   float gain_db_per_step();
74   double freq_min();
75   double freq_max();
76   struct freq_result_t set_freq(double freq);
77   bool  set_gain(float gain);
78   bool  is_quadrature();
79 };
80
81 #endif