00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef INCLUDED_USRP1_SOURCE_BASE_H
00024 #define INCLUDED_USRP1_SOURCE_BASE_H
00025
00026 #include <gr_sync_block.h>
00027 #include <stdexcept>
00028
00029 class usrp_standard_rx;
00030
00034 class usrp1_source_base : public gr_sync_block {
00035 private:
00036 usrp_standard_rx *d_usrp;
00037 int d_noverruns;
00038
00039 protected:
00040 usrp1_source_base (const std::string &name,
00041 gr_io_signature_sptr output_signature,
00042 int which_board,
00043 unsigned int decim_rate,
00044 int nchan,
00045 int mux,
00046 int mode,
00047 int fusb_block_size,
00048 int fusb_nblocks,
00049 const std::string fpga_filename,
00050 const std::string firmware_filename
00051 ) throw (std::runtime_error);
00052
00056 virtual int ninput_bytes_reqd_for_noutput_items (int noutput_items) = 0;
00057
00061 unsigned int sizeof_basic_sample() const;
00062
00077 virtual void copy_from_usrp_buffer (gr_vector_void_star &output_items,
00078 int output_index,
00079 int output_items_available,
00080 int &output_items_produced,
00081 const void *usrp_buffer,
00082 int usrp_buffer_length,
00083 int &bytes_read) = 0;
00084
00085 public:
00087 static const int READ_FAILED = -99999;
00088
00089 ~usrp1_source_base ();
00090
00091 int work (int noutput_items,
00092 gr_vector_const_void_star &input_items,
00093 gr_vector_void_star &output_items);
00094
00095 bool start();
00096 bool stop();
00097
00104 bool set_decim_rate (unsigned int rate);
00105 bool set_nchannels (int nchan);
00106 bool set_mux (int mux);
00107
00115 bool set_rx_freq (int channel, double freq);
00116
00120 bool set_fpga_mode (int mode);
00121
00122 void set_verbose (bool verbose);
00123
00130 bool set_ddc_phase(int channel, int phase);
00131
00144 bool set_pga (int which, double gain_in_db);
00145
00151 double pga (int which) const;
00152
00156 double pga_min () const;
00157
00161 double pga_max () const;
00162
00166 double pga_db_per_step () const;
00167
00168
00169
00170 long fpga_master_clock_freq() const;
00171 long converter_rate() const;
00172 long adc_rate() const { return converter_rate(); }
00173 long adc_freq() const { return converter_rate(); }
00174
00175 unsigned int decim_rate () const;
00176 int nchannels () const;
00177 int mux () const;
00178 double rx_freq (int channel) const;
00179 int noverruns () const { return d_noverruns; }
00180
00188 int daughterboard_id (int which_dboard) const;
00189
00200 bool write_aux_dac (int which_board, int which_dac, int value);
00201
00209 int read_aux_adc (int which_dboard, int which_adc);
00210
00218 bool write_eeprom (int i2c_addr, int eeprom_offset, const std::string buf);
00219
00227 std::string read_eeprom (int i2c_addr, int eeprom_offset, int len);
00228
00236 bool write_i2c (int i2c_addr, const std::string buf);
00237
00245 std::string read_i2c (int i2c_addr, int len);
00246
00252 bool set_adc_offset (int which, int offset);
00253
00261 bool set_dac_offset (int which, int offset, int offset_pin);
00262
00269 bool set_adc_buffer_bypass (int which, bool bypass);
00270
00276 std::string serial_number();
00277
00293 bool _write_oe (int which_dboard, int value, int mask);
00294
00302 bool write_io (int which_dboard, int value, int mask);
00303
00310 int read_io (int which_dboard);
00311
00332 bool set_dc_offset_cl_enable(int bits, int mask);
00333
00362 bool set_format(unsigned int format);
00363
00367 unsigned int format () const;
00368
00369 static unsigned int make_format(int width=16, int shift=0,
00370 bool want_q=true, bool bypass_halfband=false);
00371 static int format_width(unsigned int format);
00372 static int format_shift(unsigned int format);
00373 static bool format_want_q(unsigned int format);
00374 static bool format_bypass_halfband(unsigned int format);
00375
00376
00377
00378
00379
00380
00387 bool _write_fpga_reg (int regno, int value);
00388
00396 bool _write_fpga_reg_masked (int regno, int value, int mask);
00397
00403 int _read_fpga_reg (int regno);
00404
00412 bool _write_9862 (int which_codec, int regno, unsigned char value);
00413
00420 int _read_9862 (int which_codec, int regno) const;
00421
00435 bool _write_spi (int optional_header, int enables, int format, std::string buf);
00436
00437
00438
00439
00440
00441
00442
00443
00444
00445
00446
00447
00448
00449
00450
00451
00452 std::string _read_spi (int optional_header, int enables, int format, int len);
00453 };
00454
00455 #endif