diff options
author | Vadim Yanitskiy <axilirator@gmail.com> | 2018-03-02 21:24:57 +0700 |
---|---|---|
committer | Vadim Yanitskiy <axilirator@gmail.com> | 2018-03-02 21:24:57 +0700 |
commit | c066787fd5e9696e4af0a43f7bd3fd9392de4931 (patch) | |
tree | 551ded65f04e9e57b990a9865a7d073942dc3554 /src/host/trxcon/trx_if.c | |
parent | ff233256e12b370db78af29d4b283ba5e19becfa (diff) |
host/trxcon: use integer math for ToA (Timing of Arrival)
There's no need to express ToA value as a float. Let's 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.
Inspired by Idce4178e0b1f7e940ebc22b3e2f340fcd544d4ec.
Change-Id: I99c0f38db08a530d5846c474aba352aa0b68fe86
Diffstat (limited to 'src/host/trxcon/trx_if.c')
-rw-r--r-- | src/host/trxcon/trx_if.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/src/host/trxcon/trx_if.c b/src/host/trxcon/trx_if.c index 048b720c..cab5a9bd 100644 --- a/src/host/trxcon/trx_if.c +++ b/src/host/trxcon/trx_if.c @@ -535,8 +535,8 @@ static int trx_data_rx_cb(struct osmo_fd *ofd, unsigned int what) uint8_t buf[256]; sbit_t bits[148]; int8_t rssi, tn; + int16_t toa256; uint32_t fn; - float toa; int len; len = recv(ofd->fd, buf, sizeof(buf), 0); @@ -552,7 +552,7 @@ static int trx_data_rx_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} */ osmo_ubit2sbit(bits, buf + 8, 148); @@ -567,11 +567,11 @@ static int trx_data_rx_cb(struct osmo_fd *ofd, unsigned int what) return -EINVAL; } - LOGP(DTRXD, LOGL_DEBUG, "RX burst tn=%u fn=%u rssi=%d toa=%.2f\n", - tn, fn, rssi, toa); + LOGP(DTRXD, LOGL_DEBUG, "RX burst tn=%u fn=%u rssi=%d toa=%d\n", + tn, fn, rssi, toa256); /* Poke scheduler */ - sched_trx_handle_rx_burst(trx, tn, fn, bits, 148, rssi, toa); + sched_trx_handle_rx_burst(trx, tn, fn, bits, 148, rssi, toa256); /* Correct local clock counter */ if (fn % 51 == 0) |