1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
|
/* -*- c++ -*- */
/*
* Copyright 2014 Analog Devices Inc.
* Author: Paul Cercueil <paul.cercueil@analog.com>
*
* SPDX-License-Identifier: GPL-3.0-or-later
*
*/
#ifndef INCLUDED_IIO_FMCOMMS2_SOURCE_IMPL_H
#define INCLUDED_IIO_FMCOMMS2_SOURCE_IMPL_H
#include "device_source_impl.h"
#include <gnuradio/iio/fmcomms2_source.h>
#include <string>
#include <thread>
#include <vector>
#include <volk/volk_alloc.hh>
namespace gr {
namespace iio {
template <typename T>
class fmcomms2_source_impl : public fmcomms2_source<T>, public device_source_impl
{
private:
std::vector<std::string>
get_channels_vector(bool ch1_en, bool ch2_en, bool ch3_en, bool ch4_en);
std::vector<std::string> get_channels_vector(const std::vector<bool>& ch_en);
std::thread overflow_thd;
void check_overflow(void);
const static int s_initial_device_buf_size = 8192;
std::vector<volk::vector<short>> d_device_bufs;
gr_vector_void_star d_device_item_ptrs;
volk::vector<float> d_float_rvec;
volk::vector<float> d_float_ivec;
int work(int noutput_items,
gr_vector_const_void_star& input_items,
gr_vector_void_star& output_items);
public:
fmcomms2_source_impl(iio_context* ctx,
const std::vector<bool>& ch_en,
unsigned long buffer_size);
~fmcomms2_source_impl();
virtual void set_len_tag_key(const std::string& len_tag_key);
virtual void set_frequency(unsigned long long frequency);
virtual void set_samplerate(unsigned long samplerate);
virtual void set_gain_mode(size_t chan, const std::string& mode);
virtual void set_gain(size_t chan, double gain_value);
virtual void set_quadrature(bool quadrature);
virtual void set_rfdc(bool rfdc);
virtual void set_bbdc(bool bbdc);
virtual void set_filter_params(const std::string& filter_source,
const std::string& filter_filename,
float fpass,
float fstop);
protected:
void update_dependent_params();
unsigned long long d_frequency = 2400000000;
unsigned long d_samplerate = 1000000;
unsigned long d_bandwidth = 20000000;
bool d_quadrature = true;
bool d_rfdc = true;
bool d_bbdc = true;
std::vector<std::string> d_gain_mode = {
"manual", "manual", "manual", "manual"
}; // TODO - make these enums
std::vector<double> d_gain_value = { 0, 0, 0, 0 };
std::string d_rf_port_select = "A_BALANCED";
std::string d_filter_source = "Auto";
std::string d_filter_filename = "";
float d_fpass = (float)d_samplerate / 4.0;
float d_fstop = (float)d_samplerate / 3.0;
};
} // namespace iio
} // namespace gr
#endif /* INCLUDED_IIO_FMCOMMS2_SOURCE_IMPL_H */
|