Imported Upstream version 3.2.2
[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 /*!
46  * \brief Abstract base class for all USRP daughterboards
47  * \ingroup usrp
48  */
49 class db_base
50 {
51  protected:
52   bool                          d_is_shutdown;
53   usrp_basic                   *d_raw_usrp;
54   int                           d_which;
55   double                        d_lo_offset;
56
57   void _enable_refclk(bool enable);
58   virtual double _refclk_freq();
59   virtual int _refclk_divisor();
60
61   usrp_basic *usrp(){
62     return d_raw_usrp;
63   }
64
65  public:
66   db_base(boost::shared_ptr<usrp_basic> usrp, int which);
67   virtual ~db_base();
68
69   int dbid();
70   std::string name();
71   std::string side_and_name();
72   int which() { return d_which; }
73
74   bool bypass_adc_buffers(bool bypass);
75   bool set_atr_mask(int v);
76   bool set_atr_txval(int v);
77   bool set_atr_rxval(int v);
78   bool set_atr_tx_delay(int v);
79   bool set_atr_rx_delay(int v);
80   bool set_lo_offset(double offset);
81   double lo_offset() { return d_lo_offset; }
82
83
84   ////////////////////////////////////////////////////////
85   // derived classes should override the following methods
86
87 protected:
88   friend class usrp_basic;
89
90   /*!
91    * Called to shutdown daughterboard.  Called from dtor and usrp_basic dtor.
92    *
93    * N.B., any class that overrides shutdown MUST call shutdown in its destructor.
94    */
95   virtual void shutdown();
96
97
98 public:
99   virtual float gain_min() = 0;
100   virtual float gain_max() = 0;
101   virtual float gain_db_per_step() = 0;
102   virtual double freq_min() = 0;
103   virtual double freq_max() = 0;
104   virtual struct freq_result_t set_freq(double target_freq) = 0;
105   virtual bool set_gain(float gain) = 0;
106   virtual bool is_quadrature() = 0;
107   virtual bool i_and_q_swapped();
108   virtual bool spectrum_inverted();
109   virtual bool set_enable(bool on);
110   virtual bool set_auto_tr(bool on);
111   virtual bool select_rx_antenna(int which_antenna);
112   virtual bool select_rx_antenna(const std::string &which_antenna);
113   virtual bool set_bw(float bw);
114 };
115
116
117 std::ostream & operator<<(std::ostream &os, db_base &x);
118
119 #endif /* INCLUDED_DB_BASE_H */