From: Sylvain Munaut Date: Thu, 23 Sep 2010 19:05:18 +0000 (+0200) Subject: [WIP] Ugly hack to compensate lost time on TS change (high TS -> low TS) X-Git-Url: http://git.rot13.org/?a=commitdiff_plain;h=48bc8877b5b1811d2aa0b5491683c6b540d16611;p=osmocom-bb.git [WIP] Ugly hack to compensate lost time on TS change (high TS -> low TS) Signed-off-by: Sylvain Munaut --- diff --git a/src/target/firmware/layer1/sync.c b/src/target/firmware/layer1/sync.c index 3397dc0..150205f 100644 --- a/src/target/firmware/layer1/sync.c +++ b/src/target/firmware/layer1/sync.c @@ -189,6 +189,7 @@ static int last_timestamp; static inline void check_lost_frame(void) { + static int last_ts = -1; int diff, timestamp = hwtimer_read(1); if (last_timestamp < timestamp) @@ -196,6 +197,22 @@ 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: %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); + // } + } + last_ts = l1s.dedicated.tn; + } + /* allow for a bit of jitter */ if (diff < TIMER_TICKS_PER_TDMA - TIMER_TICK_JITTER || diff > TIMER_TICKS_PER_TDMA + TIMER_TICK_JITTER)