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