⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 usrp_basic.h

📁 这是用python语言写的一个数字广播的信号处理工具包。利用它
💻 H
📖 第 1 页 / 共 2 页
字号:
  int read (void *buf, int len, bool *overrun);  // ACCESSORS  //! sampling rate of A/D converter  virtual long converter_rate() const { return fpga_master_clock_freq(); } // 64M  long adc_rate() const { return converter_rate(); }  long adc_freq() const { return converter_rate(); }   //!< deprecated method name  /*!   * \brief Return daughterboard ID for given Rx daughterboard slot [0,1].   *   * \param which_dboard	[0,1] which Rx daughterboard   *   * \return daughterboard id >= 0 if successful   * \return -1 if no daugherboard   * \return -2 if invalid EEPROM on daughterboard   */  int daughterboard_id (int which_dboard) const { return d_dbid[which_dboard & 0x1]; }  // ----------------------------------------------------------------  // routines for controlling the Programmable Gain Amplifier  /*!   * \brief Set Programmable Gain Amplifier (PGA)   *   * \param which	which A/D [0,3]   * \param gain_in_db	gain value (linear in dB)   *   * gain is rounded to closest setting supported by hardware.   *   * \returns true iff sucessful.   *   * \sa pga_min(), pga_max(), pga_db_per_step()   */  bool set_pga (int which, double gain_in_db);  /*!   * \brief Return programmable gain amplifier gain setting in dB.   *   * \param which	which A/D [0,3]   */  double pga (int which) const;  /*!   * \brief Return minimum legal PGA gain in dB.   */  double pga_min () const { return 0.0; }  /*!   * \brief Return maximum legal PGA gain in dB.   */  double pga_max () const { return 20.0; }  /*!   * \brief Return hardware step size of PGA (linear in dB).   */  double pga_db_per_step () const { return 20.0 / 20; }  /*!   * \brief Write direction register (output enables) for pins that go to daughterboard.   *   * \param which_dboard	[0,1] which d'board   * \param value		value to write into register   * \param mask		which bits of value to write into reg   *   * Each d'board has 16-bits of general purpose i/o.   * Setting the bit makes it an output from the FPGA to the d'board.   *   * This register is initialized based on a value stored in the   * d'board EEPROM.  In general, you shouldn't be using this routine   * without a very good reason.  Using this method incorrectly will   * kill your USRP motherboard and/or daughterboard.   */  bool _write_oe (int which_dboard, int value, int mask);  /*!   * \brief Write daughterboard i/o pin value   *   * \param which_dboard	[0,1] which d'board   * \param value		value to write into register   * \param mask		which bits of value to write into reg   */  bool write_io (int which_dboard, int value, int mask);  /*!   * \brief Read daughterboard i/o pin value   *   * \param which_dboard	[0,1] which d'board   * \param value		output   */  bool read_io (int which_dboard, int *value);  /*!   * \brief Read daughterboard i/o pin value   *   * \param which_dboard	[0,1] which d'board   * \returns register value if successful, else READ_FAILED   */  int read_io (int which_dboard);  /*!   * \brief Write auxiliary digital to analog converter.   *   * \param which_dboard	[0,1] which d'board   *    			N.B., SLOT_TX_A and SLOT_RX_A share the same AUX DAC's.   *          			SLOT_TX_B and SLOT_RX_B share the same AUX DAC's.   * \param which_dac		[2,3] TX slots must use only 2 and 3.   * \param value		[0,4095]   * \returns true iff successful   */  bool write_aux_dac (int which_board, int which_dac, int value);  /*!   * \brief Read auxiliary analog to digital converter.   *   * \param which_dboard	[0,1] which d'board   * \param which_adc		[0,1]   * \param value		return 12-bit value [0,4095]   * \returns true iff successful   */  bool read_aux_adc (int which_dboard, int which_adc, int *value);  /*!   * \brief Read auxiliary analog to digital converter.   *   * \param which_dboard	[0,1] which d'board   * \param which_adc		[0,1]   * \returns value in the range [0,4095] if successful, else READ_FAILED.   */  int read_aux_adc (int which_dboard, int which_adc);  /*!   * \brief returns current fusb block size   */  int block_size() const;  /*!   * \brief Enable/disable automatic DC offset removal control loop in FPGA   *   * \param bits  which control loops to enable   * \param mask  which \p bits to pay attention to   *   * If the corresponding bit is set, enable the automatic DC   * offset correction control loop.   *   * <pre>   * The 4 low bits are significant:   *   *   ADC0 = (1 << 0)   *   ADC1 = (1 << 1)   *   ADC2 = (1 << 2)   *   ADC3 = (1 << 3)   * </pre>   *   * By default the control loop is enabled on all ADC's.   */  bool set_dc_offset_cl_enable(int bits, int mask);  // called in base class to derived class order  bool start ();  bool stop ();};/*! * \brief class for accessing the transmit side of the USRP */class usrp_basic_tx : public usrp_basic {private:  fusb_devhandle	*d_devhandle;  fusb_ephandle		*d_ephandle;  int			 d_bytes_seen;		// how many bytes we've seen  bool			 d_first_write;  bool			 d_tx_enable; protected:  int			 d_dbid[2];		// Tx daughterboard ID's  /*!   * \param which_board	     Which USRP board on usb (not particularly useful; use 0)   * \param fusb_block_size  fast usb xfer block size.  Must be a multiple of 512.   *                         Use zero for a reasonable default.   * \param fusb_nblocks     number of fast usb URBs to allocate.  Use zero for a reasonable default.   */  usrp_basic_tx (int which_board,		 int fusb_block_size=0,		 int fusb_nblocks=0,		 const std::string fpga_filename = "",		 const std::string firmware_filename = ""		 );		// throws if trouble  bool set_tx_enable (bool on);  bool tx_enable () const { return d_tx_enable; }  bool disable_tx ();		// conditional disable, return prev state  void restore_tx (bool on);	// conditional set  void probe_tx_slots (bool verbose);  int  dboard_to_slot (int dboard) { return (dboard << 1) | 0; }public:  ~usrp_basic_tx ();  /*!   * \brief invokes constructor, returns instance or 0 if trouble   *   * \param which_board	     Which USRP board on usb (not particularly useful; use 0)   * \param fusb_block_size  fast usb xfer block size.  Must be a multiple of 512.    *                         Use zero for a reasonable default.   * \param fusb_nblocks     number of fast usb URBs to allocate.  Use zero for a reasonable default.    */  static usrp_basic_tx *make (int which_board, int fusb_block_size=0, int fusb_nblocks=0,			      const std::string fpga_filename = "",			      const std::string firmware_filename = ""			      );  // MANIPULATORS  /*!   * \brief tell the fpga the rate tx samples are going to the D/A's   *   * div = fpga_master_clock_freq () * 2   *   * sample_rate is determined by a myriad of registers   * in the 9862.  That's why you have to tell us, so   * we can tell the fpga.   */  bool set_fpga_tx_sample_rate_divisor (unsigned int div);  /*!   * \brief Write data to the A/D's via the FPGA.   *   * \p len must be a multiple of 512 bytes.   * \returns number of bytes written or -1 on error.   *   * if \p underrun is non-NULL, it will be set to true iff   * a transmit underrun condition is detected.   */  int write (const void *buf, int len, bool *underrun);  /*   * Block until all outstanding writes have completed.   * This is typically used to assist with benchmarking   */  void wait_for_completion ();  // ACCESSORS  //! sampling rate of D/A converter  virtual long converter_rate() const { return fpga_master_clock_freq () * 2; } // 128M  long dac_rate() const { return converter_rate(); }  long dac_freq() const { return converter_rate(); }	//!< deprecated method name  /*!   * \brief Return daughterboard ID for given Tx daughterboard slot [0,1].   *   * \return daughterboard id >= 0 if successful   * \return -1 if no daugherboard   * \return -2 if invalid EEPROM on daughterboard   */  int daughterboard_id (int which_dboard) const { return d_dbid[which_dboard & 0x1]; }  // ----------------------------------------------------------------  // routines for controlling the Programmable Gain Amplifier  /*!   * \brief Set Programmable Gain Amplifier (PGA)   *   * \param which	which D/A [0,3]   * \param gain_in_db	gain value (linear in dB)   *   * gain is rounded to closest setting supported by hardware.   * Note that DAC 0 and DAC 1 share a gain setting as do DAC 2 and DAC 3.   * Setting DAC 0 affects DAC 1 and vice versa.  Same with DAC 2 and DAC 3.   *   * \returns true iff sucessful.   *   * \sa pga_min(), pga_max(), pga_db_per_step()   */  bool set_pga (int which, double gain_in_db);  /*!   * \brief Return programmable gain amplifier gain in dB.   *   * \param which	which D/A [0,3]   */  double pga (int which) const;  /*!   * \brief Return minimum legal PGA gain in dB.   */  double pga_min () const { return -20.0; }  /*!   * \brief Return maximum legal PGA gain in dB.   */  double pga_max () const { return 0.0; }  /*!   * \brief Return hardware step size of PGA (linear in dB).   */  double pga_db_per_step () const { return 20.0/255; }  /*!   * \brief Write direction register (output enables) for pins that go to daughterboard.   *   * \param which_dboard	[0,1] which d'board   * \param value		value to write into register   * \param mask		which bits of value to write into reg   *   * Each d'board has 16-bits of general purpose i/o.   * Setting the bit makes it an output from the FPGA to the d'board.   *   * This register is initialized based on a value stored in the   * d'board EEPROM.  In general, you shouldn't be using this routine   * without a very good reason.  Using this method incorrectly will   * kill your USRP motherboard and/or daughterboard.   */  bool _write_oe (int which_dboard, int value, int mask);  /*!   * \brief Write daughterboard i/o pin value   *   * \param which_dboard	[0,1] which d'board   * \param value		value to write into register   * \param mask		which bits of value to write into reg   */  bool write_io (int which_dboard, int value, int mask);  /*!   * \brief Read daughterboard i/o pin value   *   * \param which_dboard	[0,1] which d'board   * \param value		return value   */  bool read_io (int which_dboard, int *value);  /*!   * \brief Read daughterboard i/o pin value   *   * \param which_dboard	[0,1] which d'board   * \returns register value if successful, else READ_FAILED   */  int read_io (int which_dboard);  /*!   * \brief Write auxiliary digital to analog converter.   *   * \param which_dboard	[0,1] which d'board   *    			N.B., SLOT_TX_A and SLOT_RX_A share the same AUX DAC's.   *          			SLOT_TX_B and SLOT_RX_B share the same AUX DAC's.   * \param which_dac		[2,3] TX slots must use only 2 and 3.   * \param value		[0,4095]   * \returns true iff successful   */  bool write_aux_dac (int which_board, int which_dac, int value);  /*!   * \brief Read auxiliary analog to digital converter.   *   * \param which_dboard	[0,1] which d'board   * \param which_adc		[0,1]   * \param value		return 12-bit value [0,4095]   * \returns true iff successful   */  bool read_aux_adc (int which_dboard, int which_adc, int *value);  /*!   * \brief Read auxiliary analog to digital converter.   *   * \param which_dboard	[0,1] which d'board   * \param which_adc		[0,1]   * \returns value in the range [0,4095] if successful, else READ_FAILED.   */  int read_aux_adc (int which_dboard, int which_adc);  /*!   * \brief returns current fusb block size   */  int block_size() const;  // called in base class to derived class order  bool start ();  bool stop ();};#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -