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  * @param align_ch_phase Perform MIMO phase alignment by calling AlignRxRF()
54  * as described in
55  * https://github.com/myriadrf/LMS7002M-docs/blob/master/LimeSDR-USB_channel_alignment_v01r00.pdf
56  *
57  * @return a new limesdr source block object
58  */
59  static sptr make(std::string serial,
60  int channel_mode,
61  const std::string& filename,
62  bool align_ch_phase);
63 
64  /**
65  * Set center frequency
66  *
67  * @param freq Frequency to set in Hz
68  *
69  * @param chan Channel (not used)
70  *
71  * @return actual center frequency in Hz
72  */
73  virtual double set_center_freq(double freq, size_t chan = 0) = 0;
74 
75  /**
76  * Set which antenna is used
77  *
78  * @param antenna Antenna to set: None(0), LNAH(1), LNAL(2), LNAW(3), AUTO(255)
79  *
80  * @param channel Channel selection: A(LMS_CH_0),B(LMS_CH_1).
81  */
82  virtual void set_antenna(int antenna, int channel = 0) = 0;
83 
84  /**
85  * Set NCO (numerically controlled oscillator).
86  * By selecting NCO frequency
87  * configure NCO. When NCO frequency is 0, NCO is off.
88  *
89  * @param nco_freq NCO frequency in Hz.
90  *
91  * @param channel Channel index.
92  */
93  virtual void set_nco(float nco_freq, int channel) = 0;
94 
95  /**
96  * Set analog filters.
97  *
98  * @param analog_bandw Channel filter bandwidth in Hz.
99  *
100  * @param channel Channel selection: A(LMS_CH_0),B(LMS_CH_1).
101  *
102  * @return actual filter bandwidth in Hz
103  */
104  virtual double set_bandwidth(double analog_bandw, int channel = 0) = 0;
105 
106  /**
107  * Set digital filters (GFIR).
108  *
109  * @param digital_bandw Channel filter bandwidth in Hz.
110  *
111  * @param channel Channel selection: A(LMS_CH_0),B(LMS_CH_1).
112  */
113  virtual void set_digital_filter(double digital_bandw, int channel) = 0;
114 
115  /**
116  * Set the combined gain value in dB
117  *
118  * @note actual gain depends on LO frequency and analog LPF configuration and
119  * resulting output signal level may be different when those values are changed
120  *
121  * @param gain_dB Desired gain: [0,73] dB
122  *
123  * @param channel Channel selection: A(LMS_CH_0),B(LMS_CH_1).
124  *
125  * @return actual gain in dB
126  */
127  virtual unsigned set_gain(unsigned gain_dB, int channel = 0) = 0;
128 
129  /**
130  * Set the same sample rate for both channels.
131  *
132  * @param rate Sample rate in S/s.
133  *
134  * @return actual sample rate in S/s
135  */
136  virtual double set_sample_rate(double rate) = 0;
137 
138  /**
139  * Set oversampling for both channels.
140  *
141  * @param oversample Oversampling value (0 (default),1,2,4,8,16,32).
142  */
143  virtual void set_oversampling(int oversample) = 0;
144 
145  /**
146  * Perform device calibration.
147  *
148  * @param bandw Set calibration bandwidth in Hz.
149  *
150  * @param channel Channel selection: A(LMS_CH_0),B(LMS_CH_1).
151  */
152  virtual void calibrate(double bandw, int channel = 0) = 0;
153 
154  /**
155  * Set stream buffer size
156  *
157  * @param size FIFO buffer size in samples
158  */
159  virtual void set_buffer_size(uint32_t size) = 0;
160 
161  /**
162  * Set TCXO DAC.
163  * @note Care must be taken as this parameter is returned to default value only after
164  * power off.
165  * @note LimeSDR-Mini default value is 180 range is [0,255]
166  * LimeSDR-USB default value is 125 range is [0,255]
167  * LimeSDR-PCIe default value is 134 range is [0,255]
168  * LimeNET-Micro default value is 30714 range is [0,65535]
169  *
170  * @param dacVal DAC value (0-65535)
171  */
172  virtual void set_tcxo_dac(uint16_t dacVal = 125) = 0;
173 
174  /**
175  * Write LMS register
176  *
177  * Writes a parameter by calling LMS_WriteLMSReg()
178  *
179  * @param address Address
180  * @param val Value
181  */
182  virtual void write_lms_reg(uint32_t address, uint16_t val) = 0;
183 };
184 
185 } // namespace limesdr
186 } // namespace gr
187 
188 #endif /* INCLUDED_LIMESDR_SOURCE_H */
#define LIMESDR_API
Definition: api.h:31
<+description of block+>
Definition: source.h:36
virtual unsigned set_gain(unsigned gain_dB, int channel=0)=0
virtual void set_nco(float nco_freq, int channel)=0
virtual void set_digital_filter(double digital_bandw, int channel)=0
virtual void set_buffer_size(uint32_t size)=0
virtual void set_tcxo_dac(uint16_t dacVal=125)=0
virtual void calibrate(double bandw, int channel=0)=0
virtual double set_bandwidth(double analog_bandw, int channel=0)=0
boost::shared_ptr< source > sptr
Definition: source.h:38
virtual double set_center_freq(double freq, size_t chan=0)=0
virtual void write_lms_reg(uint32_t address, uint16_t val)=0
virtual void set_antenna(int antenna, int channel=0)=0
virtual double set_sample_rate(double rate)=0
static sptr make(std::string serial, int channel_mode, const std::string &filename, bool align_ch_phase)
Return a shared_ptr to a new instance of limesdr::source.
virtual void set_oversampling(int oversample)=0
Definition: rfe.h:29