summaryrefslogtreecommitdiff
path: root/gr-analog/lib/pll_freqdet_cf_impl.cc
diff options
context:
space:
mode:
authorMarcus Müller <mmueller@gnuradio.org>2021-04-09 23:49:10 +0200
committermormj <34754695+mormj@users.noreply.github.com>2021-04-17 20:05:55 -0400
commit39a173fe78a127e57019600e52173e02e492827d (patch)
tree672e81d8b9d0a891bfa6df5a810d9f2e7528e82f /gr-analog/lib/pll_freqdet_cf_impl.cc
parenta9e4368866a650f767b88e9ad3e22097b5374141 (diff)
analog: PLL Freq Det: refactor (implementation in .cc, not .h)
Signed-off-by: Marcus Müller <mmueller@gnuradio.org>
Diffstat (limited to 'gr-analog/lib/pll_freqdet_cf_impl.cc')
-rw-r--r--gr-analog/lib/pll_freqdet_cf_impl.cc16
1 files changed, 16 insertions, 0 deletions
diff --git a/gr-analog/lib/pll_freqdet_cf_impl.cc b/gr-analog/lib/pll_freqdet_cf_impl.cc
index a450b00f5f..33d46f1135 100644
--- a/gr-analog/lib/pll_freqdet_cf_impl.cc
+++ b/gr-analog/lib/pll_freqdet_cf_impl.cc
@@ -35,6 +35,22 @@ pll_freqdet_cf_impl::pll_freqdet_cf_impl(float loop_bw, float max_freq, float mi
}
pll_freqdet_cf_impl::~pll_freqdet_cf_impl() {}
+constexpr float mod_2pi(float in)
+{
+ if (in > GR_M_PI) {
+ return in - static_cast<float>(2.0 * GR_M_PI);
+ }
+ if (in < -GR_M_PI) {
+ return in + static_cast<float>(2.0 * GR_M_PI);
+ }
+ return in;
+}
+
+float phase_detector(gr_complex sample, float ref_phase)
+{
+ float sample_phase = gr::fast_atan2f(sample.imag(), sample.real());
+ return mod_2pi(sample_phase - ref_phase);
+}
int pll_freqdet_cf_impl::work(int noutput_items,
gr_vector_const_void_star& input_items,