GNU Radio's GSM Package
crc8gen.h
Go to the documentation of this file.
1 /*
2  * crc8gen.h
3  *
4  * Copyright (C) 2011 Sylvain Munaut <tnt@246tNt.com>
5  *
6  * All Rights Reserved
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License along
19  * with this program; if not, write to the Free Software Foundation, Inc.,
20  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21  */
22 
23 #pragma once
24 
25 /*! \addtogroup crcgen
26  * @{
27  */
28 
29 /*! \file crc8gen.h
30  * Osmocom generic CRC routines (for max 8 bits poly) header
31  */
32 
33 
34 #include <stdint.h>
35 #include <osmocom/core/bits.h>
36 
37 
38 /*! \brief structure describing a given CRC code of max 8 bits */
40  int bits; /*!< \brief Actual number of bits of the CRC */
41  uint8_t poly; /*!< \brief Polynom (normal representation, MSB omitted */
42  uint8_t init; /*!< \brief Initialization value of the CRC state */
43  uint8_t remainder; /*!< \brief Remainder of the CRC (final XOR) */
44 };
45 
46 uint8_t osmo_crc8gen_compute_bits(const struct osmo_crc8gen_code *code,
47  const ubit_t *in, int len);
49  const ubit_t *in, int len, const ubit_t *crc_bits);
50 void osmo_crc8gen_set_bits(const struct osmo_crc8gen_code *code,
51  const ubit_t *in, int len, ubit_t *crc_bits);
52 
53 
54 /*! @} */
55 
56 /* vim: set syntax=c: */
osmo_crc8gen_compute_bits
uint8_t osmo_crc8gen_compute_bits(const struct osmo_crc8gen_code *code, const ubit_t *in, int len)
osmo_crc8gen_set_bits
void osmo_crc8gen_set_bits(const struct osmo_crc8gen_code *code, const ubit_t *in, int len, ubit_t *crc_bits)
osmo_crc8gen_code::poly
uint8_t poly
Polynom (normal representation, MSB omitted.
Definition: crc8gen.h:41
bits.h
osmo_crc8gen_code::bits
int bits
Actual number of bits of the CRC.
Definition: crc8gen.h:40
ubit_t
uint8_t ubit_t
Definition: bits.h:24
osmo_crc8gen_code::init
uint8_t init
Initialization value of the CRC state.
Definition: crc8gen.h:42
osmo_crc8gen_code::remainder
uint8_t remainder
Remainder of the CRC (final XOR)
Definition: crc8gen.h:43
osmo_crc8gen_check_bits
int osmo_crc8gen_check_bits(const struct osmo_crc8gen_code *code, const ubit_t *in, int len, const ubit_t *crc_bits)
osmo_crc8gen_code
structure describing a given CRC code of max 8 bits
Definition: crc8gen.h:39