aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTom Tsou <tom.tsou@ettus.com>2016-05-03 19:02:24 -0700
committerTom Tsou <tom.tsou@ettus.com>2016-05-03 19:04:00 -0700
commit3f4a13f0496d2407a698df62c34bdb410529fc54 (patch)
treec43eed754dfe9d508a4ab54c80a8cda5649a24d3
parent0fe41a583cb95ad3aaedc3fa6e99fa73755662f4 (diff)
uhd: Make device offset check a private method
Removes extra arguments and a static call. Signed-off-by: Tom Tsou <tom.tsou@ettus.com>
-rw-r--r--Transceiver52M/UHDDevice.cpp123
1 files changed, 62 insertions, 61 deletions
diff --git a/Transceiver52M/UHDDevice.cpp b/Transceiver52M/UHDDevice.cpp
index bcb64b0..0c57222 100644
--- a/Transceiver52M/UHDDevice.cpp
+++ b/Transceiver52M/UHDDevice.cpp
@@ -68,8 +68,8 @@ enum uhd_dev_type {
struct uhd_dev_offset {
enum uhd_dev_type type;
- int tx_sps;
- int rx_sps;
+ size_t tx_sps;
+ size_t rx_sps;
double offset;
const std::string desc;
};
@@ -131,64 +131,6 @@ static struct uhd_dev_offset special_offsets[] = {
{ UMTRX, 4, 1, 5.2103e-5, "UmTRX diversity, 4 SPS" },
};
-static double get_dev_offset(enum uhd_dev_type type, int tx_sps, int rx_sps,
- bool edge = false, bool diversity = false)
-{
- struct uhd_dev_offset *offset = NULL;
-
- /* Reject USRP1 */
- if (type == USRP1) {
- LOG(ERR) << "Invalid device type";
- return 0.0;
- }
-
- if (edge && diversity) {
- LOG(ERR) << "Unsupported configuration";
- return 0.0;
- }
-
- if (edge && (type != B200) && (type != B210) && (type != UMTRX)) {
- LOG(ALERT) << "EDGE is supported on B200/B210 and UmTRX only";
- return 0.0;
- }
-
- /* Special cases (e.g. diversity receiver) */
- if (diversity) {
- if (type != UMTRX) {
- LOG(ALERT) << "Diversity on UmTRX only";
- return 0.0;
- }
-
- switch (tx_sps) {
- case 1:
- offset = &special_offsets[0];
- break;
- case 4:
- default:
- offset = &special_offsets[1];
- }
- } else {
- /* Search for matching offset value */
- for (size_t i = 0; i < NUM_UHD_OFFSETS; i++) {
- if ((type == uhd_offsets[i].type) &&
- (tx_sps == uhd_offsets[i].tx_sps) &&
- (rx_sps == uhd_offsets[i].rx_sps)) {
- offset = &uhd_offsets[i];
- break;
- }
- }
- }
-
- if (!offset) {
- LOG(ERR) << "Invalid device configuration";
- return 0.0;
- }
-
- std::cout << "-- Setting " << offset->desc << std::endl;
-
- return offset->offset;
-}
-
/*
* Select sample rate based on device type and requested samples-per-symbol.
* The base rate is either GSM symbol rate, 270.833 kHz, or the minimum
@@ -385,6 +327,7 @@ private:
std::vector<smpl_buf *> rx_buffers;
void init_gains();
+ double get_dev_offset(bool edge, bool diversity);
int set_master_clk(double rate);
int set_rates(double tx_rate, double rx_rate);
bool parse_dev_type();
@@ -513,6 +456,64 @@ void uhd_device::init_gains()
}
+double uhd_device::get_dev_offset(bool edge, bool diversity)
+{
+ struct uhd_dev_offset *offset = NULL;
+
+ /* Reject USRP1 */
+ if (dev_type == USRP1) {
+ LOG(ERR) << "Invalid device type";
+ return 0.0;
+ }
+
+ if (edge && diversity) {
+ LOG(ERR) << "Unsupported configuration";
+ return 0.0;
+ }
+
+ if (edge && (dev_type != B200) &&
+ (dev_type != B210) && (dev_type != UMTRX)) {
+ LOG(ALERT) << "EDGE is supported on B200/B210 and UmTRX only";
+ return 0.0;
+ }
+
+ /* Special cases (e.g. diversity receiver) */
+ if (diversity) {
+ if (dev_type != UMTRX) {
+ LOG(ALERT) << "Diversity on UmTRX only";
+ return 0.0;
+ }
+
+ switch (tx_sps) {
+ case 1:
+ offset = &special_offsets[0];
+ break;
+ case 4:
+ default:
+ offset = &special_offsets[1];
+ }
+ } else {
+ /* Search for matching offset value */
+ for (size_t i = 0; i < NUM_UHD_OFFSETS; i++) {
+ if ((dev_type == uhd_offsets[i].type) &&
+ (tx_sps == uhd_offsets[i].tx_sps) &&
+ (rx_sps == uhd_offsets[i].rx_sps)) {
+ offset = &uhd_offsets[i];
+ break;
+ }
+ }
+ }
+
+ if (!offset) {
+ LOG(ERR) << "Invalid device configuration";
+ return 0.0;
+ }
+
+ std::cout << "-- Setting " << offset->desc << std::endl;
+
+ return offset->offset;
+}
+
int uhd_device::set_master_clk(double clk_rate)
{
double actual, offset, limit = 1.0;
@@ -802,7 +803,7 @@ int uhd_device::open(const std::string &args, bool extref, bool swap_channels)
if (rx_sps == 4)
edge = true;
- double offset = get_dev_offset(dev_type, tx_sps, rx_sps, edge, diversity);
+ double offset = get_dev_offset(edge, diversity);
if (offset == 0.0) {
LOG(ERR) << "Unsupported configuration, no correction applied";
ts_offset = 0;