GNU Radio's LIMESDR Package
rfe.h
Go to the documentation of this file.
1 /* -*- c++ -*- */
2 /*
3  * Copyright 2020 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_LIMERFE_H
22 #define INCLUDED_LIMERFE_H
23 
24 #include <limeRFE.h>
25 #include <limesdr/api.h>
26 #include <iostream>
27 #include <string>
28 
29 namespace gr {
30 namespace limesdr {
31 
32 /*!
33  * \brief GNURadio block to control LimeRFE boards
34  * \ingroup limesdr
35  *
36  */
38 {
39 public:
40  rfe(int comm_type,
41  std::string device,
42  std::string config_file,
43  char IDRX,
44  char IDTX,
45  char PortRX,
46  char PortTX,
47  char Mode,
48  char Notch,
49  char Atten);
50  ~rfe();
51  /**
52  * Change LimeRFE Mode
53  *
54  * @param mode Mode to be set: RX(0), TX(1), NONE(2), TXRX(3)
55  *
56  * @return 0 on success, other on failure (see LimeRFE error codes)
57  */
58  int change_mode(int mode);
59  /**
60  * Enable or disbale fan
61  *
62  * @param enable fan state: 0 - disable; 1 - enable.
63  *
64  * @return 0 on success, other on failure (see LimeRFE error codes)
65  */
66  int set_fan(int enable);
67  /**
68  * Set RX Attenuation value
69  *
70  * @param attenuation Specifies the attenuation in the RX path. Attenuation [dB] =
71  * 2 * attenuation. Value range: [0,7]
72  *
73  * @return 0 on success, other on failure (see LimeRFE error codes)
74  */
75  int set_attenuation(int attenuation);
76  /**
77  * Enable or disable AM/FM notch filter
78  *
79  * @param enable notch state: 0 - disable; 1 - enable
80  *
81  * @note Notch filter is only possible up to HAM 430-440 MHz, or Wideband 1-1000 MHz
82  * @return 0 on success, other on failure (see LimeRFE error codes)
83  */
84  int set_notch(int enable);
85 
86 private:
87  rfe_dev_t* rfe_dev = nullptr;
88  rfe_boardState boardState = { RFE_CID_WB_1000,
89  RFE_CID_WB_1000,
90  RFE_PORT_1,
91  RFE_PORT_1,
92  RFE_MODE_NONE,
93  RFE_NOTCH_OFF,
94  0,
95  0,
96  0 };
97  int sdr_device_num = 0;
98 
99  void print_error(int error);
100 
101  void get_board_state()
102  {
103  rfe_boardState currentState = { 0 };
104  if (RFE_GetState(rfe_dev, &currentState) != 0) {
105  std::cout << "LimeRFE: failed to get board state" << std::endl;
106  return;
107  }
108 
109  std::cout << "LimeRFE: RX channel: " << (int)currentState.channelIDRX << std::endl;
110  std::cout << "LimeRFE: TX channel: " << (int)currentState.channelIDTX << std::endl;
111  std::cout << "LimeRFE: PortRX: " << (int)currentState.selPortRX << std::endl;
112  std::cout << "LimeRFE: PortTx: " << (int)currentState.selPortTX << std::endl;
113  std::cout << "LimeRFE: Mode: " << (int)currentState.mode << std::endl;
114  std::cout << "LimeRFE: Notch: " << (int)currentState.notchOnOff << std::endl;
115  std::cout << "LimeRFE: Attenuation: " << (int)currentState.attValue << std::endl;
116  std::cout << "LimeRFE: Enable SWR: " << (int)currentState.enableSWR << std::endl;
117  std::cout << "LimeRFE: SourceSWR: " << (int)currentState.sourceSWR << std::endl;
118  }
119 };
120 
121 } // namespace limesdr
122 } // namespace gr
123 
124 #endif /* INCLUDED_LIMERFE_H */
#define LIMESDR_API
Definition: api.h:31
GNURadio block to control LimeRFE boards.
Definition: rfe.h:38
int set_attenuation(int attenuation)
int set_fan(int enable)
rfe(int comm_type, std::string device, std::string config_file, char IDRX, char IDTX, char PortRX, char PortTX, char Mode, char Notch, char Atten)
int set_notch(int enable)
int change_mode(int mode)
Definition: rfe.h:29