summaryrefslogtreecommitdiffstats
path: root/src/target/firmware/layer1/sync.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/target/firmware/layer1/sync.c')
-rw-r--r--src/target/firmware/layer1/sync.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/target/firmware/layer1/sync.c b/src/target/firmware/layer1/sync.c
index 36f42975..0cf4f10b 100644
--- a/src/target/firmware/layer1/sync.c
+++ b/src/target/firmware/layer1/sync.c
@@ -187,6 +187,7 @@ void l1s_reset_hw(void)
static int last_timestamp;
+static int last_ts = 0;
static inline void check_lost_frame(void)
{
int diff, timestamp = hwtimer_read(1);
@@ -196,6 +197,26 @@ static inline void check_lost_frame(void)
diff = last_timestamp - timestamp;
+ /* TS change compensation */
+ if (l1s.dedicated.type) {
+ if (l1s.dedicated.tn < last_ts) {
+ int ediff = ((8 - last_ts + l1s.dedicated.tn) * TIMER_TICKS_PER_TDMA) >> 3;
+ printf("TS Chg back: %d -> %d | %d %d\n",
+ last_ts, l1s.dedicated.tn, diff, ediff);
+
+ // if (((ediff - 2) < diff) && ((ediff + 2) > diff)) {
+ puts("ADV !\n");
+ l1s.current_time = l1s.next_time;
+ l1s_time_inc(&l1s.next_time, 1);
+ // }
+ } else if (l1s.dedicated.tn > last_ts)
+ printf("TS Chg forth: %d -> %d | %d\n",
+ last_ts, l1s.dedicated.tn, diff);
+ last_ts = l1s.dedicated.tn;
+ }
+// } else
+// last_ts = 0;
+
/* allow for a bit of jitter */
if (diff < TIMER_TICKS_PER_TDMA - TIMER_TICK_JITTER ||
diff > TIMER_TICKS_PER_TDMA + TIMER_TICK_JITTER)
@@ -367,6 +388,7 @@ void l1s_reset(void)
/* Leave dedicated mode */
l1s.dedicated.type = GSM_DCHAN_NONE;
+ last_ts = 0;
/* reset scheduler and hardware */
sched_gsmtime_reset();