GNU Radio's LIMESDR Package
source.h
Go to the documentation of this file.
1 /* -*- c++ -*- */
2 /*
3  * Copyright 2019 Lime Microsystems <info@limemicro.com>
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_SOURCE_H
22 #define INCLUDED_LIMESDR_SOURCE_H
23 
24 #include <gnuradio/sync_block.h>
25 #include <limesdr/api.h>
26 
27 namespace gr {
28 namespace limesdr {
29 
30 /*!
31  * \brief <+description of block+>
32  * \ingroup limesdr
33  *
34  */
35 class LIMESDR_API source : virtual public gr::sync_block
36 {
37 public:
38  typedef boost::shared_ptr<source> sptr;
39 
40  /*!
41  * \brief Return a shared_ptr to a new instance of limesdr::source.
42  *
43  * To avoid accidental use of raw pointers, limesdr::source's
44  * constructor is in a private implementation
45  * class. limesdr::source::make is the public interface for
46  * creating new instances.
47  * @param serial Device serial number. Cannot be left blank.
48  *
49  * @param channel_mode Channel and mode selection A(1), B(2), (A+B)MIMO(3).
50  *
51  * @param filename Path to file if file switch is turned on.
52  *
53  * @return a new limesdr source block object
54  */
55  static sptr make(std::string serial, int channel_mode, const std::string& filename);
56 
57  /**
58  * Set center frequency
59  *
60  * @param freq Frequency to set in Hz
61  *
62  * @param chan Channel (not used)
63  *
64  * @return actual center frequency in Hz
65  */
66  virtual double set_center_freq(double freq, size_t chan = 0) = 0;
67 
68  /**
69  * Set which antenna is used
70  *
71  * @param antenna Antenna to set: None(0), LNAH(1), LNAL(2), LNAW(3), AUTO(255)
72  *
73  * @param channel Channel selection: A(LMS_CH_0),B(LMS_CH_1).
74  */
75  virtual void set_antenna(int antenna, int channel = 0) = 0;
76 
77  /**
78  * Set NCO (numerically controlled oscillator).
79  * By selecting NCO frequency
80  * configure NCO. When NCO frequency is 0, NCO is off.
81  *
82  * @param nco_freq NCO frequency in Hz.
83  *
84  * @param channel Channel index.
85  */
86  virtual void set_nco(float nco_freq, int channel) = 0;
87 
88  /**
89  * Set analog filters.
90  *
91  * @param analog_bandw Channel filter bandwidth in Hz.
92  *
93  * @param channel Channel selection: A(LMS_CH_0),B(LMS_CH_1).
94  *
95  * @return actual filter bandwidth in Hz
96  */
97  virtual double set_bandwidth(double analog_bandw, int channel = 0) = 0;
98 
99  /**
100  * Set digital filters (GFIR).
101  *
102  * @param digital_bandw Channel filter bandwidth in Hz.
103  *
104  * @param channel Channel selection: A(LMS_CH_0),B(LMS_CH_1).
105  */
106  virtual void set_digital_filter(double digital_bandw, int channel) = 0;
107 
108  /**
109  * Set the combined gain value in dB
110  *
111  * @note actual gain depends on LO frequency and analog LPF configuration and
112  * resulting output signal level may be different when those values are changed
113  *
114  * @param gain_dB Desired gain: [0,70] RX
115  *
116  * @param channel Channel selection: A(LMS_CH_0),B(LMS_CH_1).
117  *
118  * @return actual gain in dB
119  */
120  virtual unsigned set_gain(unsigned gain_dB, int channel = 0) = 0;
121 
122  /**
123  * Set the same sample rate for both channels.
124  *
125  * @param rate Sample rate in S/s.
126  *
127  * @return actual sample rate in S/s
128  */
129  virtual double set_sample_rate(double rate) = 0;
130 
131  /**
132  * Set oversampling for both channels.
133  *
134  * @param oversample Oversampling value (0 (default),1,2,4,8,16,32).
135  */
136  virtual void set_oversampling(int oversample) = 0;
137 
138  /**
139  * Perform device calibration.
140  *
141  * @param bandw Set calibration bandwidth in Hz.
142  *
143  * @param channel Channel selection: A(LMS_CH_0),B(LMS_CH_1).
144  */
145  virtual void calibrate(double bandw, int channel = 0) = 0;
146 
147  /**
148  * Set stream buffer size
149  *
150  * @param size FIFO buffer size in samples
151  */
152  virtual void set_buffer_size(uint32_t size) = 0;
153 
154  /**
155  * Set TCXO DAC.
156  * @note Care must be taken as this parameter is returned to default value only after
157  * power off.
158  * @note LimeSDR-Mini default value is 180 range is [0,255]
159  * LimeSDR-USB default value is 125 range is [0,255]
160  * LimeSDR-PCIe default value is 134 range is [0,255]
161  * LimeNET-Micro default value is 30714 range is [0,65535]
162  *
163  * @param dacVal DAC value (0-65535)
164  */
165  virtual void set_tcxo_dac(uint16_t dacVal = 125) = 0;
166 };
167 
168 } // namespace limesdr
169 } // namespace gr
170 
171 #endif /* INCLUDED_LIMESDR_SOURCE_H */
gr::limesdr::source::set_oversampling
virtual void set_oversampling(int oversample)=0
gr::limesdr::source::set_antenna
virtual void set_antenna(int antenna, int channel=0)=0
gr::limesdr::source::set_sample_rate
virtual double set_sample_rate(double rate)=0
gr::limesdr::source::set_buffer_size
virtual void set_buffer_size(uint32_t size)=0
gr::limesdr::source::set_tcxo_dac
virtual void set_tcxo_dac(uint16_t dacVal=125)=0
gr::limesdr::source
<+description of block+>
Definition: source.h:36
gr::limesdr::source::calibrate
virtual void calibrate(double bandw, int channel=0)=0
gr::limesdr::source::set_bandwidth
virtual double set_bandwidth(double analog_bandw, int channel=0)=0
gr::limesdr::source::set_digital_filter
virtual void set_digital_filter(double digital_bandw, int channel)=0
LIMESDR_API
#define LIMESDR_API
Definition: api.h:31
gr::limesdr::source::set_nco
virtual void set_nco(float nco_freq, int channel)=0
gr::limesdr::source::set_gain
virtual unsigned set_gain(unsigned gain_dB, int channel=0)=0
gr
Definition: sink.h:27
gr::limesdr::source::set_center_freq
virtual double set_center_freq(double freq, size_t chan=0)=0
gr::limesdr::source::make
static sptr make(std::string serial, int channel_mode, const std::string &filename)
Return a shared_ptr to a new instance of limesdr::source.
gr::limesdr::source::sptr
boost::shared_ptr< source > sptr
Definition: source.h:38
api.h