1 // 2 // Copyright 2016 Ettus Research LLC 3 // Copyright 2018 Ettus Research, a National Instruments Company 4 // 5 // SPDX-License-Identifier: GPL-3.0-or-later 6 // 7 8 #pragma once 9 10 #include <uhd/config.hpp> 11 #include <boost/operators.hpp> 12 #include <string> 13 14 namespace uhd { namespace usrp { 15 16 class UHD_API fe_connection_t : boost::equality_comparable<fe_connection_t> 17 { 18 public: 19 /** Sampling mode. 20 * Represents the sampling architecture for the front-end 21 */ 22 enum sampling_t { 23 QUADRATURE, /**< Complex sampling (Complex input, Complex output). */ 24 HETERODYNE, /**< Heterodyne sampling (Real input, Complex output). Only one of the 25 I and Q inputs is used. */ 26 REAL /**< Real sampling (Real input, Real output). Only one of the I and Q inputs 27 is used. */ 28 }; 29 30 /*! 31 * Create a frontend connection class from individual settings. 32 * \param sampling_mode can be { QUADRATURE, HETERODYNE, REAL } 33 * \param iq_swapped indicates if the IQ channels are swapped (after inverion and 34 * heterodyne correction) \param i_inverted indicates if the I channel is inverted 35 * (negated) \param q_inverted indicates if the Q channel is inverted (negated) \param 36 * if_freq the baseband sampling frequency. 37 */ 38 fe_connection_t(sampling_t sampling_mode, 39 bool iq_swapped, 40 bool i_inverted, 41 bool q_inverted, 42 double if_freq = 0.0); 43 44 /*! 45 * Create a frontend connection class from a connection string 46 * The connection string can be: 47 * - in {I, Q}: Real mode sampling with no inversion. 48 * - in {Ib, Qb}: Real mode sampling with inversion. 49 * - in {IQ, QI}: Quadrature sampling with no inversion. 50 * - in {IbQb, QbIb}: Quadrature sampling with inversion. 51 * - in {II, QQ}: Heterodyne sampling with no inversion. 52 * - in {IbIb, QbQb}: Heterodyne sampling with inversion. 53 * 54 * \param conn_str the connection string. 55 * \param if_freq the baseband sampling frequency. 56 */ 57 fe_connection_t(const std::string& conn_str, double if_freq = 0.0); 58 59 /*! 60 * Accessor for sampling mode 61 */ get_sampling_mode() const62 inline sampling_t get_sampling_mode() const 63 { 64 return _sampling_mode; 65 } 66 67 /*! 68 * Accessor for IQ swap parameter 69 */ is_iq_swapped() const70 inline bool is_iq_swapped() const 71 { 72 return _iq_swapped; 73 } 74 75 /*! 76 * Accessor for I inversion parameter 77 */ is_i_inverted() const78 inline bool is_i_inverted() const 79 { 80 return _i_inverted; 81 } 82 83 /*! 84 * Accessor for Q inversion parameter 85 */ is_q_inverted() const86 inline bool is_q_inverted() const 87 { 88 return _q_inverted; 89 } 90 91 /*! 92 * Accessor for IF frequency 93 */ get_if_freq() const94 inline double get_if_freq() const 95 { 96 return _if_freq; 97 } 98 99 /*! 100 * Mutator for IF frequency 101 */ set_if_freq(double freq)102 inline void set_if_freq(double freq) 103 { 104 _if_freq = freq; 105 } 106 107 private: 108 sampling_t _sampling_mode; 109 bool _iq_swapped; 110 bool _i_inverted; 111 bool _q_inverted; 112 double _if_freq; 113 }; 114 115 /*! 116 * Comparator operator overloaded for fe_connection_t. 117 * The boost::equality_comparable provides the !=. 118 * \param lhs the fe_connection_t to the left of the operator 119 * \param rhs the fe_connection_t to the right of the operator 120 * \return true when the fe connections are equal 121 */ 122 UHD_API bool operator==(const fe_connection_t& lhs, const fe_connection_t& rhs); 123 124 }} // namespace uhd::usrp 125