Clean build
[debian/gnuradio] / usrp / host / include / usrp / db_wbxng.h
1 /* -*- c++ -*- */
2 //
3 // Copyright 2008,2009 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_WBXNG_H
23 #define DB_WBXNG_H
24
25 #include <usrp/db_base.h>
26 #include <cmath>
27
28 //debug_using_gui = true                // Must be set to True or False
29 #define debug_using_gui false           // Must be set to True or False
30
31 class adf4350;
32
33 class wbxng_base : public db_base
34 {
35 public:
36   wbxng_base(usrp_basic_sptr usrp, int which, int _power_on=0);
37   ~wbxng_base();
38
39   struct freq_result_t set_freq(double freq);
40
41   bool  is_quadrature();
42   double freq_min();
43   double freq_max();
44
45 protected:
46   void _write_all(int R, int control, int N);
47   void _write_control(int control);
48   void _write_R(int R);
49   void _write_N(int N);
50   void _write_it(int v);
51   bool _lock_detect();
52
53   virtual bool _compute_regs(double freq, int &retR, int &retcontrol, 
54                              int &retN, double &retfreq);
55   int  _compute_control_reg();
56   int _refclk_divisor();
57   double _refclk_freq();
58
59   bool _set_pga(float pga_gain);
60
61   int power_on() { return d_power_on; }
62   int power_off() { return 0; }
63
64   bool d_first;
65   int  d_spi_format;
66   int  d_spi_enable;
67   int  d_power_on;
68   int  d_PD;
69
70   adf4350 *d_common;
71 };
72
73 // ----------------------------------------------------------------
74
75 class wbxng_base_tx : public wbxng_base
76 {
77 protected:
78   void shutdown();
79
80 public:
81   wbxng_base_tx(usrp_basic_sptr usrp, int which, int _power_on=0);
82   ~wbxng_base_tx();
83
84   //*** TODO *** Fix comment
85   // All RFX tx d'boards have fixed gain
86   float gain_min();
87   float gain_max();
88   float gain_db_per_step();
89
90   bool set_auto_tr(bool on);
91   bool set_enable(bool on);
92   bool set_gain(float gain);
93 };
94
95 class wbxng_base_rx : public wbxng_base
96 {
97 protected:
98   void shutdown();
99
100 public:
101   wbxng_base_rx(usrp_basic_sptr usrp, int which, int _power_on=0);
102   ~wbxng_base_rx();
103     
104   bool set_auto_tr(bool on);
105   bool select_rx_antenna(int which_antenna);
106   bool select_rx_antenna(const std::string &which_antenna);
107   bool set_gain(float gain);
108
109 };
110
111 // ----------------------------------------------------------------
112
113 class db_wbxng_tx : public wbxng_base_tx
114 {
115  public:
116   db_wbxng_tx(usrp_basic_sptr usrp, int which);
117   ~db_wbxng_tx();
118
119   // Wrapper calls to d_common functions
120   bool _compute_regs(double freq, int &retR, int &retcontrol,
121                      int &retN, double &retfreq);
122 };
123
124 class db_wbxng_rx : public wbxng_base_rx
125 {
126 public:
127   db_wbxng_rx(usrp_basic_sptr usrp, int which);
128   ~db_wbxng_rx();
129   
130   float gain_min();
131   float gain_max();
132   float gain_db_per_step();
133   bool i_and_q_swapped();
134
135   bool _compute_regs(double freq, int &retR, int &retcontrol,
136                      int &retN, double &retfreq);
137 };
138
139
140 #endif