Imported Upstream version 3.2.2
[debian/gnuradio] / gr-usrp2 / src / usrp2_base.cc
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 #ifdef HAVE_CONFIG_H
24 #include <config.h>
25 #endif
26
27 #include <usrp2_base.h>
28 #include <gr_io_signature.h>
29 #include <iostream>
30
31 usrp2_base::usrp2_base(const char *name,
32                        gr_io_signature_sptr input_signature,
33                        gr_io_signature_sptr output_signature,
34                        const std::string &ifc,
35                        const std::string &mac) 
36   throw (std::runtime_error)
37   : gr_sync_block(name,
38                   input_signature,
39                   output_signature),
40     d_u2(usrp2::usrp2::sptr())
41 {
42   d_u2 = usrp2::usrp2::make(ifc, mac);
43   if (!d_u2)
44     throw std::runtime_error("Unable to initialize USRP2!");
45 }
46
47 usrp2_base::~usrp2_base ()
48 {
49   // NOP
50 }
51
52 std::string
53 usrp2_base::mac_addr() const
54 {
55   return d_u2->mac_addr();
56 }
57
58 std::string
59 usrp2_base::interface_name() const
60 {
61   return d_u2->interface_name();
62 }
63
64 bool
65 usrp2_base::fpga_master_clock_freq(long *freq) const
66 {
67   return d_u2->fpga_master_clock_freq(freq);
68 }
69
70 bool
71 usrp2_base::config_mimo(int flags)
72 {
73   return d_u2->config_mimo(flags);
74 }
75
76 bool
77 usrp2_base::sync_to_pps()
78 {
79   return d_u2->sync_to_pps();
80 }
81
82 bool
83 usrp2_base::sync_every_pps(bool enable)
84 {
85   return d_u2->sync_every_pps(enable);
86 }
87
88 std::vector<uint32_t>
89 usrp2_base::peek32(uint32_t addr, uint32_t words)
90 {
91   return d_u2->peek32(addr, words);
92 }
93
94 bool
95 usrp2_base::poke32(uint32_t addr, const std::vector<uint32_t> &data)
96 {
97   return d_u2->poke32(addr, data);
98 }
99
100 bool
101 usrp2_base::start()
102 {
103   // Default implementation is NOP
104   return true;
105 }
106
107 bool
108 usrp2_base::stop()
109 {
110   // Default implementation is NOP
111   return true;
112 }