Commit 8c6c365b authored by Tomasz Wlostowski's avatar Tomasz Wlostowski

softpll: starting ptracker should clear its' state

parent b6ec8446
......@@ -5,7 +5,7 @@ struct spll_ptracker_state {
int id_a, id_b;
int n_avg, acc, avg_count;
int phase_val, ready;
int tag_a, tag_b;
int tag_a, tag_b;
int sample_n;
int preserve_sign;
};
......@@ -14,7 +14,7 @@ struct spll_ptracker_state {
static void ptracker_init(struct spll_ptracker_state *s, int id_a, int id_b, int num_avgs)
{
s->tag_a = s->tag_b = -1;
s->id_a = id_a;
s->id_b = id_b;
s->ready = 0;
......@@ -27,6 +27,13 @@ static void ptracker_init(struct spll_ptracker_state *s, int id_a, int id_b, int
static void ptracker_start(struct spll_ptracker_state *s)
{
s->tag_a = s->tag_b = -1;
s->ready = 0;
s->acc = 0;
s->avg_count = 0;
s->sample_n= 0;
s->preserve_sign = 0;
spll_enable_tagger(s->id_a, 1);
spll_enable_tagger(s->id_b, 1);
}
......@@ -45,13 +52,13 @@ static int ptracker_update(struct spll_ptracker_state *s, int tag, int source)
if(s->tag_a >= 0 && s->tag_b >= 0)
{
int delta = (s->tag_a - s->tag_b) & ((1<<HPLL_N) - 1);
s->sample_n++;
if(s->avg_count == 0)
{
if(delta <= PTRACK_WRAP_LO)
if(delta <= PTRACK_WRAP_LO)
s->preserve_sign = -1;
else if (delta >= PTRACK_WRAP_HI)
s->preserve_sign = 1;
......@@ -61,7 +68,7 @@ static int ptracker_update(struct spll_ptracker_state *s, int tag, int source)
s->avg_count++;
s->acc = delta;
} else {
if(delta <= PTRACK_WRAP_LO && s->preserve_sign > 0)
s->acc += delta + (1<<HPLL_N);
else if (delta >= PTRACK_WRAP_HI && s->preserve_sign < 0)
......@@ -78,8 +85,8 @@ static int ptracker_update(struct spll_ptracker_state *s, int tag, int source)
s->acc = 0;
s->avg_count = 0;
}
}
}
s->tag_b = s->tag_a = -1;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment