GNU Radio 3.4.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 version 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 00023 #ifndef INCLUDED_USRP2_BASE_H 00024 #define INCLUDED_USRP2_BASE_H 00025 00026 #include <gr_sync_block.h> 00027 #include <usrp2/usrp2.h> 00028 #include <stdexcept> 00029 00030 // BIG ASS FIXME: get from lower layer MTU calculation 00031 #define USRP2_MIN_RX_SAMPLES 371 00032 00033 /*! 00034 * Base class for all USRP2 blocks 00035 */ 00036 class usrp2_base : public gr_sync_block 00037 { 00038 protected: 00039 usrp2_base(const char *name, 00040 gr_io_signature_sptr input_signature, 00041 gr_io_signature_sptr output_signature, 00042 const std::string &ifc, 00043 const std::string &mac) 00044 throw (std::runtime_error); 00045 00046 usrp2::usrp2::sptr d_u2; 00047 00048 public: 00049 ~usrp2_base(); 00050 00051 /*! 00052 * \brief Get USRP2 hardware MAC address 00053 */ 00054 std::string mac_addr() const; 00055 00056 /*! 00057 * \brief Get interface name used to communicat with USRP2 00058 */ 00059 std::string interface_name() const; 00060 00061 /*! 00062 * \brief Get USRP2 master clock rate 00063 */ 00064 bool fpga_master_clock_freq(long *freq) const; 00065 00066 /*! 00067 * \brief MIMO configuration 00068 */ 00069 bool config_mimo(int flags); 00070 00071 /*! 00072 * \brief Set master time to 0 at next PPS rising edge 00073 */ 00074 bool sync_to_pps(); 00075 00076 /*! 00077 * Reset master time to 0 at every PPS edge 00078 */ 00079 bool sync_every_pps(bool enable); 00080 00081 /*! 00082 * \brief Read memory from Wishbone bus as words 00083 */ 00084 std::vector<uint32_t> peek32(uint32_t addr, uint32_t words); 00085 00086 /*! 00087 * \brief Write memory to Wishbone bus as words 00088 */ 00089 bool poke32(uint32_t addr, const std::vector<uint32_t> &data); 00090 00091 /*! 00092 * \brief Called by scheduler when starting flowgraph 00093 */ 00094 virtual bool start(); 00095 00096 /*! 00097 * \brief Called by scheduler when stopping flowgraph 00098 */ 00099 virtual bool stop(); 00100 00101 /*! 00102 * \brief Derived class must override this 00103 */ 00104 virtual int work(int noutput_items, 00105 gr_vector_const_void_star &input_items, 00106 gr_vector_void_star &output_items) = 0; 00107 }; 00108 00109 #endif /* INCLUDED_USRP2_BASE_H */