GNU Radio's OsmoSDR Package
bladerf_common.h
Go to the documentation of this file.
1 /* -*- c++ -*- */
2 /*
3  * Copyright 2013 Nuand LLC
4  * Copyright 2013 Dimitri Stolnikov <horiz0n@gmx.net>
5  *
6  * GNU Radio is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 3, or (at your option)
9  * any later version.
10  *
11  * GNU Radio is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with GNU Radio; see the file COPYING. If not, write to
18  * the Free Software Foundation, Inc., 51 Franklin Street,
19  * Boston, MA 02110-1301, USA.
20  */
21 #ifndef INCLUDED_BLADERF_COMMON_H
22 #define INCLUDED_BLADERF_COMMON_H
23 
24 #include <vector>
25 #include <string>
26 
27 #include <boost/circular_buffer.hpp>
28 #include <boost/thread/mutex.hpp>
29 #include <boost/thread/shared_mutex.hpp>
30 #include <boost/thread/condition_variable.hpp>
31 
32 #include <gnuradio/gr_complex.h>
33 
34 #include <libbladeRF.h>
35 
36 #include "osmosdr/ranges.h"
37 
38 /* We currently read/write 1024 samples (pairs of 16-bit signed ints) */
39 #define BLADERF_SAMPLE_BLOCK_SIZE (1024)
40 
41 /*
42  * Default size of sample FIFO, in entries.
43  * This can be overridden by the environment variable BLADERF_SAMPLE_FIFO_SIZE.
44  */
45 #ifndef BLADERF_SAMPLE_FIFO_SIZE
46 # define BLADERF_SAMPLE_FIFO_SIZE (2 * 1024 * 1024)
47 #endif
48 
49 #define BLADERF_SAMPLE_FIFO_MIN_SIZE (3 * BLADERF_SAMPLE_BLOCK_SIZE)
50 
52 {
53 public:
56 
57 protected:
61 
62  static std::vector< std::string > devices();
63 
64  bool is_running();
65  void set_running(bool is_running);
66 
67  bladerf *dev;
68 
69  int16_t *raw_sample_buf;
70  boost::circular_buffer<gr_complex> *sample_fifo;
71  boost::mutex sample_fifo_lock;
72  boost::condition_variable samples_available;
73 private:
74  bool running;
75  boost::shared_mutex state_lock;
76 };
77 
78 #endif
bladerf * dev
Definition: bladerf_common.h:67
osmosdr::meta_range_t sample_rates()
Definition: ranges.h:69
int16_t * raw_sample_buf
Definition: bladerf_common.h:69
osmosdr::freq_range_t filter_bandwidths()
osmosdr::freq_range_t freq_range()
boost::mutex sample_fifo_lock
Definition: bladerf_common.h:71
static std::vector< std::string > devices()
Definition: bladerf_common.h:51
boost::condition_variable samples_available
Definition: bladerf_common.h:72
void set_running(bool is_running)
boost::circular_buffer< gr_complex > * sample_fifo
Definition: bladerf_common.h:70