Skip to content

Commit

Permalink
Add API to change NCQO state of PLLs
Browse files Browse the repository at this point in the history
  • Loading branch information
BatchDrake committed May 15, 2023
1 parent 6e30f90 commit bd4295d
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 8 deletions.
44 changes: 44 additions & 0 deletions src/include/sigutils/pll.h
Expand Up @@ -92,6 +92,50 @@ SU_METHOD(su_pll, SUFLOAT, locksig)
return self->lock;
}

SUINLINE
SU_METHOD(su_pll, void, set_angfreq, SUFLOAT omega)
{
su_ncqo_set_angfreq(&self->ncqo, omega);
}

SUINLINE
SU_METHOD(su_pll, void, set_freq, SUFLOAT omega)
{
su_ncqo_set_freq(&self->ncqo, omega);
}

SUINLINE
SU_METHOD(su_pll, void, inc_angfreq, SUFLOAT delta)
{
su_ncqo_inc_angfreq(&self->ncqo, delta);
}

SUINLINE
SU_GETTER(su_pll, SUFREQ, get_freq)
{
return su_ncqo_get_freq(&self->ncqo);
}

SUINLINE
SU_GETTER(su_pll, SUFREQ, get_angfreq)
{
return su_ncqo_get_angfreq(&self->ncqo);
}

SUINLINE
SU_METHOD(su_pll, void, set_cutoff, SUFLOAT fc)
{
SUFLOAT dinv;

fc = SU_NORM2ANG_FREQ(fc);

/* Settings taken from GNU Radio */
dinv = 1.f / (1.f + 2.f * .707f * fc + fc * fc);

self->alpha = 4 * fc * fc * dinv;
self->beta = 4 * 0.707 * fc * dinv;
}

/* QPSK costas loops are way more complex than that */
SU_CONSTRUCTOR(
su_costas,
Expand Down
9 changes: 1 addition & 8 deletions src/sigutils/pll.c
Expand Up @@ -37,14 +37,7 @@ SU_CONSTRUCTOR(su_pll, SUFLOAT fhint, SUFLOAT fc)

memset(self, 0, sizeof(su_pll_t));

fc = SU_NORM2ANG_FREQ(fc);

/* Settings taken from GNU Radio */
dinv = 1.f / (1.f + 2.f * .707f * fc + fc * fc);

self->alpha = 4 * fc * fc * dinv;
self->beta = 4 * 0.707 * fc * dinv;

su_pll_set_cutoff(self, fc);
su_ncqo_init(&self->ncqo, fhint);

return SU_TRUE;
Expand Down

0 comments on commit bd4295d

Please sign in to comment.