diff options
author | Harald Welte <laforge@gnumonks.org> | 2018-02-19 14:21:36 +0100 |
---|---|---|
committer | Harald Welte <laforge@gnumonks.org> | 2018-02-27 19:58:20 +0100 |
commit | d5bbd8ccf79eaf13bc23cc71accbeb3ff638b6dd (patch) | |
tree | 0f1ec34ad152ac9e7933724b35a8d342e8be2abe /src/osmo-bts-trx/trx_if.c | |
parent | b3a2a3e24f44adcc6660d33cc9684a8f24271e2e (diff) |
trx/scheduler: Use integer math for TOA (Timing of Arrival)
There's no need to express TOA as a float:
* We receive it as signed 16bit integer in units 1/256 symbol periods
* We pass it to L1SAP as signed integer in 1/4 symbol periods
So turn it into an int16_t with 1/256 symbol period accuracy throughout
the code to avoid both float arithmetic as well as loosing any precision.
Change-Id: Idce4178e0b1f7e940ebc22b3e2f340fcd544d4ec
Diffstat (limited to 'src/osmo-bts-trx/trx_if.c')
-rw-r--r-- | src/osmo-bts-trx/trx_if.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/osmo-bts-trx/trx_if.c b/src/osmo-bts-trx/trx_if.c index 35698ef5..f3de2453 100644 --- a/src/osmo-bts-trx/trx_if.c +++ b/src/osmo-bts-trx/trx_if.c @@ -520,7 +520,7 @@ static int trx_data_read_cb(struct osmo_fd *ofd, unsigned int what) int len; uint8_t tn; int8_t rssi; - float toa = 0.0; + int16_t toa256 = 0; uint32_t fn; sbit_t bits[EGPRS_BURST_LEN]; int i, burst_len = GSM_BURST_LEN; @@ -539,7 +539,7 @@ static int trx_data_read_cb(struct osmo_fd *ofd, unsigned int what) tn = buf[0]; fn = (buf[1] << 24) | (buf[2] << 16) | (buf[3] << 8) | buf[4]; rssi = -(int8_t)buf[5]; - toa = ((int16_t)(buf[6] << 8) | buf[7]) / 256.0F; + toa256 = ((int16_t)(buf[6] << 8) | buf[7]); /* copy and convert bits {254..0} to sbits {-127..127} */ for (i = 0; i < burst_len; i++) { @@ -558,20 +558,20 @@ static int trx_data_read_cb(struct osmo_fd *ofd, unsigned int what) return -EINVAL; } - LOGP(DTRX, LOGL_DEBUG, "RX burst tn=%u fn=%u rssi=%d toa=%.2f\n", - tn, fn, rssi, toa); + LOGP(DTRX, LOGL_DEBUG, "RX burst tn=%u fn=%u rssi=%d toa256=%d\n", + tn, fn, rssi, toa256); #ifdef TOA_RSSI_DEBUG char deb[128]; sprintf(deb, "| 0 " - " | rssi=%4d toa=%4.2f fn=%u", rssi, toa, fn); + " | rssi=%4d toa=%5d fn=%u", rssi, toa256, fn); deb[1 + (128 + rssi) / 4] = '*'; fprintf(stderr, "%s\n", deb); #endif /* feed received burst into scheduler code */ - trx_sched_ul_burst(&l1h->l1s, tn, fn, bits, burst_len, rssi, toa); + trx_sched_ul_burst(&l1h->l1s, tn, fn, bits, burst_len, rssi, toa256); return 0; } |