public
Last active

  • Download Gist
iq_swap.cpp
C++
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
/** I/Q swap **/
iq_swap_cc_sptr make_iq_swap_cc(bool enabled)
{
return gnuradio::get_initial_sptr(new iq_swap_cc(enabled));
}
 
iq_swap_cc::iq_swap_cc(bool enabled)
: gr_hier_block2 ("iq_swap_cc",
gr_make_io_signature(1, 1, sizeof(gr_complex)),
gr_make_io_signature(1, 1, sizeof(gr_complex)))
{
d_c2f = gr_make_complex_to_float();
d_f2c = gr_make_float_to_complex();
 
connect(self(), 0, d_c2f, 0);
if (enabled)
{
connect(d_c2f, 0, d_f2c, 1);
connect(d_c2f, 1, d_f2c, 0);
}
else
{
connect(d_c2f, 0, d_f2c, 0);
connect(d_c2f, 1, d_f2c, 1);
}
connect(d_f2c, 0, self(), 0);
}
 
iq_swap_cc::~iq_swap_cc()
{
 
}
 
/*! \brief Enabled or disable I/Q swapping. */
void iq_swap_cc::set_enabled(bool enabled)
{
#ifndef QT_NO_DEBUG_OUTPUT
std::cout << "IQ swap: " << enabled << std::endl;
#endif
 
lock();
disconnect_all();
connect(self(), 0, d_c2f, 0);
if (enabled)
{
connect(d_c2f, 0, d_f2c, 1);
connect(d_c2f, 1, d_f2c, 0);
}
else
{
connect(d_c2f, 0, d_f2c, 0);
connect(d_c2f, 1, d_f2c, 1);
}
connect(d_f2c, 0, self(), 0);
unlock();
}
iq_swap.h
C++
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
iq_swap_cc_sptr make_iq_swap_cc(bool enabled);
 
/*! \brief Block to swap I and Q channels.
* \ingroup DSP
*/
class iq_swap_cc : public gr_hier_block2
{
friend iq_swap_cc_sptr make_iq_swap_cc(bool enabled);
 
protected:
iq_swap_cc(bool enabled);
 
public:
~iq_swap_cc();
void set_enabled(bool enabled);
 
private:
gr_complex_to_float_sptr d_c2f;
gr_float_to_complex_sptr d_f2c;
};

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.