summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSylvain Munaut <tnt@246tNt.com>2010-09-23 21:05:18 +0200
committerAndreas Eversberg <jolly@eversberg.eu>2013-10-05 19:44:37 +0200
commitcb59ea788379e1c2bb2b5860b25c292e5ee3dcad (patch)
treee6f89e019a952eaccda56f7f7d7807ad2f806db0
parentcca4eb28e7378afef6c475a3b022a0e41cf7b259 (diff)
[WIP] Ugly hack to compensate lost time on TS change (high TS -> low TS)
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
-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();