FreeCalypso > hg > themwi-system-sw
annotate libutil/tfo_msg_enc.c @ 209:e80f158333c5
mgw: correct PCMU decoding table
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sun, 07 May 2023 21:43:02 -0800 |
parents | 05d01e810217 |
children |
rev | line source |
---|---|
194
05d01e810217
libutil: add TFO message gen function based on Osmocom crc8gen
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1 /* |
05d01e810217
libutil: add TFO message gen function based on Osmocom crc8gen
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2 * The function implemented in this module encodes a GSM 08.62 Extension_Block. |
05d01e810217
libutil: add TFO message gen function based on Osmocom crc8gen
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
3 */ |
05d01e810217
libutil: add TFO message gen function based on Osmocom crc8gen
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
4 |
05d01e810217
libutil: add TFO message gen function based on Osmocom crc8gen
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
5 #include <stdint.h> |
05d01e810217
libutil: add TFO message gen function based on Osmocom crc8gen
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
6 #include "osmo_bits.h" |
05d01e810217
libutil: add TFO message gen function based on Osmocom crc8gen
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
7 |
05d01e810217
libutil: add TFO message gen function based on Osmocom crc8gen
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
8 /* |
05d01e810217
libutil: add TFO message gen function based on Osmocom crc8gen
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
9 * EFR TRAU parity |
05d01e810217
libutil: add TFO message gen function based on Osmocom crc8gen
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
10 * |
05d01e810217
libutil: add TFO message gen function based on Osmocom crc8gen
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
11 * g(x) = x^3 + x^1 + 1 |
05d01e810217
libutil: add TFO message gen function based on Osmocom crc8gen
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
12 */ |
05d01e810217
libutil: add TFO message gen function based on Osmocom crc8gen
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
13 static const struct osmo_crc8gen_code gsm0860_efr_crc3 = { |
05d01e810217
libutil: add TFO message gen function based on Osmocom crc8gen
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
14 .bits = 3, |
05d01e810217
libutil: add TFO message gen function based on Osmocom crc8gen
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
15 .poly = 0x3, |
05d01e810217
libutil: add TFO message gen function based on Osmocom crc8gen
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
16 .init = 0x0, |
05d01e810217
libutil: add TFO message gen function based on Osmocom crc8gen
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
17 .remainder = 0x7, |
05d01e810217
libutil: add TFO message gen function based on Osmocom crc8gen
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
18 }; |
05d01e810217
libutil: add TFO message gen function based on Osmocom crc8gen
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
19 |
05d01e810217
libutil: add TFO message gen function based on Osmocom crc8gen
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
20 void |
05d01e810217
libutil: add TFO message gen function based on Osmocom crc8gen
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
21 encode_tfo_ext_words(bits_2_10, bits_12_15, ex, out) |
05d01e810217
libutil: add TFO message gen function based on Osmocom crc8gen
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
22 unsigned bits_2_10, bits_12_15, ex; |
05d01e810217
libutil: add TFO message gen function based on Osmocom crc8gen
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
23 uint16_t *out; |
05d01e810217
libutil: add TFO message gen function based on Osmocom crc8gen
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
24 { |
05d01e810217
libutil: add TFO message gen function based on Osmocom crc8gen
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
25 ubit_t crc_in[13]; |
05d01e810217
libutil: add TFO message gen function based on Osmocom crc8gen
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
26 uint8_t crc; |
05d01e810217
libutil: add TFO message gen function based on Osmocom crc8gen
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
27 |
05d01e810217
libutil: add TFO message gen function based on Osmocom crc8gen
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
28 uint16_to_bits(bits_2_10, crc_in, 9); |
05d01e810217
libutil: add TFO message gen function based on Osmocom crc8gen
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
29 uint16_to_bits(bits_12_15, crc_in + 9, 4); |
05d01e810217
libutil: add TFO message gen function based on Osmocom crc8gen
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
30 crc = osmo_crc8gen_compute_bits(&gsm0860_efr_crc3, crc_in, 13); |
05d01e810217
libutil: add TFO message gen function based on Osmocom crc8gen
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
31 out[0] = bits_2_10; |
05d01e810217
libutil: add TFO message gen function based on Osmocom crc8gen
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
32 out[1] = (bits_12_15 << 5) | (crc << 2) | ex; |
05d01e810217
libutil: add TFO message gen function based on Osmocom crc8gen
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
33 } |