GNU Radio 3.3.0 C++ API
|
00001 /* -*- c++ -*- */ 00002 // 00003 // Copyright 2008 Free Software Foundation, Inc. 00004 // 00005 // This file is part of GNU Radio 00006 // 00007 // GNU Radio is free software; you can redistribute it and/or modify 00008 // it under the terms of the GNU General Public License as published by 00009 // the Free Software Foundation; either asversion 3, or (at your option) 00010 // any later version. 00011 // 00012 // GNU Radio is distributed in the hope that it will be useful, 00013 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 // GNU General Public License for more details. 00016 // 00017 // You should have received a copy of the GNU General Public License 00018 // along with GNU Radio; see the file COPYING. If not, write to 00019 // the Free Software Foundation, Inc., 51 Franklin Street, 00020 // Boston, MA 02110-1301, USA. 00021 // 00022 00023 #ifndef INCLUDED_DB_BASE_H 00024 #define INCLUDED_DB_BASE_H 00025 00026 #include <string> 00027 #include <boost/shared_ptr.hpp> 00028 #include <boost/weak_ptr.hpp> 00029 #include <iosfwd> 00030 00031 class db_base; 00032 typedef boost::shared_ptr<db_base> db_base_sptr; 00033 00034 class usrp_basic; 00035 typedef boost::shared_ptr<usrp_basic> usrp_basic_sptr; 00036 00037 struct freq_result_t 00038 { 00039 bool ok; 00040 double baseband_freq; 00041 }; 00042 00043 /******************************************************************************/ 00044 00045 /*! 00046 * \brief Abstract base class for all USRP daughterboards 00047 * \ingroup usrp 00048 */ 00049 class db_base 00050 { 00051 protected: 00052 bool d_is_shutdown; 00053 usrp_basic *d_raw_usrp; 00054 int d_which; 00055 double d_lo_offset; 00056 00057 void _enable_refclk(bool enable); 00058 virtual double _refclk_freq(); 00059 virtual int _refclk_divisor(); 00060 00061 usrp_basic *usrp(){ 00062 return d_raw_usrp; 00063 } 00064 00065 public: 00066 db_base(boost::shared_ptr<usrp_basic> usrp, int which); 00067 virtual ~db_base(); 00068 00069 int dbid(); 00070 std::string name(); 00071 std::string side_and_name(); 00072 int which() { return d_which; } 00073 00074 bool bypass_adc_buffers(bool bypass); 00075 bool set_atr_mask(int v); 00076 bool set_atr_txval(int v); 00077 bool set_atr_rxval(int v); 00078 bool set_atr_tx_delay(int v); 00079 bool set_atr_rx_delay(int v); 00080 bool set_lo_offset(double offset); 00081 double lo_offset() { return d_lo_offset; } 00082 00083 00084 //////////////////////////////////////////////////////// 00085 // derived classes should override the following methods 00086 00087 protected: 00088 friend class usrp_basic; 00089 00090 /*! 00091 * Called to shutdown daughterboard. Called from dtor and usrp_basic dtor. 00092 * 00093 * N.B., any class that overrides shutdown MUST call shutdown in its destructor. 00094 */ 00095 virtual void shutdown(); 00096 00097 00098 public: 00099 virtual float gain_min() = 0; 00100 virtual float gain_max() = 0; 00101 virtual float gain_db_per_step() = 0; 00102 virtual double freq_min() = 0; 00103 virtual double freq_max() = 0; 00104 virtual struct freq_result_t set_freq(double target_freq) = 0; 00105 virtual bool set_gain(float gain) = 0; 00106 virtual bool is_quadrature() = 0; 00107 virtual bool i_and_q_swapped(); 00108 virtual bool spectrum_inverted(); 00109 virtual bool set_enable(bool on); 00110 virtual bool set_auto_tr(bool on); 00111 virtual bool select_rx_antenna(int which_antenna); 00112 virtual bool select_rx_antenna(const std::string &which_antenna); 00113 virtual bool set_bw(float bw); 00114 }; 00115 00116 00117 std::ostream & operator<<(std::ostream &os, db_base &x); 00118 00119 #endif /* INCLUDED_DB_BASE_H */