annotate libutil/osmo_bits.h @ 18:f7321b25195e default tip

new build system for ThemWi sw components
author Mychaela Falconia <falcon@freecalypso.org>
date Tue, 14 May 2024 18:08:35 -0800
parents 35c0d9f03c0a
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
35c0d9f03c0a beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1 /*
35c0d9f03c0a beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2 * This include file has been put together from Osmocom (specifically
35c0d9f03c0a beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
3 * libosmocore) header files, containing definitions for bit vector
35c0d9f03c0a beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
4 * manipulation and CRC functions.
35c0d9f03c0a beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
5 */
35c0d9f03c0a beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
6
35c0d9f03c0a beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
7 /* from bits.h */
35c0d9f03c0a beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
8
35c0d9f03c0a beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
9 /*! unpacked bit (0 or 1): 1 bit per byte */
35c0d9f03c0a beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
10 typedef uint8_t ubit_t;
35c0d9f03c0a beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
11
35c0d9f03c0a beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
12 /* from crc8gen.h */
35c0d9f03c0a beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
13
35c0d9f03c0a beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
14 /*! structure describing a given CRC code of max 8 bits */
35c0d9f03c0a beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
15 struct osmo_crc8gen_code {
35c0d9f03c0a beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
16 int bits; /*!< Actual number of bits of the CRC */
35c0d9f03c0a beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
17 uint8_t poly; /*!< Polynom (normal representation, MSB omitted */
35c0d9f03c0a beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
18 uint8_t init; /*!< Initialization value of the CRC state */
35c0d9f03c0a beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
19 uint8_t remainder; /*!< Remainder of the CRC (final XOR) */
35c0d9f03c0a beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
20 };
35c0d9f03c0a beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
21
35c0d9f03c0a beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
22 uint8_t osmo_crc8gen_compute_bits(const struct osmo_crc8gen_code *code,
35c0d9f03c0a beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
23 const ubit_t *in, int len);
35c0d9f03c0a beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
24 int osmo_crc8gen_check_bits(const struct osmo_crc8gen_code *code,
35c0d9f03c0a beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
25 const ubit_t *in, int len, const ubit_t *crc_bits);
35c0d9f03c0a beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
26 void osmo_crc8gen_set_bits(const struct osmo_crc8gen_code *code,
35c0d9f03c0a beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
27 const ubit_t *in, int len, ubit_t *crc_bits);
35c0d9f03c0a beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
28
35c0d9f03c0a beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
29 /*
35c0d9f03c0a beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
30 * Themyscira-added (not Osmocom-originating) functions
35c0d9f03c0a beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
31 * that use the ubit_t defined type that (to our knowledge)
35c0d9f03c0a beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
32 * was invented by Osmocom.
35c0d9f03c0a beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
33 */
35c0d9f03c0a beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
34
35c0d9f03c0a beginning with sipout-test-voice,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
35 void uint16_to_bits(uint16_t word, ubit_t *out, unsigned nbits);