aboutsummaryrefslogtreecommitdiffstats
path: root/Transceiver52M/radioVector.cpp
diff options
context:
space:
mode:
authorThomas Tsou <tom@tsou.cc>2014-04-16 23:10:12 -0400
committerThomas Tsou <tom@tsou.cc>2014-10-06 10:35:29 -0700
commit14bb9c923d8c967e8ce114a868923e9566be51e5 (patch)
tree4e2b1724ff032d870468f968f395bee767cefdf0 /Transceiver52M/radioVector.cpp
parentc7f36c282a917a4718f9b116ba59d2daffa16eb2 (diff)
Transceiver52M: Add FCCH based frequency correction
Enable frequency detection and correction by buffering the previous frame to allow FCCH measurement and compensation after frame timing is locked using the SCH. When the SCH is detected and symbol timing matched, measure the FCCH burst from one frame prior and compensate by baseband tuning the DDC on the device. Avoid appying frequency corrections to the RF portion due to possible tuning delays, which is not an issue with DDC tuning. Signed-off-by: Thomas Tsou <tom@tsou.cc>
Diffstat (limited to 'Transceiver52M/radioVector.cpp')
-rw-r--r--Transceiver52M/radioVector.cpp28
1 files changed, 22 insertions, 6 deletions
diff --git a/Transceiver52M/radioVector.cpp b/Transceiver52M/radioVector.cpp
index 2e3af9d..ea354b4 100644
--- a/Transceiver52M/radioVector.cpp
+++ b/Transceiver52M/radioVector.cpp
@@ -74,25 +74,31 @@ bool radioVector::setVector(signalVector *vector, size_t chan)
return true;
}
-noiseVector::noiseVector(size_t size)
- : std::vector<float>(size), itr(0)
+avgVector::avgVector(size_t max)
+ : std::vector<float>(0), itr(0)
{
+ this->max = max;
}
-float noiseVector::avg() const
+float avgVector::avg() const
{
float val = 0.0;
+ if (!size())
+ return 0.0f;
+
for (size_t i = 0; i < size(); i++)
val += (*this)[i];
return val / (float) size();
}
-bool noiseVector::insert(float val)
+bool avgVector::insert(float val)
{
- if (!size())
- return false;
+ if (size() < max) {
+ push_back(val);
+ return true;
+ }
if (itr >= this->size())
itr = 0;
@@ -102,6 +108,16 @@ bool noiseVector::insert(float val)
return true;
}
+bool avgVector::full() const
+{
+ return size() >= max;
+}
+
+void avgVector::reset()
+{
+ resize(0);
+}
+
GSM::Time VectorQueue::nextTime() const
{
GSM::Time retVal;