GNU Radio's LIMESDR Package
sink_impl.h
Go to the documentation of this file.
1/* -*- c++ -*- */
2/*
3 * Copyright 2019 Lime Microsystems.
4 *
5 * This is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 3, or (at your option)
8 * any later version.
9 *
10 * This software is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this software; see the file COPYING. If not, write to
17 * the Free Software Foundation, Inc., 51 Franklin Street,
18 * Boston, MA 02110-1301, USA.
19 */
20
21#ifndef INCLUDED_LIMESDR_SINK_IMPL_H
22#define INCLUDED_LIMESDR_SINK_IMPL_H
23
24#include "device_handler.h"
25#include <limesdr/sink.h>
26
27
28static const pmt::pmt_t TIME_TAG = pmt::string_to_symbol("tx_time");
29
30namespace gr {
31namespace limesdr {
32class sink_impl : public sink
33{
34private:
35 lms_stream_t streamId[2];
36
37 bool stream_analyzer = false;
38
39 int sink_block = 2;
40
41 pmt::pmt_t LENGTH_TAG;
42 lms_stream_meta_t tx_meta;
43 long burst_length = 0;
44 int nitems_send = 0;
45 int ret[2] = { 0 };
46 int pa_path[2] = { 0 }; // TX PA path NONE
47
48 struct constant_data {
49 std::string serial;
50 int device_number;
51 int channel_mode;
52 double samp_rate = 10e6;
53 uint32_t FIFO_size = 0;
54 } stored;
55
56 std::chrono::high_resolution_clock::time_point t1, t2;
57
58 void work_tags(int noutput_items);
59
60 void print_stream_stats(int channel);
61
62public:
63 sink_impl(std::string serial,
64 int channel_mode,
65 const std::string& filename,
66 const std::string& length_tag_name);
68
69 int work(int noutput_items,
70 gr_vector_const_void_star& input_items,
71 gr_vector_void_star& output_items);
72
73 bool start(void);
74
75 bool stop(void);
76
77 inline gr::io_signature::sptr args_to_io_signature(int channel_number);
78
79 void init_stream(int device_number, int channel);
80 void release_stream(int device_number, lms_stream_t* stream);
81
82 double set_center_freq(double freq, size_t chan = 0);
83
84 void set_antenna(int antenna, int channel = 0);
85 void toggle_pa_path(int device_number, bool enable);
86
87 void set_nco(float nco_freq, int channel = 0);
88
89 double set_bandwidth(double analog_bandw, int channel = 0);
90
91 void set_digital_filter(double digital_bandw, int channel = 0);
92
93 unsigned set_gain(unsigned gain_dB, int channel = 0);
94
95 double set_sample_rate(double rate);
96
97 void set_oversampling(int oversample);
98
99 void set_buffer_size(uint32_t size);
100
101 void calibrate(double bandw, int channel = 0);
102
103 void set_tcxo_dac(uint16_t dacVal = 125);
104
105 void write_lms_reg(uint32_t address, uint16_t val);
106
107 // Set GPIO pin directions, one bit per pin
108 void set_gpio_dir(uint8_t dir);
109
110 // Write GPIO outputs, one bit per pin
111 void write_gpio(uint8_t out);
112
113 // Read GPIO inputs, one bit per pin
114 uint8_t read_gpio();
115};
116} // namespace limesdr
117} // namespace gr
118
119#endif
Definition sink_impl.h:33
void set_antenna(int antenna, int channel=0)
void init_stream(int device_number, int channel)
void write_lms_reg(uint32_t address, uint16_t val)
unsigned set_gain(unsigned gain_dB, int channel=0)
void set_digital_filter(double digital_bandw, int channel=0)
void calibrate(double bandw, int channel=0)
double set_sample_rate(double rate)
void set_oversampling(int oversample)
void toggle_pa_path(int device_number, bool enable)
void write_gpio(uint8_t out)
gr::io_signature::sptr args_to_io_signature(int channel_number)
double set_bandwidth(double analog_bandw, int channel=0)
double set_center_freq(double freq, size_t chan=0)
void set_tcxo_dac(uint16_t dacVal=125)
sink_impl(std::string serial, int channel_mode, const std::string &filename, const std::string &length_tag_name)
void set_gpio_dir(uint8_t dir)
int work(int noutput_items, gr_vector_const_void_star &input_items, gr_vector_void_star &output_items)
void set_buffer_size(uint32_t size)
void release_stream(int device_number, lms_stream_t *stream)
void set_nco(float nco_freq, int channel=0)
Definition sink.h:30
Definition rfe.h:29
static const pmt::pmt_t TIME_TAG
Definition sink_impl.h:28