aboutsummaryrefslogtreecommitdiffstats
path: root/Transceiver52M/radioInterface.cpp
diff options
context:
space:
mode:
authorTom Tsou <tom@tsou.cc>2014-11-25 15:46:56 -0800
committerTom Tsou <tom@tsou.cc>2014-12-15 16:20:15 -0700
commita4d1a4124421473f5f92255e2f3bc44bfa3937ea (patch)
tree9af9b04c2915028363593771e5233e5335c996c1 /Transceiver52M/radioInterface.cpp
parentb99975917585dc8973cc806a5da0aa3fc791b198 (diff)
Transceiver52M: Allow setting gain before POWERON
There is no reason gain settings should not be modifiable when the radio is running or not. Signed-off-by: Tom Tsou <tom@tsou.cc>
Diffstat (limited to 'Transceiver52M/radioInterface.cpp')
-rw-r--r--Transceiver52M/radioInterface.cpp14
1 files changed, 9 insertions, 5 deletions
diff --git a/Transceiver52M/radioInterface.cpp b/Transceiver52M/radioInterface.cpp
index 1329ef1..d67b486 100644
--- a/Transceiver52M/radioInterface.cpp
+++ b/Transceiver52M/radioInterface.cpp
@@ -106,23 +106,27 @@ double RadioInterface::fullScaleOutputValue(void) {
return mRadio->fullScaleOutputValue();
}
-
-void RadioInterface::setPowerAttenuation(double atten, size_t chan)
+int RadioInterface::setPowerAttenuation(int atten, size_t chan)
{
double rfGain, digAtten;
if (chan >= mChans) {
LOG(ALERT) << "Invalid channel requested";
- return;
+ return -1;
}
- rfGain = mRadio->setTxGain(mRadio->maxTxGain() - atten, chan);
- digAtten = atten - mRadio->maxTxGain() + rfGain;
+ if (atten < 0.0)
+ atten = 0.0;
+
+ rfGain = mRadio->setTxGain(mRadio->maxTxGain() - (double) atten, chan);
+ digAtten = (double) atten - mRadio->maxTxGain() + rfGain;
if (digAtten < 1.0)
powerScaling[chan] = 1.0;
else
powerScaling[chan] = 1.0 / sqrt(pow(10, digAtten / 10.0));
+
+ return atten;
}
int RadioInterface::radioifyVector(signalVector &wVector,