mirror of https://gerrit.osmocom.org/libusrp
Clean up annoying class structure in wbx
This commit is contained in:
parent
0ba8eaa142
commit
87bbd984a5
|
@ -30,7 +30,7 @@ class adf4350;
|
||||||
class wbxng_base : public db_base
|
class wbxng_base : public db_base
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
wbxng_base(usrp_basic_sptr usrp, int which, int _power_on=0);
|
wbxng_base(usrp_basic_sptr usrp, int which);
|
||||||
~wbxng_base();
|
~wbxng_base();
|
||||||
|
|
||||||
struct freq_result_t set_freq(double freq);
|
struct freq_result_t set_freq(double freq);
|
||||||
|
@ -44,9 +44,6 @@ protected:
|
||||||
bool _lock_detect();
|
bool _lock_detect();
|
||||||
bool _set_pga(float pga_gain);
|
bool _set_pga(float pga_gain);
|
||||||
|
|
||||||
int power_on() { return d_power_on; }
|
|
||||||
int power_off() { return 0; }
|
|
||||||
|
|
||||||
bool d_first;
|
bool d_first;
|
||||||
int d_spi_format;
|
int d_spi_format;
|
||||||
int d_spi_enable;
|
int d_spi_enable;
|
||||||
|
@ -58,14 +55,14 @@ protected:
|
||||||
|
|
||||||
// ----------------------------------------------------------------
|
// ----------------------------------------------------------------
|
||||||
|
|
||||||
class wbxng_base_tx : public wbxng_base
|
class db_wbxng_tx : public wbxng_base
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
void shutdown();
|
void shutdown();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
wbxng_base_tx(usrp_basic_sptr usrp, int which, int _power_on=0);
|
db_wbxng_tx(usrp_basic_sptr usrp, int which);
|
||||||
~wbxng_base_tx();
|
~db_wbxng_tx();
|
||||||
|
|
||||||
float gain_min();
|
float gain_min();
|
||||||
float gain_max();
|
float gain_max();
|
||||||
|
@ -76,36 +73,20 @@ public:
|
||||||
bool set_gain(float gain);
|
bool set_gain(float gain);
|
||||||
};
|
};
|
||||||
|
|
||||||
class wbxng_base_rx : public wbxng_base
|
class db_wbxng_rx : public wbxng_base
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
void shutdown();
|
void shutdown();
|
||||||
bool _set_attn(float attn);
|
bool _set_attn(float attn);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
wbxng_base_rx(usrp_basic_sptr usrp, int which, int _power_on=0);
|
db_wbxng_rx(usrp_basic_sptr usrp, int which);
|
||||||
~wbxng_base_rx();
|
~db_wbxng_rx();
|
||||||
|
|
||||||
bool set_auto_tr(bool on);
|
bool set_auto_tr(bool on);
|
||||||
bool select_rx_antenna(int which_antenna);
|
bool select_rx_antenna(int which_antenna);
|
||||||
bool select_rx_antenna(const std::string &which_antenna);
|
bool select_rx_antenna(const std::string &which_antenna);
|
||||||
bool set_gain(float gain);
|
bool set_gain(float gain);
|
||||||
};
|
|
||||||
|
|
||||||
// ----------------------------------------------------------------
|
|
||||||
|
|
||||||
class db_wbxng_tx : public wbxng_base_tx
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
db_wbxng_tx(usrp_basic_sptr usrp, int which);
|
|
||||||
~db_wbxng_tx();
|
|
||||||
};
|
|
||||||
|
|
||||||
class db_wbxng_rx : public wbxng_base_rx
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
db_wbxng_rx(usrp_basic_sptr usrp, int which);
|
|
||||||
~db_wbxng_rx();
|
|
||||||
|
|
||||||
float gain_min();
|
float gain_min();
|
||||||
float gain_max();
|
float gain_max();
|
||||||
|
|
|
@ -46,8 +46,8 @@
|
||||||
#define ATTN_SHIFT 8
|
#define ATTN_SHIFT 8
|
||||||
#define ATTN_MASK (63 << ATTN_SHIFT)
|
#define ATTN_MASK (63 << ATTN_SHIFT)
|
||||||
|
|
||||||
wbxng_base::wbxng_base(usrp_basic_sptr _usrp, int which, int _power_on)
|
wbxng_base::wbxng_base(usrp_basic_sptr _usrp, int which)
|
||||||
: db_base(_usrp, which), d_power_on(_power_on)
|
: db_base(_usrp, which)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
@param usrp: instance of usrp.source_c
|
@param usrp: instance of usrp.source_c
|
||||||
|
@ -152,8 +152,8 @@ wbxng_base::freq_max()
|
||||||
|
|
||||||
// ----------------------------------------------------------------
|
// ----------------------------------------------------------------
|
||||||
|
|
||||||
wbxng_base_tx::wbxng_base_tx(usrp_basic_sptr _usrp, int which, int _power_on)
|
db_wbxng_tx::db_wbxng_tx(usrp_basic_sptr _usrp, int which)
|
||||||
: wbxng_base(_usrp, which, _power_on)
|
: wbxng_base(_usrp, which)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
@param usrp: instance of usrp.sink_c
|
@param usrp: instance of usrp.sink_c
|
||||||
|
@ -171,7 +171,7 @@ wbxng_base_tx::wbxng_base_tx(usrp_basic_sptr _usrp, int which, int _power_on)
|
||||||
|
|
||||||
// power up the transmit side, but don't enable the mixer
|
// power up the transmit side, but don't enable the mixer
|
||||||
usrp()->_write_oe(d_which,(RX_TXN|TXMOD_EN|ENABLE_33|ENABLE_5), (RX_TXN|TXMOD_EN|ENABLE_33|ENABLE_5));
|
usrp()->_write_oe(d_which,(RX_TXN|TXMOD_EN|ENABLE_33|ENABLE_5), (RX_TXN|TXMOD_EN|ENABLE_33|ENABLE_5));
|
||||||
usrp()->write_io(d_which, (power_on()|RX_TXN|ENABLE_33|ENABLE_5), (RX_TXN|ENABLE_33|ENABLE_5));
|
usrp()->write_io(d_which, (RX_TXN|ENABLE_33|ENABLE_5), (RX_TXN|ENABLE_33|ENABLE_5));
|
||||||
//set_lo_offset(4e6);
|
//set_lo_offset(4e6);
|
||||||
|
|
||||||
// Disable VCO/PLL
|
// Disable VCO/PLL
|
||||||
|
@ -180,16 +180,16 @@ wbxng_base_tx::wbxng_base_tx(usrp_basic_sptr _usrp, int which, int _power_on)
|
||||||
set_gain((gain_min() + gain_max()) / 2.0); // initialize gain
|
set_gain((gain_min() + gain_max()) / 2.0); // initialize gain
|
||||||
}
|
}
|
||||||
|
|
||||||
wbxng_base_tx::~wbxng_base_tx()
|
db_wbxng_tx::~db_wbxng_tx()
|
||||||
{
|
{
|
||||||
shutdown();
|
shutdown();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
wbxng_base_tx::shutdown()
|
db_wbxng_tx::shutdown()
|
||||||
{
|
{
|
||||||
// fprintf(stderr, "wbxng_base_tx::shutdown d_is_shutdown = %d\n", d_is_shutdown);
|
// fprintf(stderr, "db_wbxng_tx::shutdown d_is_shutdown = %d\n", d_is_shutdown);
|
||||||
|
|
||||||
if (!d_is_shutdown){
|
if (!d_is_shutdown){
|
||||||
d_is_shutdown = true;
|
d_is_shutdown = true;
|
||||||
|
@ -199,7 +199,7 @@ wbxng_base_tx::shutdown()
|
||||||
d_common->_enable(false);
|
d_common->_enable(false);
|
||||||
|
|
||||||
// Power down and leave the T/R switch in the R position
|
// Power down and leave the T/R switch in the R position
|
||||||
usrp()->write_io(d_which, (power_off()|RX_TXN), (RX_TXN|ENABLE_33|ENABLE_5));
|
usrp()->write_io(d_which, (RX_TXN), (RX_TXN|ENABLE_33|ENABLE_5));
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -211,7 +211,7 @@ wbxng_base_tx::shutdown()
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
wbxng_base_tx::set_auto_tr(bool on)
|
db_wbxng_tx::set_auto_tr(bool on)
|
||||||
{
|
{
|
||||||
bool ok = true;
|
bool ok = true;
|
||||||
if(on) {
|
if(on) {
|
||||||
|
@ -228,7 +228,7 @@ wbxng_base_tx::set_auto_tr(bool on)
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
wbxng_base_tx::set_enable(bool on)
|
db_wbxng_tx::set_enable(bool on)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
Enable transmitter if on is true
|
Enable transmitter if on is true
|
||||||
|
@ -250,25 +250,25 @@ wbxng_base_tx::set_enable(bool on)
|
||||||
}
|
}
|
||||||
|
|
||||||
float
|
float
|
||||||
wbxng_base_tx::gain_min()
|
db_wbxng_tx::gain_min()
|
||||||
{
|
{
|
||||||
return 0.0;
|
return 0.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
float
|
float
|
||||||
wbxng_base_tx::gain_max()
|
db_wbxng_tx::gain_max()
|
||||||
{
|
{
|
||||||
return 25.0;
|
return 25.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
float
|
float
|
||||||
wbxng_base_tx::gain_db_per_step()
|
db_wbxng_tx::gain_db_per_step()
|
||||||
{
|
{
|
||||||
return gain_max()/(1+(1.4-0.5)*4096/3.3);
|
return gain_max()/(1+(1.4-0.5)*4096/3.3);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
wbxng_base_tx::set_gain(float gain)
|
db_wbxng_tx::set_gain(float gain)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
Set the gain.
|
Set the gain.
|
||||||
|
@ -305,8 +305,8 @@ wbxng_base_tx::set_gain(float gain)
|
||||||
/**************************************************************************/
|
/**************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
wbxng_base_rx::wbxng_base_rx(usrp_basic_sptr _usrp, int which, int _power_on)
|
db_wbxng_rx::db_wbxng_rx(usrp_basic_sptr _usrp, int which)
|
||||||
: wbxng_base(_usrp, which, _power_on)
|
: wbxng_base(_usrp, which)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
@param usrp: instance of usrp.source_c
|
@param usrp: instance of usrp.source_c
|
||||||
|
@ -326,7 +326,7 @@ wbxng_base_rx::wbxng_base_rx(usrp_basic_sptr _usrp, int which, int _power_on)
|
||||||
d_common->_enable(true);
|
d_common->_enable(true);
|
||||||
|
|
||||||
usrp()->_write_oe(d_which, (RX2_RX1N|RXBB_EN|ATTN_MASK|ENABLE_33|ENABLE_5), (RX2_RX1N|RXBB_EN|ATTN_MASK|ENABLE_33|ENABLE_5));
|
usrp()->_write_oe(d_which, (RX2_RX1N|RXBB_EN|ATTN_MASK|ENABLE_33|ENABLE_5), (RX2_RX1N|RXBB_EN|ATTN_MASK|ENABLE_33|ENABLE_5));
|
||||||
usrp()->write_io(d_which, (power_on()|RX2_RX1N|RXBB_EN|ENABLE_33|ENABLE_5), (RX2_RX1N|RXBB_EN|ATTN_MASK|ENABLE_33|ENABLE_5));
|
usrp()->write_io(d_which, (RX2_RX1N|RXBB_EN|ENABLE_33|ENABLE_5), (RX2_RX1N|RXBB_EN|ATTN_MASK|ENABLE_33|ENABLE_5));
|
||||||
//fprintf(stderr,"Setting WBXNG RXBB on");
|
//fprintf(stderr,"Setting WBXNG RXBB on");
|
||||||
|
|
||||||
// set up for RX on TX/RX port
|
// set up for RX on TX/RX port
|
||||||
|
@ -337,17 +337,19 @@ wbxng_base_rx::wbxng_base_rx(usrp_basic_sptr _usrp, int which, int _power_on)
|
||||||
/*
|
/*
|
||||||
set_lo_offset(-4e6);
|
set_lo_offset(-4e6);
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
set_gain((gain_min() + gain_max()) / 2.0); // initialize gain
|
||||||
}
|
}
|
||||||
|
|
||||||
wbxng_base_rx::~wbxng_base_rx()
|
db_wbxng_rx::~db_wbxng_rx()
|
||||||
{
|
{
|
||||||
shutdown();
|
shutdown();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
wbxng_base_rx::shutdown()
|
db_wbxng_rx::shutdown()
|
||||||
{
|
{
|
||||||
// fprintf(stderr, "wbxng_base_rx::shutdown d_is_shutdown = %d\n", d_is_shutdown);
|
// fprintf(stderr, "db_wbxng_rx::shutdown d_is_shutdown = %d\n", d_is_shutdown);
|
||||||
|
|
||||||
if (!d_is_shutdown){
|
if (!d_is_shutdown){
|
||||||
d_is_shutdown = true;
|
d_is_shutdown = true;
|
||||||
|
@ -356,24 +358,24 @@ wbxng_base_rx::shutdown()
|
||||||
// Power down VCO/PLL
|
// Power down VCO/PLL
|
||||||
d_common->_enable(false);
|
d_common->_enable(false);
|
||||||
|
|
||||||
// fprintf(stderr, "wbxng_base_rx::shutdown before _write_control\n");
|
// fprintf(stderr, "db_wbxng_rx::shutdown before _write_control\n");
|
||||||
//_write_control(_compute_control_reg());
|
//_write_control(_compute_control_reg());
|
||||||
|
|
||||||
// fprintf(stderr, "wbxng_base_rx::shutdown before _enable_refclk\n");
|
// fprintf(stderr, "db_wbxng_rx::shutdown before _enable_refclk\n");
|
||||||
_enable_refclk(false); // turn off refclk
|
_enable_refclk(false); // turn off refclk
|
||||||
|
|
||||||
// fprintf(stderr, "wbxng_base_rx::shutdown before set_auto_tr\n");
|
// fprintf(stderr, "db_wbxng_rx::shutdown before set_auto_tr\n");
|
||||||
set_auto_tr(false);
|
set_auto_tr(false);
|
||||||
|
|
||||||
// Power down
|
// Power down
|
||||||
usrp()->write_io(d_which, power_off(), (RX2_RX1N|RXBB_EN|ATTN_MASK|ENABLE_33|ENABLE_5));
|
usrp()->write_io(d_which, 0, (RX2_RX1N|RXBB_EN|ATTN_MASK|ENABLE_33|ENABLE_5));
|
||||||
|
|
||||||
// fprintf(stderr, "wbxng_base_rx::shutdown after set_auto_tr\n");
|
// fprintf(stderr, "db_wbxng_rx::shutdown after set_auto_tr\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
wbxng_base_rx::set_auto_tr(bool on)
|
db_wbxng_rx::set_auto_tr(bool on)
|
||||||
{
|
{
|
||||||
bool ok = true;
|
bool ok = true;
|
||||||
if(on) {
|
if(on) {
|
||||||
|
@ -390,7 +392,7 @@ wbxng_base_rx::set_auto_tr(bool on)
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
wbxng_base_rx::select_rx_antenna(int which_antenna)
|
db_wbxng_rx::select_rx_antenna(int which_antenna)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
Specify which antenna port to use for reception.
|
Specify which antenna port to use for reception.
|
||||||
|
@ -410,7 +412,7 @@ wbxng_base_rx::select_rx_antenna(int which_antenna)
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
wbxng_base_rx::select_rx_antenna(const std::string &which_antenna)
|
db_wbxng_rx::select_rx_antenna(const std::string &which_antenna)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
Specify which antenna port to use for reception.
|
Specify which antenna port to use for reception.
|
||||||
|
@ -432,7 +434,7 @@ wbxng_base_rx::select_rx_antenna(const std::string &which_antenna)
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
wbxng_base_rx::set_gain(float gain)
|
db_wbxng_rx::set_gain(float gain)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
Set the gain.
|
Set the gain.
|
||||||
|
@ -462,7 +464,7 @@ wbxng_base_rx::set_gain(float gain)
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
wbxng_base_rx::_set_attn(float attn)
|
db_wbxng_rx::_set_attn(float attn)
|
||||||
{
|
{
|
||||||
int attn_code = int(floor(attn/0.5));
|
int attn_code = int(floor(attn/0.5));
|
||||||
unsigned int iobits = (~attn_code) << ATTN_SHIFT;
|
unsigned int iobits = (~attn_code) << ATTN_SHIFT;
|
||||||
|
@ -470,27 +472,6 @@ wbxng_base_rx::_set_attn(float attn)
|
||||||
return usrp()->write_io(d_which, iobits, ATTN_MASK);
|
return usrp()->write_io(d_which, iobits, ATTN_MASK);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------
|
|
||||||
|
|
||||||
db_wbxng_tx::db_wbxng_tx(usrp_basic_sptr usrp, int which)
|
|
||||||
: wbxng_base_tx(usrp, which)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
db_wbxng_tx::~db_wbxng_tx()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
db_wbxng_rx::db_wbxng_rx(usrp_basic_sptr usrp, int which)
|
|
||||||
: wbxng_base_rx(usrp, which)
|
|
||||||
{
|
|
||||||
set_gain((gain_min() + gain_max()) / 2.0); // initialize gain
|
|
||||||
}
|
|
||||||
|
|
||||||
db_wbxng_rx::~db_wbxng_rx()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
float
|
float
|
||||||
db_wbxng_rx::gain_min()
|
db_wbxng_rx::gain_min()
|
||||||
{
|
{
|
||||||
|
@ -509,7 +490,6 @@ db_wbxng_rx::gain_db_per_step()
|
||||||
return 0.05;
|
return 0.05;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
db_wbxng_rx::i_and_q_swapped()
|
db_wbxng_rx::i_and_q_swapped()
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue