Merged r10071:10164 from features/cppdb-test into trunk. Implements the fully native...
[debian/gnuradio] / usrp / host / lib / legacy / db_base.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
23 #ifndef INCLUDED_DB_BASE_H
24 #define INCLUDED_DB_BASE_H
25
26 #include <string>
27 #include <boost/shared_ptr.hpp>
28 #include <boost/weak_ptr.hpp>
29 #include <iosfwd>
30
31 class db_base;
32 typedef boost::shared_ptr<db_base> db_base_sptr;
33
34 class usrp_basic;
35 typedef boost::shared_ptr<usrp_basic> usrp_basic_sptr;
36
37 struct freq_result_t
38 {
39   bool  ok;
40   double baseband_freq;
41 };
42
43 /******************************************************************************/
44
45 class db_base
46 {
47  protected:
48   bool                          d_is_shutdown;
49   usrp_basic                   *d_raw_usrp;
50   int                           d_which;
51   double                        d_lo_offset;
52
53   void _enable_refclk(bool enable);
54   virtual double _refclk_freq();
55   virtual int _refclk_divisor();
56
57   usrp_basic *usrp(){
58     return d_raw_usrp;
59   }
60
61  public:
62   db_base(boost::shared_ptr<usrp_basic> usrp, int which);
63   virtual ~db_base();
64
65   int dbid();
66   std::string name();
67   std::string side_and_name();
68   int which() { return d_which; }
69
70   bool bypass_adc_buffers(bool bypass);
71   bool set_atr_mask(int v);
72   bool set_atr_txval(int v);
73   bool set_atr_rxval(int v);
74   bool set_atr_tx_delay(int v);
75   bool set_atr_rx_delay(int v);
76   bool set_lo_offset(double offset);
77   double lo_offset() { return d_lo_offset; }
78
79
80   ////////////////////////////////////////////////////////
81   // derived classes should override the following methods
82
83 protected:
84   friend class usrp_basic;
85
86   /*!
87    * Called to shutdown daughterboard.  Called from dtor and usrp_basic dtor.
88    *
89    * N.B., any class that overrides shutdown MUST call shutdown in its destructor.
90    */
91   virtual void shutdown();
92
93
94 public:
95   virtual float gain_min() = 0;
96   virtual float gain_max() = 0;
97   virtual float gain_db_per_step() = 0;
98   virtual double freq_min() = 0;
99   virtual double freq_max() = 0;
100   virtual struct freq_result_t set_freq(double target_freq) = 0;
101   virtual bool set_gain(float gain) = 0;
102   virtual bool is_quadrature() = 0;
103   virtual bool i_and_q_swapped();
104   virtual bool spectrum_inverted();
105   virtual bool set_enable(bool on);
106   virtual bool set_auto_tr(bool on);
107   virtual bool select_rx_antenna(int which_antenna);
108   virtual bool select_rx_antenna(const std::string &which_antenna);
109 };
110
111
112 std::ostream & operator<<(std::ostream &os, db_base &x);
113
114 #endif /* INCLUDED_DB_BASE_H */