Skip to content

Instantly share code, notes, and snippets.

@csete
Last active December 14, 2015 01:48
Show Gist options
  • Save csete/5008658 to your computer and use it in GitHub Desktop.
Save csete/5008658 to your computer and use it in GitHub Desktop.
/** 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_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;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment