fun_ofdm  1.0
802.11a Physical Layer for USRP
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Macros Pages
usrp.h
Go to the documentation of this file.
1 
11 #ifndef USRP_H
12 #define USRP_H
13 
14 #include <uhd/usrp/multi_usrp.hpp>
15 #include <uhd/convert.hpp>
16 #include <uhd/stream.hpp>
17 #include <semaphore.h>
18 
19 namespace fun
20 {
25  struct usrp_params
26  {
27  double freq;
28  double rate;
29  double tx_gain;
30  double rx_gain;
31  double tx_amp;
32  std::string device_addr;
33 
43  usrp_params(double freq = 5.72e9, double rate = 5e6, double tx_gain=20, double rx_gain=20, double tx_amp=1.0, std::string device_addr="") :
44  freq(freq),
45  rate(rate),
48  tx_amp(tx_amp),
50  {
51  }
52  };
53 
60  class usrp
61  {
62  public:
63 
69  usrp(usrp_params params);
70 
71 
72  // Send a burst of samples, and block until the burst has finished
78  void send_burst_sync(std::vector<std::complex<double> > samples);
79 
85  void send_burst(std::vector<std::complex<double> > samples);
86 
87  // Get some samples from the USRP
93  void get_samples(int num_samples, std::vector<std::complex<double> > & buffer);
94 
95 
96  private:
97 
98 
100 
101  boost::shared_ptr<uhd::usrp::multi_usrp> m_usrp;
102  boost::shared_ptr<uhd::device> m_device;
103  uhd::rx_streamer::sptr m_rx_streamer;
104  uhd::tx_streamer::sptr m_tx_streamer;
105 
106  sem_t m_tx_sem;
107  };
108 
109 }
110 
111 
112 #endif // USRP_H