GNU Radio 3.3.0 C++ API
|
00001 /* -*- c++ -*- */ 00002 // 00003 // Copyright 2008,2009 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 #ifndef DB_FLEXRF_H 00023 #define DB_FLEXRF_H 00024 00025 #include <usrp/db_base.h> 00026 #include <cmath> 00027 00028 //debug_using_gui = true // Must be set to True or False 00029 #define debug_using_gui false // Must be set to True or False 00030 00031 class _AD4360_common; 00032 00033 class flexrf_base : public db_base 00034 { 00035 public: 00036 flexrf_base(usrp_basic_sptr usrp, int which, int _power_on=0); 00037 ~flexrf_base(); 00038 00039 struct freq_result_t set_freq(double freq); 00040 00041 bool is_quadrature(); 00042 double freq_min(); 00043 double freq_max(); 00044 00045 protected: 00046 void _write_all(int R, int control, int N); 00047 void _write_control(int control); 00048 void _write_R(int R); 00049 void _write_N(int N); 00050 void _write_it(int v); 00051 bool _lock_detect(); 00052 00053 virtual bool _compute_regs(double freq, int &retR, int &retcontrol, 00054 int &retN, double &retfreq); 00055 int _compute_control_reg(); 00056 int _refclk_divisor(); 00057 00058 bool _set_pga(float pga_gain); 00059 00060 int power_on() { return d_power_on; } 00061 int power_off() { return 0; } 00062 00063 bool d_first; 00064 int d_spi_format; 00065 int d_spi_enable; 00066 int d_power_on; 00067 int d_PD; 00068 00069 _AD4360_common *d_common; 00070 }; 00071 00072 // ---------------------------------------------------------------- 00073 00074 class flexrf_base_tx : public flexrf_base 00075 { 00076 protected: 00077 void shutdown(); 00078 00079 public: 00080 flexrf_base_tx(usrp_basic_sptr usrp, int which, int _power_on=0); 00081 ~flexrf_base_tx(); 00082 00083 // All RFX tx d'boards have fixed gain 00084 float gain_min(); 00085 float gain_max(); 00086 float gain_db_per_step(); 00087 00088 bool set_auto_tr(bool on); 00089 bool set_enable(bool on); 00090 bool set_gain(float gain); 00091 }; 00092 00093 class flexrf_base_rx : public flexrf_base 00094 { 00095 protected: 00096 void shutdown(); 00097 00098 public: 00099 flexrf_base_rx(usrp_basic_sptr usrp, int which, int _power_on=0); 00100 ~flexrf_base_rx(); 00101 00102 bool set_auto_tr(bool on); 00103 bool select_rx_antenna(int which_antenna); 00104 bool select_rx_antenna(const std::string &which_antenna); 00105 bool set_gain(float gain); 00106 00107 }; 00108 00109 // ---------------------------------------------------------------- 00110 00111 00112 class _AD4360_common 00113 { 00114 public: 00115 _AD4360_common(); 00116 virtual ~_AD4360_common(); 00117 00118 virtual double freq_min() = 0; 00119 virtual double freq_max() = 0; 00120 00121 bool _compute_regs(double refclk_freq, double freq, int &retR, 00122 int &retcontrol, int &retN, double &retfreq); 00123 int _compute_control_reg(); 00124 virtual int _refclk_divisor(); 00125 int _prescaler(); 00126 00127 void R_DIV(int div) { d_R_DIV = div; } 00128 00129 protected: 00130 int d_R_RSV, d_BSC, d_TEST, d_LDP, d_ABP, d_N_RSV, d_PL, d_MTLD; 00131 int d_CPG, d_CP3S, d_PDP, d_MUXOUT, d_CR, d_PC; 00132 00133 // FIXME: d_PD might cause conflict from flexrf_base 00134 int d_A_DIV, d_B_DIV, d_R_DIV, d_P, d_PD, d_CP2, d_CP1, d_DIVSEL; 00135 int d_DIV2, d_CPGAIN, d_freq_mult; 00136 00137 }; 00138 00139 //---------------------------------------------------------------------- 00140 00141 class _2400_common : public _AD4360_common 00142 { 00143 public: 00144 _2400_common(); 00145 ~_2400_common() {} 00146 00147 double freq_min(); 00148 double freq_max(); 00149 }; 00150 00151 //---------------------------------------------------------------------- 00152 00153 class _1200_common : public _AD4360_common 00154 { 00155 public: 00156 _1200_common(); 00157 ~_1200_common() {} 00158 00159 double freq_min(); 00160 double freq_max(); 00161 }; 00162 00163 //------------------------------------------------------------------------- 00164 00165 class _1800_common : public _AD4360_common 00166 { 00167 public: 00168 _1800_common(); 00169 ~_1800_common() {} 00170 00171 double freq_min(); 00172 double freq_max(); 00173 }; 00174 00175 //------------------------------------------------------------------------- 00176 00177 class _900_common : public _AD4360_common 00178 { 00179 public: 00180 _900_common(); 00181 ~_900_common() {} 00182 00183 double freq_min(); 00184 double freq_max(); 00185 }; 00186 00187 //------------------------------------------------------------------------- 00188 00189 class _400_common : public _AD4360_common 00190 { 00191 public: 00192 _400_common(); 00193 ~_400_common() {} 00194 00195 double freq_min(); 00196 double freq_max(); 00197 }; 00198 00199 class _400_tx : public _400_common 00200 { 00201 public: 00202 _400_tx(); 00203 ~_400_tx() {} 00204 }; 00205 00206 class _400_rx : public _400_common 00207 { 00208 public: 00209 _400_rx(); 00210 ~_400_rx() {} 00211 }; 00212 00213 //------------------------------------------------------------ 00214 00215 class db_flexrf_2400_tx : public flexrf_base_tx 00216 { 00217 public: 00218 db_flexrf_2400_tx(usrp_basic_sptr usrp, int which); 00219 ~db_flexrf_2400_tx(); 00220 00221 // Wrapper calls to d_common functions 00222 bool _compute_regs(double freq, int &retR, int &retcontrol, 00223 int &retN, double &retfreq); 00224 }; 00225 00226 class db_flexrf_2400_rx : public flexrf_base_rx 00227 { 00228 public: 00229 db_flexrf_2400_rx(usrp_basic_sptr usrp, int which); 00230 ~db_flexrf_2400_rx(); 00231 00232 float gain_min(); 00233 float gain_max(); 00234 float gain_db_per_step(); 00235 bool i_and_q_swapped(); 00236 00237 bool _compute_regs(double freq, int &retR, int &retcontrol, 00238 int &retN, double &retfreq); 00239 }; 00240 00241 //------------------------------------------------------------ 00242 00243 class db_flexrf_1200_tx : public flexrf_base_tx 00244 { 00245 public: 00246 db_flexrf_1200_tx(usrp_basic_sptr usrp, int which); 00247 ~db_flexrf_1200_tx(); 00248 00249 // Wrapper calls to d_common functions 00250 bool _compute_regs(double freq, int &retR, int &retcontrol, 00251 int &retN, double &retfreq); 00252 }; 00253 00254 class db_flexrf_1200_rx : public flexrf_base_rx 00255 { 00256 public: 00257 db_flexrf_1200_rx(usrp_basic_sptr usrp, int which); 00258 ~db_flexrf_1200_rx(); 00259 00260 float gain_min(); 00261 float gain_max(); 00262 float gain_db_per_step(); 00263 bool i_and_q_swapped(); 00264 00265 bool _compute_regs(double freq, int &retR, int &retcontrol, 00266 int &retN, double &retfreq); 00267 }; 00268 00269 //------------------------------------------------------------ 00270 00271 class db_flexrf_1800_tx : public flexrf_base_tx 00272 { 00273 public: 00274 db_flexrf_1800_tx(usrp_basic_sptr usrp, int which); 00275 ~db_flexrf_1800_tx(); 00276 00277 // Wrapper calls to d_common functions 00278 bool _compute_regs(double freq, int &retR, int &retcontrol, 00279 int &retN, double &retfreq); 00280 }; 00281 00282 class db_flexrf_1800_rx : public flexrf_base_rx 00283 { 00284 public: 00285 db_flexrf_1800_rx(usrp_basic_sptr usrp, int which); 00286 ~db_flexrf_1800_rx(); 00287 00288 float gain_min(); 00289 float gain_max(); 00290 float gain_db_per_step(); 00291 bool i_and_q_swapped(); 00292 00293 bool _compute_regs(double freq, int &retR, int &retcontrol, 00294 int &retN, double &retfreq); 00295 }; 00296 00297 //------------------------------------------------------------ 00298 00299 class db_flexrf_900_tx : public flexrf_base_tx 00300 { 00301 public: 00302 db_flexrf_900_tx(usrp_basic_sptr usrp, int which); 00303 ~db_flexrf_900_tx(); 00304 00305 // Wrapper calls to d_common functions 00306 bool _compute_regs(double freq, int &retR, int &retcontrol, 00307 int &retN, double &retfreq); 00308 }; 00309 00310 class db_flexrf_900_rx : public flexrf_base_rx 00311 { 00312 public: 00313 db_flexrf_900_rx(usrp_basic_sptr usrp, int which); 00314 ~db_flexrf_900_rx(); 00315 00316 float gain_min(); 00317 float gain_max(); 00318 float gain_db_per_step(); 00319 bool i_and_q_swapped(); 00320 00321 bool _compute_regs(double freq, int &retR, int &retcontrol, 00322 int &retN, double &retfreq); 00323 }; 00324 00325 00326 //------------------------------------------------------------ 00327 00328 class db_flexrf_400_tx : public flexrf_base_tx 00329 { 00330 public: 00331 db_flexrf_400_tx(usrp_basic_sptr usrp, int which); 00332 ~db_flexrf_400_tx(); 00333 00334 // Wrapper calls to d_common functions 00335 bool _compute_regs(double freq, int &retR, int &retcontrol, 00336 int &retN, double &retfreq); 00337 }; 00338 00339 class db_flexrf_400_rx : public flexrf_base_rx 00340 { 00341 public: 00342 db_flexrf_400_rx(usrp_basic_sptr usrp, int which); 00343 ~db_flexrf_400_rx(); 00344 00345 float gain_min(); 00346 float gain_max(); 00347 float gain_db_per_step(); 00348 bool i_and_q_swapped(); 00349 00350 bool _compute_regs(double freq, int &retR, int &retcontrol, 00351 int &retN, double &retfreq); 00352 }; 00353 00354 #endif