MotorControlModuleSDFM_TMS3.../Projects/EFC_Communication/UMLibrary/common/CrcDesc.hpp
2024-06-07 11:12:56 +03:00

141 lines
3.8 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/*
* CrcDesc.hpp
*
* Created on: 30 нояб. 2018 г.
* Author: maksimenko
*/
#ifndef SOURCE_COMMON_CRCDESC_HPP_
#define SOURCE_COMMON_CRCDESC_HPP_
#include <cstddef>
namespace common {
namespace crc {
struct Crc32_ZLIB
{
static const uint32_t poly = 0xedb88320;// Базовый полином CRC
static const uint32_t width_bit = 32;// Число значащих бит расчета
static const bool reflect = true;// Порядок битов в байте b0->b7
static const uint32_t init = 0xFFFFFFFF;// Начальное значение CRC
static const uint32_t final = 0xFFFFFFFF;// Значение завершающего XOR
typedef uint32_t res_t;// Тип представляющий результат
typedef CrcVal<Crc32_ZLIB> crc_t;// Тип переменной расчета CRC
};
struct Crc32_PRIME
{
static const uint32_t poly = 0x04c11db7;
static const uint32_t width_bit = 32;
static const bool reflect = false;
static const uint32_t init = 0x0;
static const uint32_t final = 0x0;
typedef uint32_t res_t;
typedef CrcVal<Crc32_PRIME> crc_t;
};
struct Crc16_802_15_4
{
static const uint32_t poly = 0x1021;
static const uint32_t width_bit = 16;
static const bool reflect = false;
static const uint32_t init = 0x0;
static const uint32_t final = 0x0;
typedef uint16_t res_t;
typedef CrcVal<Crc16_802_15_4> crc_t;
};
struct Crc16_ALT
{
static const uint32_t poly = 0x8005;
static const uint32_t width_bit = 16;
static const bool reflect = false;
static const uint32_t init = 0x0;
static const uint32_t final = 0x0;
typedef uint16_t res_t;
typedef CrcVal<Crc16_ALT> crc_t;
};
struct Crc16_IBM// CRC-16-ANSI (Modbus RTU,)
{
static const uint32_t poly = 0xA001;
static const uint32_t width_bit = 16;
static const bool reflect = true;
static const uint32_t init = 0xFFFF;
static const uint32_t final = 0x0;
typedef uint16_t res_t;
typedef CrcVal<Crc16_IBM> crc_t;
};
struct Crc8_PRIME
{
static const uint32_t poly = 0x07;
static const uint32_t width_bit = 8;
static const bool reflect = false;
static const uint32_t init = 0x0;
static const uint32_t final = 0x0;
typedef uint16_t res_t;
typedef CrcVal<Crc8_PRIME> crc_t;
};
struct Crc32_C
{
static const uint32_t poly = 0x1edc6f41;
static const uint32_t width_bit = 32;
static const bool reflect = false;
static const uint32_t init = 0x0;
static const uint32_t final = 0x0;
typedef uint32_t res_t;
typedef CrcVal<Crc32_C> crc_t;
};
struct Crc24_FLEXRAY
{
static const uint32_t poly = 0x005d6dcb;
static const uint32_t width_bit = 24;
static const bool reflect = false;
static const uint32_t init = 0x0;
static const uint32_t final = 0x0;
typedef uint32_t res_t;
typedef CrcVal<Crc24_FLEXRAY> crc_t;
};
struct Crc16_CCITT
{
static const uint32_t poly = 0x1021;
static const uint32_t width_bit = 16;
static const bool reflect = false;
static const uint32_t init = 0xFFFF;
static const uint32_t final = 0x0;
typedef uint16_t res_t;
typedef CrcVal<Crc16_CCITT> crc_t;
};
struct Crc6_BISS
{
static const uint32_t poly = 0x43;
static const uint32_t width_bit = 6;
static const bool reflect = true;
static const uint32_t init = 0x0;
static const uint32_t final = 0x3F;
typedef uint32_t res_t;
typedef CrcVal<Crc6_BISS> crc_t;
};
struct Crc3_GSM
{
static const uint32_t poly = 0x3;
static const uint32_t width_bit = 3;
static const bool reflect = false;
static const uint32_t init = 0x0;
static const uint32_t final = 0x7;
typedef uint16_t res_t;
typedef CrcVal<Crc3_GSM> crc_t;
};
} // namespace crc
} // namespace common
#endif /* SOURCE_COMMON_CRCDESC_HPP_ */