Replaced USRP2 peek() with peek32(), handles endian-swapping if needed
[debian/gnuradio] / gr-usrp2 / src / usrp2_base.h
1 /* -*- c++ -*- */
2 /*
3  * Copyright 2008 Free Software Foundation, Inc.
4  * 
5  * This file is part of GNU Radio
6  * 
7  * GNU Radio is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 3, or (at your option)
10  * any later version.
11  * 
12  * GNU Radio is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16  * 
17  * You should have received a copy of the GNU General Public License
18  * along with GNU Radio; see the file COPYING.  If not, write to
19  * the Free Software Foundation, Inc., 51 Franklin Street,
20  * Boston, MA 02110-1301, USA.
21  */
22
23 #ifndef INCLUDED_USRP2_BASE_H
24 #define INCLUDED_USRP2_BASE_H
25
26 #include <gr_sync_block.h>
27 #include <usrp2/usrp2.h>
28 #include <stdexcept>
29
30 // BIG ASS FIXME: get from lower layer MTU calculation
31 #define USRP2_MIN_RX_SAMPLES 371
32
33 /*!
34  * Base class for all USRP2 blocks
35  */
36 class usrp2_base : public gr_sync_block
37 {
38 protected:
39   usrp2_base(const char *name,
40              gr_io_signature_sptr input_signature,
41              gr_io_signature_sptr output_signature,
42              const std::string &ifc,
43              const std::string &mac)
44     throw (std::runtime_error);
45
46   usrp2::usrp2::sptr d_u2;
47
48 public:
49   ~usrp2_base();
50
51   /*!
52    * \brief Get USRP2 hardware MAC address
53    */
54   std::string mac_addr() const;
55   
56   /*!
57    * \brief Get USRP2 master clock rate
58    */
59   bool fpga_master_clock_freq(long *freq) const;
60
61   /*!
62    * \brief Set master time to 0 at next PPS rising edge
63    */
64   bool sync_to_pps();
65
66   /*!
67    * \brief Read memory from Wishbone bus as words
68    */
69   std::vector<uint32_t> peek32(uint32_t addr, uint32_t words);
70
71   /*!
72    * \brief Called by scheduler when starting flowgraph
73    */
74   virtual bool start();
75   
76   /*!
77    * \brief Called by scheduler when stopping flowgraph
78    */
79   virtual bool stop();
80
81   /*!
82    * \brief Derived class must override this
83    */
84   virtual int work(int noutput_items,
85                    gr_vector_const_void_star &input_items,
86                    gr_vector_void_star &output_items) = 0;
87 };
88
89 #endif /* INCLUDED_USRP2_BASE_H */