Loading...
Searching...
No Matches
crc8gen.h
Go to the documentation of this file.
/*
* Copyright (C) 2011 Sylvain Munaut <tnt@246tNt.com>
*
* All Rights Reserved
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#pragma once
#include <stdint.h>
#include <osmocom/core/bits.h>
struct osmo_crc8gen_code {
int bits;
uint8_t poly;
uint8_t init;
uint8_t remainder;
};
uint8_t osmo_crc8gen_compute_bits(const struct osmo_crc8gen_code *code,
const ubit_t *in, int len);
int osmo_crc8gen_check_bits(const struct osmo_crc8gen_code *code,
const ubit_t *in, int len, const ubit_t *crc_bits);
void osmo_crc8gen_set_bits(const struct osmo_crc8gen_code *code,
const ubit_t *in, int len, ubit_t *crc_bits);
/* vim: set syntax=c: */
bits.h
Osmocom bit level support code.
ubit_t
uint8_t ubit_t
unpacked bit (0 or 1): 1 bit per byte
Definition bits.h:24
osmo_crc8gen_compute_bits
uint8_t osmo_crc8gen_compute_bits(const struct osmo_crc8gen_code *code, const ubit_t *in, int len)
Compute the CRC value of a given array of hard-bits.
Definition crc8gen.c:40
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)
Checks the CRC value of a given array of hard-bits.
Definition crc8gen.c:75
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)
Computes and writes the CRC value of a given array of bits.
Definition crc8gen.c:100
osmo_crc8gen_code
structure describing a given CRC code of max 8 bits
Definition crc8gen.h:30
osmo_crc8gen_code::poly
uint8_t poly
Polynom (normal representation, MSB omitted.
Definition crc8gen.h:32
osmo_crc8gen_code::bits
int bits
Actual number of bits of the CRC.
Definition crc8gen.h:31
osmo_crc8gen_code::init
uint8_t init
Initialization value of the CRC state.
Definition crc8gen.h:33
osmo_crc8gen_code::remainder
uint8_t remainder
Remainder of the CRC (final XOR)
Definition crc8gen.h:34