00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef DB_WBX_H
00023 #define DB_WBX_H
00024
00025 #include <db_base.h>
00026 #include <boost/shared_ptr.hpp>
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039 class wbx_base : public db_base
00040 {
00041 protected:
00042 void shutdown();
00043
00044
00045
00046
00047
00048
00049
00050 public:
00051 wbx_base(usrp_basic_sptr usrp, int which);
00052 ~wbx_base();
00053
00054 struct freq_result_t set_freq(double freq);
00055 float gain_min();
00056 float gain_max();
00057 float gain_db_per_step();
00058 bool set_gain(float gain);
00059 bool is_quadrature();
00060
00061
00062 protected:
00063 virtual bool _lock_detect();
00064
00065
00066 bool _tx_write_oe(int value, int mask);
00067 bool _rx_write_oe(int value, int mask);
00068 bool _tx_write_io(int value, int mask);
00069 bool _rx_write_io(int value, int mask);
00070 virtual bool _rx_read_io();
00071 bool _tx_read_io();
00072 bool _compute_regs(double freq);
00073 virtual double _refclk_freq();
00074 int _refclk_divisor();
00075
00076 bool _set_pga(float pga_gain);
00077
00078 bool d_first;
00079 int d_spi_format;
00080 int d_spi_enable;
00081 double d_lo_offset;
00082 };
00083
00084
00085
00086
00087
00088 class wbx_base_tx : public wbx_base
00089 {
00090 public:
00091 wbx_base_tx(usrp_basic_sptr usrp, int which);
00092 ~wbx_base_tx();
00093
00094 bool set_auto_tr(bool on);
00095 bool set_enable(bool on);
00096 };
00097
00098
00099
00100
00101
00102 class wbx_base_rx : public wbx_base
00103 {
00104 public:
00105 wbx_base_rx(usrp_basic_sptr usrp, int which);
00106 ~wbx_base_rx();
00107
00108 bool set_auto_tr(bool on);
00109 bool select_rx_antenna(int which_antenna);
00110 bool select_rx_antenna(const std::string &which_antenna);
00111 bool set_gain(float gain);
00112 bool i_and_q_swapped();
00113 };
00114
00115
00116
00117
00118
00119 class _ADF410X_common
00120 {
00121 public:
00122 _ADF410X_common();
00123 virtual ~_ADF410X_common();
00124
00125 bool _compute_regs(double freq, int &retR, int &retcontrol,
00126 int &retN, double &retfreq);
00127 void _write_all(int R, int N, int control);
00128 void _write_R(int R);
00129 void _write_N(int N);
00130 void _write_func(int func);
00131 void _write_init(int init);
00132 int _prescaler();
00133 virtual void _write_it(int v);
00134 virtual double _refclk_freq();
00135 virtual bool _rx_write_io(int value, int mask);
00136 virtual bool _lock_detect();
00137
00138 protected:
00139 virtual usrp_basic* usrp();
00140
00141 int d_R_RSV, d_LDP, d_TEST, d_ABP;
00142 int d_N_RSV, d_CP_GAIN;
00143 int d_P, d_PD2, d_CP2, d_CP1, d_TC, d_FL;
00144 int d_CP3S, d_PDP, d_MUXOUT, d_PD1, d_CR;
00145 int d_R_DIV, d_A_DIV, d_B_DIV;
00146 int d_freq_mult;
00147
00148 int d_spi_format;
00149 int d_spi_enable;
00150 };
00151
00152
00153
00154
00155
00156 class _lo_common : public _ADF410X_common
00157 {
00158 public:
00159 _lo_common();
00160 ~_lo_common();
00161
00162 double freq_min();
00163 double freq_max();
00164
00165 void set_divider(int main_or_aux, int divisor);
00166 void set_divider(const std::string &main_or_aux, int divisor);
00167
00168 struct freq_result_t set_freq(double freq);
00169
00170 protected:
00171 int d_R_DIV, d_P, d_CP2, d_CP1;
00172 int d_DIVSEL, d_DIV2, d_CPGAIN;
00173 int d_div, d_aux_div, d_main_div;
00174 };
00175
00176
00177
00178
00179
00180 class db_wbx_lo_tx : public _lo_common, public wbx_base_tx
00181 {
00182 public:
00183 db_wbx_lo_tx(usrp_basic_sptr usrp, int which);
00184 ~db_wbx_lo_tx();
00185
00186 float gain_min();
00187 float gain_max();
00188 float gain_db_per_step();
00189 bool set_gain(float gain);
00190
00191 double _refclk_freq();
00192 bool _rx_write_io(int value, int mask);
00193 bool _lock_detect();
00194
00195 protected:
00196 usrp_basic* usrp();
00197 };
00198
00199
00200
00201
00202
00203 class db_wbx_lo_rx : public _lo_common, public wbx_base_rx
00204 {
00205 public:
00206 db_wbx_lo_rx(usrp_basic_sptr usrp, int which);
00207 ~db_wbx_lo_rx();
00208
00209 float gain_min();
00210 float gain_max();
00211 float gain_db_per_step();
00212
00213 double _refclk_freq();
00214 bool _rx_write_io(int value, int mask);
00215 bool _lock_detect();
00216
00217 protected:
00218 usrp_basic* usrp();
00219 };
00220
00221 #endif