[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] r9260 - gnuradio/branches/developers/trondeau/dbs/usrp
From: |
trondeau |
Subject: |
[Commit-gnuradio] r9260 - gnuradio/branches/developers/trondeau/dbs/usrp/host/lib/legacy |
Date: |
Tue, 12 Aug 2008 16:02:48 -0600 (MDT) |
Author: trondeau
Date: 2008-08-12 16:02:48 -0600 (Tue, 12 Aug 2008)
New Revision: 9260
Modified:
gnuradio/branches/developers/trondeau/dbs/usrp/host/lib/legacy/db_flexrf.cc
gnuradio/branches/developers/trondeau/dbs/usrp/host/lib/legacy/db_flexrf.h
Log:
moving d_common into base class and cleaning up redundant code. Fixes a few
problems with closing down the USRPs.
Modified:
gnuradio/branches/developers/trondeau/dbs/usrp/host/lib/legacy/db_flexrf.cc
===================================================================
--- gnuradio/branches/developers/trondeau/dbs/usrp/host/lib/legacy/db_flexrf.cc
2008-08-12 21:09:18 UTC (rev 9259)
+++ gnuradio/branches/developers/trondeau/dbs/usrp/host/lib/legacy/db_flexrf.cc
2008-08-12 22:02:48 UTC (rev 9260)
@@ -58,14 +58,11 @@
flexrf_base::~flexrf_base()
{
- d_usrp->write_io(d_which, power_off(), POWER_UP); // turn off power to
board
+ // turn off power to board
+ d_usrp->common_write_io((d_tx ? C_TX : C_RX),
+ d_which, power_off(), POWER_UP);
- // Power down VCO/PLL
- d_PD = 3;
-
- _write_control(_compute_control_reg());
- _enable_refclk(false); // turn off refclk
- set_auto_tr(false);
+ delete d_common;
}
void
@@ -154,7 +151,8 @@
}
bool
-flexrf_base::_compute_regs(float freq, int &retR, int &retcontrol, int &retN,
float &retfreq)
+flexrf_base::_compute_regs(float freq, int &retR, int &retcontrol,
+ int &retN, float &retfreq)
{
/*
Determine values of R, control, and N registers, along with actual freq.
@@ -174,9 +172,15 @@
int
flexrf_base::_compute_control_reg()
{
- throw std::runtime_error("_compute_control_regs called from flexrf_base\n");
+ return d_common->_compute_control_reg();
}
+int
+flexrf_base::_refclk_divisor()
+{
+ return d_common->_refclk_divisor();
+}
+
float
flexrf_base::_refclk_freq()
{
@@ -322,6 +326,13 @@
{
// Power down and leave the T/R switch in the R position
d_usrp->write_io(d_which, (power_off()|RX_TXN), (POWER_UP|RX_TXN|ENABLE));
+
+ // Power down VCO/PLL
+ d_PD = 3;
+
+ _write_control(_compute_control_reg());
+ _enable_refclk(false); // turn off refclk
+ set_auto_tr(false);
}
void
@@ -388,7 +399,7 @@
}
-/******************************************************************************/
+/**************************************************************************/
flexrf_base_rx::flexrf_base_rx(usrp_basic *usrp, int which, int _power_on)
@@ -410,8 +421,8 @@
}
d_usrp->_write_oe(d_which, (POWER_UP|RX2_RX1N|ENABLE), 0xffff);
- d_usrp->write_io(d_which, (power_on()|RX2_RX1N|ENABLE),
(POWER_UP|RX2_RX1N|ENABLE));
- //d_usrp->write_io(d_which, (POWER_UP|RX2_RX1N|ENABLE),
(POWER_UP|RX2_RX1N|ENABLE));
+ d_usrp->write_io(d_which, (power_on()|RX2_RX1N|ENABLE),
+ (POWER_UP|RX2_RX1N|ENABLE));
// set up for RX on TX/RX port
select_rx_antenna("TX/RX");
@@ -424,7 +435,14 @@
flexrf_base_rx::~flexrf_base_rx()
{
// Power down
- d_usrp->write_io(d_which, power_off(), (POWER_UP|ENABLE));
+ d_usrp->common_write_io(C_RX, d_which, power_off(), (POWER_UP|ENABLE));
+
+ // Power down VCO/PLL
+ d_PD = 3;
+
+ _write_control(_compute_control_reg());
+ _enable_refclk(false); // turn off refclk
+ set_auto_tr(false);
}
@@ -514,7 +532,8 @@
assert(dac_value>=0 && dac_value<4096);
- return (d_usrp->write_aux_dac(d_which, 0, int(dac_value)) &&
_set_pga(int(pga_gain)));
+ return (d_usrp->write_aux_dac(d_which, 0, int(dac_value))
+ && _set_pga(int(pga_gain)));
}
// ----------------------------------------------------------------
@@ -599,9 +618,9 @@
int
_AD4360_common::_compute_control_reg()
{
- int control = (d_P<<22) | (d_PD<<20) | (d_CP2<<17) | (d_CP1<<14) | (d_PL<<12)
- | (d_MTLD<<11) | (d_CPG<<10) | (d_CP3S<<9) | (d_PDP<<8) |
- (d_MUXOUT<<5) | (d_CR<<4) | (d_PC<<2);
+ int control = (d_P<<22) | (d_PD<<20) | (d_CP2<<17) | (d_CP1<<14)
+ | (d_PL<<12) | (d_MTLD<<11) | (d_CPG<<10) | (d_CP3S<<9) | (d_PDP<<8)
+ | (d_MUXOUT<<5) | (d_CR<<4) | (d_PC<<2);
return control;
}
@@ -817,7 +836,6 @@
db_flexrf_2400_tx::~db_flexrf_2400_tx()
{
- delete d_common;
}
float
@@ -833,9 +851,11 @@
}
bool
-db_flexrf_2400_tx::_compute_regs(float freq, int &retR, int &retcontrol, int
&retN, float &retfreq)
+db_flexrf_2400_tx::_compute_regs(float freq, int &retR, int &retcontrol,
+ int &retN, float &retfreq)
{
- return d_common->_compute_regs(_refclk_freq(), freq, retR, retcontrol, retN,
retfreq);
+ return d_common->_compute_regs(_refclk_freq(), freq, retR,
+ retcontrol, retN, retfreq);
}
@@ -848,7 +868,6 @@
db_flexrf_2400_rx::~db_flexrf_2400_rx()
{
- delete d_common;
}
float
@@ -889,24 +908,13 @@
}
bool
-db_flexrf_2400_rx::_compute_regs(float freq, int &retR, int &retcontrol, int
&retN, float &retfreq)
+db_flexrf_2400_rx::_compute_regs(float freq, int &retR, int &retcontrol,
+ int &retN, float &retfreq)
{
- return d_common->_compute_regs(_refclk_freq(), freq, retR, retcontrol, retN,
retfreq);
+ return d_common->_compute_regs(_refclk_freq(), freq, retR,
+ retcontrol, retN, retfreq);
}
-int
-db_flexrf_2400_rx::_compute_control_reg()
-{
- return d_common->_compute_control_reg();
-}
-
-int
-db_flexrf_2400_rx::_refclk_divisor()
-{
- return d_common->_refclk_divisor();
-}
-
-
//------------------------------------------------------------
@@ -918,7 +926,6 @@
db_flexrf_1200_tx::~db_flexrf_1200_tx()
{
- delete d_common;
}
float
@@ -934,9 +941,11 @@
}
bool
-db_flexrf_1200_tx::_compute_regs(float freq, int &retR, int &retcontrol, int
&retN, float &retfreq)
+db_flexrf_1200_tx::_compute_regs(float freq, int &retR, int &retcontrol,
+ int &retN, float &retfreq)
{
- return d_common->_compute_regs(_refclk_freq(), freq, retR, retcontrol, retN,
retfreq);
+ return d_common->_compute_regs(_refclk_freq(), freq, retR,
+ retcontrol, retN, retfreq);
}
@@ -950,7 +959,6 @@
db_flexrf_1200_rx::~db_flexrf_1200_rx()
{
- delete d_common;
}
float
@@ -990,24 +998,14 @@
}
bool
-db_flexrf_1200_rx::_compute_regs(float freq, int &retR, int &retcontrol, int
&retN, float &retfreq)
+db_flexrf_1200_rx::_compute_regs(float freq, int &retR, int &retcontrol,
+ int &retN, float &retfreq)
{
- return d_common->_compute_regs(_refclk_freq(), freq, retR, retcontrol, retN,
retfreq);
+ return d_common->_compute_regs(_refclk_freq(), freq, retR,
+ retcontrol, retN, retfreq);
}
-int
-db_flexrf_1200_rx::_compute_control_reg()
-{
- return d_common->_compute_control_reg();
-}
-int
-db_flexrf_1200_rx::_refclk_divisor()
-{
- return d_common->_refclk_divisor();
-}
-
-
//------------------------------------------------------------
@@ -1019,7 +1017,6 @@
db_flexrf_1800_tx::~db_flexrf_1800_tx()
{
- delete d_common;
}
float
@@ -1035,9 +1032,11 @@
}
bool
-db_flexrf_1800_tx::_compute_regs(float freq, int &retR, int &retcontrol, int
&retN, float &retfreq)
+db_flexrf_1800_tx::_compute_regs(float freq, int &retR, int &retcontrol,
+ int &retN, float &retfreq)
{
- return d_common->_compute_regs(_refclk_freq(), freq, retR, retcontrol, retN,
retfreq);
+ return d_common->_compute_regs(_refclk_freq(), freq, retR,
+ retcontrol, retN, retfreq);
}
@@ -1050,7 +1049,6 @@
db_flexrf_1800_rx::~db_flexrf_1800_rx()
{
- delete d_common;
}
@@ -1091,24 +1089,14 @@
}
bool
-db_flexrf_1800_rx::_compute_regs(float freq, int &retR, int &retcontrol, int
&retN, float &retfreq)
+db_flexrf_1800_rx::_compute_regs(float freq, int &retR, int &retcontrol,
+ int &retN, float &retfreq)
{
- return d_common->_compute_regs(_refclk_freq(), freq, retR, retcontrol, retN,
retfreq);
+ return d_common->_compute_regs(_refclk_freq(), freq, retR,
+ retcontrol, retN, retfreq);
}
-int
-db_flexrf_1800_rx::_compute_control_reg()
-{
- return d_common->_compute_control_reg();
-}
-int
-db_flexrf_1800_rx::_refclk_divisor()
-{
- return d_common->_refclk_divisor();
-}
-
-
//------------------------------------------------------------
@@ -1120,7 +1108,6 @@
db_flexrf_900_tx::~db_flexrf_900_tx()
{
- delete d_common;
}
float
@@ -1136,9 +1123,11 @@
}
bool
-db_flexrf_900_tx::_compute_regs(float freq, int &retR, int &retcontrol, int
&retN, float &retfreq)
+db_flexrf_900_tx::_compute_regs(float freq, int &retR, int &retcontrol,
+ int &retN, float &retfreq)
{
- return d_common->_compute_regs(_refclk_freq(), freq, retR, retcontrol, retN,
retfreq);
+ return d_common->_compute_regs(_refclk_freq(), freq, retR,
+ retcontrol, retN, retfreq);
}
@@ -1150,7 +1139,6 @@
db_flexrf_900_rx::~db_flexrf_900_rx()
{
- delete d_common;
}
float
@@ -1190,24 +1178,13 @@
}
bool
-db_flexrf_900_rx::_compute_regs(float freq, int &retR, int &retcontrol, int
&retN, float &retfreq)
+db_flexrf_900_rx::_compute_regs(float freq, int &retR, int &retcontrol,
+ int &retN, float &retfreq)
{
- return d_common->_compute_regs(_refclk_freq(), freq, retR, retcontrol, retN,
retfreq);
+ return d_common->_compute_regs(_refclk_freq(), freq, retR,
+ retcontrol, retN, retfreq);
}
-int
-db_flexrf_900_rx::_compute_control_reg()
-{
- return d_common->_compute_control_reg();
-}
-
-int
-db_flexrf_900_rx::_refclk_divisor()
-{
- return d_common->_refclk_divisor();
-}
-
-
//------------------------------------------------------------
@@ -1219,7 +1196,6 @@
db_flexrf_400_tx::~db_flexrf_400_tx()
{
- delete d_common;
}
float
@@ -1235,9 +1211,11 @@
}
bool
-db_flexrf_400_tx::_compute_regs(float freq, int &retR, int &retcontrol, int
&retN, float &retfreq)
+db_flexrf_400_tx::_compute_regs(float freq, int &retR, int &retcontrol,
+ int &retN, float &retfreq)
{
- return d_common->_compute_regs(_refclk_freq(), freq, retR, retcontrol, retN,
retfreq);
+ return d_common->_compute_regs(_refclk_freq(), freq, retR,
+ retcontrol, retN, retfreq);
}
@@ -1250,7 +1228,6 @@
db_flexrf_400_rx::~db_flexrf_400_rx()
{
- delete d_common;
}
float
@@ -1292,19 +1269,10 @@
}
bool
-db_flexrf_400_rx::_compute_regs(float freq, int &retR, int &retcontrol, int
&retN, float &retfreq)
+db_flexrf_400_rx::_compute_regs(float freq, int &retR, int &retcontrol,
+ int &retN, float &retfreq)
{
- return d_common->_compute_regs(_refclk_freq(), freq, retR, retcontrol, retN,
retfreq);
+ return d_common->_compute_regs(_refclk_freq(), freq, retR,
+ retcontrol, retN, retfreq);
}
-int
-db_flexrf_400_rx::_compute_control_reg()
-{
- return d_common->_compute_control_reg();
-}
-
-int
-db_flexrf_400_rx::_refclk_divisor()
-{
- return d_common->_refclk_divisor();
-}
Modified:
gnuradio/branches/developers/trondeau/dbs/usrp/host/lib/legacy/db_flexrf.h
===================================================================
--- gnuradio/branches/developers/trondeau/dbs/usrp/host/lib/legacy/db_flexrf.h
2008-08-12 21:09:18 UTC (rev 9259)
+++ gnuradio/branches/developers/trondeau/dbs/usrp/host/lib/legacy/db_flexrf.h
2008-08-12 22:02:48 UTC (rev 9260)
@@ -41,6 +41,8 @@
#define AUX_SDO (1 << 1)
#define CLOCK_OUT (1 << 0)
+class _AD4360_common;
+
class flexrf_base : public db_base
{
public:
@@ -64,8 +66,10 @@
void _write_it(int v);
bool _lock_detect();
- virtual bool _compute_regs(float freq, int &retR, int &retcontrol, int
&retN, float &retfreq);
- virtual int _compute_control_reg();
+ virtual bool _compute_regs(float freq, int &retR, int &retcontrol,
+ int &retN, float &retfreq);
+ int _compute_control_reg();
+ int _refclk_divisor();
float _refclk_freq();
bool _set_pga(float pga_gain);
@@ -79,6 +83,8 @@
int d_spi_enable;
int d_power_on;
int d_PD;
+
+ _AD4360_common *d_common;
};
// ----------------------------------------------------------------
@@ -217,12 +223,10 @@
~db_flexrf_2400_tx();
// Wrapper calls to d_common functions
- bool _compute_regs(float freq, int &retR, int &retcontrol, int &retN, float
&retfreq);
+ bool _compute_regs(float freq, int &retR, int &retcontrol,
+ int &retN, float &retfreq);
float freq_min();
float freq_max();
-
-protected:
- _2400_common *d_common;
};
class db_flexrf_2400_rx : public flexrf_base_rx
@@ -238,12 +242,8 @@
float freq_min();
float freq_max();
- bool _compute_regs(float freq, int &retR, int &retcontrol, int &retN, float
&retfreq);
- int _compute_control_reg();
- int _refclk_divisor();
-
-protected:
- _2400_common *d_common;
+ bool _compute_regs(float freq, int &retR, int &retcontrol,
+ int &retN, float &retfreq);
};
//------------------------------------------------------------
@@ -255,13 +255,10 @@
~db_flexrf_1200_tx();
// Wrapper calls to d_common functions
- bool _compute_regs(float freq, int &retR, int &retcontrol, int &retN, float
&retfreq);
+ bool _compute_regs(float freq, int &retR, int &retcontrol,
+ int &retN, float &retfreq);
float freq_min();
float freq_max();
-
-protected:
- _1200_common *d_common;
-
};
class db_flexrf_1200_rx : public flexrf_base_rx
@@ -277,12 +274,8 @@
float freq_min();
float freq_max();
- bool _compute_regs(float freq, int &retR, int &retcontrol, int &retN, float
&retfreq);
- int _compute_control_reg();
- int _refclk_divisor();
-
-protected:
- _1200_common *d_common;
+ bool _compute_regs(float freq, int &retR, int &retcontrol,
+ int &retN, float &retfreq);
};
//------------------------------------------------------------
@@ -294,12 +287,10 @@
~db_flexrf_1800_tx();
// Wrapper calls to d_common functions
- bool _compute_regs(float freq, int &retR, int &retcontrol, int &retN, float
&retfreq);
+ bool _compute_regs(float freq, int &retR, int &retcontrol,
+ int &retN, float &retfreq);
float freq_min();
float freq_max();
-
-protected:
- _1800_common *d_common;
};
class db_flexrf_1800_rx : public flexrf_base_rx
@@ -315,12 +306,8 @@
float freq_min();
float freq_max();
- bool _compute_regs(float freq, int &retR, int &retcontrol, int &retN, float
&retfreq);
- int _compute_control_reg();
- int _refclk_divisor();
-
-protected:
- _1800_common *d_common;
+ bool _compute_regs(float freq, int &retR, int &retcontrol,
+ int &retN, float &retfreq);
};
//------------------------------------------------------------
@@ -332,12 +319,10 @@
~db_flexrf_900_tx();
// Wrapper calls to d_common functions
- bool _compute_regs(float freq, int &retR, int &retcontrol, int &retN, float
&retfreq);
+ bool _compute_regs(float freq, int &retR, int &retcontrol,
+ int &retN, float &retfreq);
float freq_min();
float freq_max();
-
-protected:
- _900_common *d_common;
};
class db_flexrf_900_rx : public flexrf_base_rx
@@ -353,12 +338,8 @@
float freq_min();
float freq_max();
- bool _compute_regs(float freq, int &retR, int &retcontrol, int &retN, float
&retfreq);
- int _compute_control_reg();
- int _refclk_divisor();
-
-protected:
- _900_common *d_common;
+ bool _compute_regs(float freq, int &retR, int &retcontrol,
+ int &retN, float &retfreq);
};
@@ -371,12 +352,10 @@
~db_flexrf_400_tx();
// Wrapper calls to d_common functions
- bool _compute_regs(float freq, int &retR, int &retcontrol, int &retN, float
&retfreq);
+ bool _compute_regs(float freq, int &retR, int &retcontrol,
+ int &retN, float &retfreq);
float freq_min();
float freq_max();
-
-protected:
- _400_common *d_common;
};
class db_flexrf_400_rx : public flexrf_base_rx
@@ -392,12 +371,8 @@
float freq_min();
float freq_max();
- bool _compute_regs(float freq, int &retR, int &retcontrol, int &retN, float
&retfreq);
- int _compute_control_reg();
- int _refclk_divisor();
-
-protected:
- _400_common *d_common;
+ bool _compute_regs(float freq, int &retR, int &retcontrol,
+ int &retN, float &retfreq);
};
#endif
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Commit-gnuradio] r9260 - gnuradio/branches/developers/trondeau/dbs/usrp/host/lib/legacy,
trondeau <=