Merge remote-tracking branch 'origin/crc-ccitt-xmodem' into development

# Conflicts:
#	README.md
This commit is contained in:
John Wellbelove 2019-12-12 12:18:51 +00:00
parent 703fe0f92b
commit 7e5a4e1efe
39 changed files with 2362 additions and 704 deletions

View File

@ -3,12 +3,12 @@ Embedded Template Library (ETL)
AppVeyor
[![Build status](https://ci.appveyor.com/api/projects/status/b7jgecv7unqjw4u0/branch/master?svg=true)](https://ci.appveyor.com/project/jwellbelove/etl/branch/master)
![build status](https://gitlab.com/ETLCPP/etl/badges/master/build.svg)
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/3c14cd918ccf40008d0bcd7b083d5946)](https://www.codacy.com/manual/jwellbelove/etl?utm_source=github.com&utm_medium=referral&utm_content=ETLCPP/etl&utm_campaign=Badge_Grade)
![GitHub release (latest by date)](https://img.shields.io/github/v/release/jwellbelove/etl)
[![License](https://img.shields.io/badge/license-MIT-blue.svg)](https://opensource.org/licenses/MIT)
[![Github All Releases](https://img.shields.io/github/downloads/ETLCPP/etl/total.svg)]()
**Motivation**
C++ is a great language to use for embedded applications and templates are a powerful aspect. The standard library can offer a great deal of well tested functionality, but there are some parts of the standard library that do not fit well with deterministic behaviour and limited resource requirements. These limitations usually preclude the use of dynamically allocated memory and containers with open ended sizes.

BIN
images/etl.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

BIN
images/etl.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

BIN
images/etl.pspimage Normal file

Binary file not shown.

BIN
images/etl.xar Normal file

Binary file not shown.

BIN
images/etl16.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

BIN
images/etl32.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

BIN
images/etl48.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

BIN
images/favicon.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

@ -31,12 +31,8 @@ SOFTWARE.
#ifndef ETL_CRC16_INCLUDED
#define ETL_CRC16_INCLUDED
#include <stdint.h>
#include "platform.h"
#include "frame_check_sequence.h"
#include "stl/iterator.h"
#include "private/crc16_poly_0x8005.h"
#if defined(ETL_COMPILER_KEIL)
#pragma diag_suppress 1300
@ -47,77 +43,7 @@ SOFTWARE.
namespace etl
{
//***************************************************************************
/// CRC16 policy.
/// Calculates CRC16 using polynomial 0x8005.
//***************************************************************************
struct crc_policy_16
{
typedef uint16_t value_type;
inline uint16_t initial() const
{
return 0;
}
inline uint16_t add(uint16_t crc, uint8_t value) const
{
const uint16_t CRC16[256] =
{
0x0000, 0xC0C1, 0xC181, 0x0140, 0xC301, 0x03C0, 0x0280, 0xC241, 0xC601, 0x06C0, 0x0780, 0xC741, 0x0500, 0xC5C1, 0xC481, 0x0440,
0xCC01, 0x0CC0, 0x0D80, 0xCD41, 0x0F00, 0xCFC1, 0xCE81, 0x0E40, 0x0A00, 0xCAC1, 0xCB81, 0x0B40, 0xC901, 0x09C0, 0x0880, 0xC841,
0xD801, 0x18C0, 0x1980, 0xD941, 0x1B00, 0xDBC1, 0xDA81, 0x1A40, 0x1E00, 0xDEC1, 0xDF81, 0x1F40, 0xDD01, 0x1DC0, 0x1C80, 0xDC41,
0x1400, 0xD4C1, 0xD581, 0x1540, 0xD701, 0x17C0, 0x1680, 0xD641, 0xD201, 0x12C0, 0x1380, 0xD341, 0x1100, 0xD1C1, 0xD081, 0x1040,
0xF001, 0x30C0, 0x3180, 0xF141, 0x3300, 0xF3C1, 0xF281, 0x3240, 0x3600, 0xF6C1, 0xF781, 0x3740, 0xF501, 0x35C0, 0x3480, 0xF441,
0x3C00, 0xFCC1, 0xFD81, 0x3D40, 0xFF01, 0x3FC0, 0x3E80, 0xFE41, 0xFA01, 0x3AC0, 0x3B80, 0xFB41, 0x3900, 0xF9C1, 0xF881, 0x3840,
0x2800, 0xE8C1, 0xE981, 0x2940, 0xEB01, 0x2BC0, 0x2A80, 0xEA41, 0xEE01, 0x2EC0, 0x2F80, 0xEF41, 0x2D00, 0xEDC1, 0xEC81, 0x2C40,
0xE401, 0x24C0, 0x2580, 0xE541, 0x2700, 0xE7C1, 0xE681, 0x2640, 0x2200, 0xE2C1, 0xE381, 0x2340, 0xE101, 0x21C0, 0x2080, 0xE041,
0xA001, 0x60C0, 0x6180, 0xA141, 0x6300, 0xA3C1, 0xA281, 0x6240, 0x6600, 0xA6C1, 0xA781, 0x6740, 0xA501, 0x65C0, 0x6480, 0xA441,
0x6C00, 0xACC1, 0xAD81, 0x6D40, 0xAF01, 0x6FC0, 0x6E80, 0xAE41, 0xAA01, 0x6AC0, 0x6B80, 0xAB41, 0x6900, 0xA9C1, 0xA881, 0x6840,
0x7800, 0xB8C1, 0xB981, 0x7940, 0xBB01, 0x7BC0, 0x7A80, 0xBA41, 0xBE01, 0x7EC0, 0x7F80, 0xBF41, 0x7D00, 0xBDC1, 0xBC81, 0x7C40,
0xB401, 0x74C0, 0x7580, 0xB541, 0x7700, 0xB7C1, 0xB681, 0x7640, 0x7200, 0xB2C1, 0xB381, 0x7340, 0xB101, 0x71C0, 0x7080, 0xB041,
0x5000, 0x90C1, 0x9181, 0x5140, 0x9301, 0x53C0, 0x5280, 0x9241, 0x9601, 0x56C0, 0x5780, 0x9741, 0x5500, 0x95C1, 0x9481, 0x5440,
0x9C01, 0x5CC0, 0x5D80, 0x9D41, 0x5F00, 0x9FC1, 0x9E81, 0x5E40, 0x5A00, 0x9AC1, 0x9B81, 0x5B40, 0x9901, 0x59C0, 0x5880, 0x9841,
0x8801, 0x48C0, 0x4980, 0x8941, 0x4B00, 0x8BC1, 0x8A81, 0x4A40, 0x4E00, 0x8EC1, 0x8F81, 0x4F40, 0x8D01, 0x4DC0, 0x4C80, 0x8C41,
0x4400, 0x84C1, 0x8581, 0x4540, 0x8701, 0x47C0, 0x4680, 0x8641, 0x8201, 0x42C0, 0x4380, 0x8341, 0x4100, 0x81C1, 0x8081, 0x4040
};
return (crc >> 8) ^ CRC16[(crc ^ value) & 0xFF];
}
inline uint16_t final(uint16_t crc) const
{
return crc;
}
};
//*************************************************************************
/// CRC16
//*************************************************************************
class crc16 : public etl::frame_check_sequence<etl::crc_policy_16>
{
public:
//*************************************************************************
/// Default constructor.
//*************************************************************************
crc16()
{
this->reset();
}
//*************************************************************************
/// Constructor from range.
/// \param begin Start of the range.
/// \param end End of the range.
//*************************************************************************
template<typename TIterator>
crc16(TIterator begin, const TIterator end)
{
this->reset();
this->add(begin, end);
}
};
typedef crc16_poly_0x8005<0x0000U, 0x0000U, true> crc16;
}
#endif

View File

@ -0,0 +1,49 @@
///\file
/******************************************************************************
The MIT License(MIT)
Embedded Template Library.
https://github.com/ETLCPP/etl
https://www.etlcpp.com
Copyright(c) 2019 jwellbelove
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files(the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions :
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
******************************************************************************/
#ifndef ETL_CRC16_AUG_CCITT_INCLUDED
#define ETL_CRC16_AUG_CCITT_INCLUDED
#include "platform.h"
#include "private/crc16_poly_0x1021_.h"
#if defined(ETL_COMPILER_KEIL)
#pragma diag_suppress 1300
#endif
///\defgroup crc16_aug_ccitt 16 bit CRC AUG CCITT calculation
///\ingroup crc
namespace etl
{
typedef crc16_poly_0x1021<0x1D0FU, 0x0000U, false> crc16_aug_ccitt;
}
#endif

View File

@ -34,9 +34,7 @@ SOFTWARE.
#include <stdint.h>
#include "platform.h"
#include "frame_check_sequence.h"
#include "stl/iterator.h"
#include "private/crc16_poly_0x1021_.h"
#if defined(ETL_COMPILER_KEIL)
#pragma diag_suppress 1300
@ -47,77 +45,7 @@ SOFTWARE.
namespace etl
{
//***************************************************************************
/// CRC16 CCITT policy.
/// Calculates CRC16 CCITT using polynomial 0x1021
//***************************************************************************
struct crc_policy_16_ccitt
{
typedef uint16_t value_type;
inline uint16_t initial() const
{
return 0xFFFF;
}
inline uint16_t add(uint16_t crc, uint8_t value) const
{
static const uint16_t CRC_CCITT[] =
{
0x0000, 0x1021, 0x2042, 0x3063, 0x4084, 0x50A5, 0x60C6, 0x70E7, 0x8108, 0x9129, 0xA14A, 0xB16B, 0xC18C, 0xD1AD, 0xE1CE, 0xF1EF,
0x1231, 0x0210, 0x3273, 0x2252, 0x52B5, 0x4294, 0x72F7, 0x62D6, 0x9339, 0x8318, 0xB37B, 0xA35A, 0xD3BD, 0xC39C, 0xF3FF, 0xE3DE,
0x2462, 0x3443, 0x0420, 0x1401, 0x64E6, 0x74C7, 0x44A4, 0x5485, 0xA56A, 0xB54B, 0x8528, 0x9509, 0xE5EE, 0xF5CF, 0xC5AC, 0xD58D,
0x3653, 0x2672, 0x1611, 0x0630, 0x76D7, 0x66F6, 0x5695, 0x46B4, 0xB75B, 0xA77A, 0x9719, 0x8738, 0xF7DF, 0xE7FE, 0xD79D, 0xC7BC,
0x48C4, 0x58E5, 0x6886, 0x78A7, 0x0840, 0x1861, 0x2802, 0x3823, 0xC9CC, 0xD9ED, 0xE98E, 0xF9AF, 0x8948, 0x9969, 0xA90A, 0xB92B,
0x5AF5, 0x4AD4, 0x7AB7, 0x6A96, 0x1A71, 0x0A50, 0x3A33, 0x2A12, 0xDBFD, 0xCBDC, 0xFBBF, 0xEB9E, 0x9B79, 0x8B58, 0xBB3B, 0xAB1A,
0x6CA6, 0x7C87, 0x4CE4, 0x5CC5, 0x2C22, 0x3C03, 0x0C60, 0x1C41, 0xEDAE, 0xFD8F, 0xCDEC, 0xDDCD, 0xAD2A, 0xBD0B, 0x8D68, 0x9D49,
0x7E97, 0x6EB6, 0x5ED5, 0x4EF4, 0x3E13, 0x2E32, 0x1E51, 0x0E70, 0xFF9F, 0xEFBE, 0xDFDD, 0xCFFC, 0xBF1B, 0xAF3A, 0x9F59, 0x8F78,
0x9188, 0x81A9, 0xB1CA, 0xA1EB, 0xD10C, 0xC12D, 0xF14E, 0xE16F, 0x1080, 0x00A1, 0x30C2, 0x20E3, 0x5004, 0x4025, 0x7046, 0x6067,
0x83B9, 0x9398, 0xA3FB, 0xB3DA, 0xC33D, 0xD31C, 0xE37F, 0xF35E, 0x02B1, 0x1290, 0x22F3, 0x32D2, 0x4235, 0x5214, 0x6277, 0x7256,
0xB5EA, 0xA5CB, 0x95A8, 0x8589, 0xF56E, 0xE54F, 0xD52C, 0xC50D, 0x34E2, 0x24C3, 0x14A0, 0x0481, 0x7466, 0x6447, 0x5424, 0x4405,
0xA7DB, 0xB7FA, 0x8799, 0x97B8, 0xE75F, 0xF77E, 0xC71D, 0xD73C, 0x26D3, 0x36F2, 0x0691, 0x16B0, 0x6657, 0x7676, 0x4615, 0x5634,
0xD94C, 0xC96D, 0xF90E, 0xE92F, 0x99C8, 0x89E9, 0xB98A, 0xA9AB, 0x5844, 0x4865, 0x7806, 0x6827, 0x18C0, 0x08E1, 0x3882, 0x28A3,
0xCB7D, 0xDB5C, 0xEB3F, 0xFB1E, 0x8BF9, 0x9BD8, 0xABBB, 0xBB9A, 0x4A75, 0x5A54, 0x6A37, 0x7A16, 0x0AF1, 0x1AD0, 0x2AB3, 0x3A92,
0xFD2E, 0xED0F, 0xDD6C, 0xCD4D, 0xBDAA, 0xAD8B, 0x9DE8, 0x8DC9, 0x7C26, 0x6C07, 0x5C64, 0x4C45, 0x3CA2, 0x2C83, 0x1CE0, 0x0CC1,
0xEF1F, 0xFF3E, 0xCF5D, 0xDF7C, 0xAF9B, 0xBFBA, 0x8FD9, 0x9FF8, 0x6E17, 0x7E36, 0x4E55, 0x5E74, 0x2E93, 0x3EB2, 0x0ED1, 0x1EF0
};
return (crc << 8) ^ CRC_CCITT[((crc >> 8) ^ value) & 0xFF];
}
inline uint16_t final(uint16_t crc) const
{
return crc;
}
};
//*************************************************************************
/// CRC16 CCITT
//*************************************************************************
class crc16_ccitt : public etl::frame_check_sequence<etl::crc_policy_16_ccitt>
{
public:
//*************************************************************************
/// Default constructor.
//*************************************************************************
crc16_ccitt()
{
this->reset();
}
//*************************************************************************
/// Constructor from range.
/// \param begin Start of the range.
/// \param end End of the range.
//*************************************************************************
template<typename TIterator>
crc16_ccitt(TIterator begin, const TIterator end)
{
this->reset();
this->add(begin, end);
}
};
typedef crc16_poly_0x1021<0xFFFFU, 0x0000U, false> crc16_ccitt;
}
#endif

View File

@ -0,0 +1,49 @@
///\file
/******************************************************************************
The MIT License(MIT)
Embedded Template Library.
https://github.com/ETLCPP/etl
https://www.etlcpp.com
Copyright(c) 2019 jwellbelove
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files(the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions :
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
******************************************************************************/
#ifndef ETL_CRC16_GENIBUS_INCLUDED
#define ETL_CRC16_GENIBUS_INCLUDED
#include "platform.h"
#include "private/crc16_poly_0x1021_.h"
#if defined(ETL_COMPILER_KEIL)
#pragma diag_suppress 1300
#endif
///\defgroup crc16_aug_ccitt 16 bit CRC GENIBUS calculation
///\ingroup crc
namespace etl
{
typedef crc16_poly_0x1021<0xFFFFU, 0xFFFFU, false> crc16_genibus;
}
#endif

View File

@ -34,9 +34,7 @@ SOFTWARE.
#include <stdint.h>
#include "platform.h"
#include "frame_check_sequence.h"
#include "stl/iterator.h"
#include "private/crc16_poly_0x1021_.h"
#if defined(ETL_COMPILER_KEIL)
#pragma diag_suppress 1300
@ -47,77 +45,7 @@ SOFTWARE.
namespace etl
{
//***************************************************************************
/// CRC16 Kermit policy.
/// Calculates CRC16 Kermit using polynomial 0x1021
//***************************************************************************
struct crc_policy_16_kermit
{
typedef uint16_t value_type;
inline uint16_t initial() const
{
return 0;
}
inline uint16_t add(uint16_t crc, uint8_t value) const
{
static const uint16_t CRC_KERMIT[] =
{
0x0000, 0x1189, 0x2312, 0x329B, 0x4624, 0x57AD, 0x6536, 0x74BF, 0x8C48, 0x9DC1, 0xAF5A, 0xBED3, 0xCA6C, 0xDBE5, 0xE97E, 0xF8F7,
0x1081, 0x0108, 0x3393, 0x221A, 0x56A5, 0x472C, 0x75B7, 0x643E, 0x9CC9, 0x8D40, 0xBFDB, 0xAE52, 0xDAED, 0xCB64, 0xF9FF, 0xE876,
0x2102, 0x308B, 0x0210, 0x1399, 0x6726, 0x76AF, 0x4434, 0x55BD, 0xAD4A, 0xBCC3, 0x8E58, 0x9FD1, 0xEB6E, 0xFAE7, 0xC87C, 0xD9F5,
0x3183, 0x200A, 0x1291, 0x0318, 0x77A7, 0x662E, 0x54B5, 0x453C, 0xBDCB, 0xAC42, 0x9ED9, 0x8F50, 0xFBEF, 0xEA66, 0xD8FD, 0xC974,
0x4204, 0x538D, 0x6116, 0x709F, 0x0420, 0x15A9, 0x2732, 0x36BB, 0xCE4C, 0xDFC5, 0xED5E, 0xFCD7, 0x8868, 0x99E1, 0xAB7A, 0xBAF3,
0x5285, 0x430C, 0x7197, 0x601E, 0x14A1, 0x0528, 0x37B3, 0x263A, 0xDECD, 0xCF44, 0xFDDF, 0xEC56, 0x98E9, 0x8960, 0xBBFB, 0xAA72,
0x6306, 0x728F, 0x4014, 0x519D, 0x2522, 0x34AB, 0x0630, 0x17B9, 0xEF4E, 0xFEC7, 0xCC5C, 0xDDD5, 0xA96A, 0xB8E3, 0x8A78, 0x9BF1,
0x7387, 0x620E, 0x5095, 0x411C, 0x35A3, 0x242A, 0x16B1, 0x0738, 0xFFCF, 0xEE46, 0xDCDD, 0xCD54, 0xB9EB, 0xA862, 0x9AF9, 0x8B70,
0x8408, 0x9581, 0xA71A, 0xB693, 0xC22C, 0xD3A5, 0xE13E, 0xF0B7, 0x0840, 0x19C9, 0x2B52, 0x3ADB, 0x4E64, 0x5FED, 0x6D76, 0x7CFF,
0x9489, 0x8500, 0xB79B, 0xA612, 0xD2AD, 0xC324, 0xF1BF, 0xE036, 0x18C1, 0x0948, 0x3BD3, 0x2A5A, 0x5EE5, 0x4F6C, 0x7DF7, 0x6C7E,
0xA50A, 0xB483, 0x8618, 0x9791, 0xE32E, 0xF2A7, 0xC03C, 0xD1B5, 0x2942, 0x38CB, 0x0A50, 0x1BD9, 0x6F66, 0x7EEF, 0x4C74, 0x5DFD,
0xB58B, 0xA402, 0x9699, 0x8710, 0xF3AF, 0xE226, 0xD0BD, 0xC134, 0x39C3, 0x284A, 0x1AD1, 0x0B58, 0x7FE7, 0x6E6E, 0x5CF5, 0x4D7C,
0xC60C, 0xD785, 0xE51E, 0xF497, 0x8028, 0x91A1, 0xA33A, 0xB2B3, 0x4A44, 0x5BCD, 0x6956, 0x78DF, 0x0C60, 0x1DE9, 0x2F72, 0x3EFB,
0xD68D, 0xC704, 0xF59F, 0xE416, 0x90A9, 0x8120, 0xB3BB, 0xA232, 0x5AC5, 0x4B4C, 0x79D7, 0x685E, 0x1CE1, 0x0D68, 0x3FF3, 0x2E7A,
0xE70E, 0xF687, 0xC41C, 0xD595, 0xA12A, 0xB0A3, 0x8238, 0x93B1, 0x6B46, 0x7ACF, 0x4854, 0x59DD, 0x2D62, 0x3CEB, 0x0E70, 0x1FF9,
0xF78F, 0xE606, 0xD49D, 0xC514, 0xB1AB, 0xA022, 0x92B9, 0x8330, 0x7BC7, 0x6A4E, 0x58D5, 0x495C, 0x3DE3, 0x2C6A, 0x1EF1, 0x0F78
};
return (crc >> 8) ^ CRC_KERMIT[(crc ^ value) & 0xFF];
}
inline uint16_t final(uint16_t crc) const
{
return crc;
}
};
//*************************************************************************
/// CRC16 Kermit
//*************************************************************************
class crc16_kermit : public etl::frame_check_sequence<etl::crc_policy_16_kermit>
{
public:
//*************************************************************************
/// Default constructor.
//*************************************************************************
crc16_kermit()
{
this->reset();
}
//*************************************************************************
/// Constructor from range.
/// \param begin Start of the range.
/// \param end End of the range.
//*************************************************************************
template<typename TIterator>
crc16_kermit(TIterator begin, const TIterator end)
{
this->reset();
this->add(begin, end);
}
};
typedef crc16_poly_0x1021<0x0000U, 0x0000U, true> crc16_kermit;
}
#endif

View File

@ -34,9 +34,7 @@ SOFTWARE.
#include <stdint.h>
#include "platform.h"
#include "frame_check_sequence.h"
#include "stl/iterator.h"
#include "private/crc16_poly_0x8005.h"
#if defined(ETL_COMPILER_KEIL)
#pragma diag_suppress 1300
@ -47,93 +45,7 @@ SOFTWARE.
namespace etl
{
//***************************************************************************
/// CRC16 MODBUS policy.
/// Calculates CRC16 MODBUS using polynomial 0x
//***************************************************************************
struct crc_policy_16_modbus
{
typedef uint16_t value_type;
inline uint16_t initial() const
{
return 0xFFFF;
}
inline uint16_t add(uint16_t crc, uint8_t value) const
{
static const uint16_t ETL_CRC_MODBUS[] =
{
0x0000, 0xC0C1, 0xC181, 0x0140, 0xC301, 0x03C0, 0x0280, 0xC241,
0xC601, 0x06C0, 0x0780, 0xC741, 0x0500, 0xC5C1, 0xC481, 0x0440,
0xCC01, 0x0CC0, 0x0D80, 0xCD41, 0x0F00, 0xCFC1, 0xCE81, 0x0E40,
0x0A00, 0xCAC1, 0xCB81, 0x0B40, 0xC901, 0x09C0, 0x0880, 0xC841,
0xD801, 0x18C0, 0x1980, 0xD941, 0x1B00, 0xDBC1, 0xDA81, 0x1A40,
0x1E00, 0xDEC1, 0xDF81, 0x1F40, 0xDD01, 0x1DC0, 0x1C80, 0xDC41,
0x1400, 0xD4C1, 0xD581, 0x1540, 0xD701, 0x17C0, 0x1680, 0xD641,
0xD201, 0x12C0, 0x1380, 0xD341, 0x1100, 0xD1C1, 0xD081, 0x1040,
0xF001, 0x30C0, 0x3180, 0xF141, 0x3300, 0xF3C1, 0xF281, 0x3240,
0x3600, 0xF6C1, 0xF781, 0x3740, 0xF501, 0x35C0, 0x3480, 0xF441,
0x3C00, 0xFCC1, 0xFD81, 0x3D40, 0xFF01, 0x3FC0, 0x3E80, 0xFE41,
0xFA01, 0x3AC0, 0x3B80, 0xFB41, 0x3900, 0xF9C1, 0xF881, 0x3840,
0x2800, 0xE8C1, 0xE981, 0x2940, 0xEB01, 0x2BC0, 0x2A80, 0xEA41,
0xEE01, 0x2EC0, 0x2F80, 0xEF41, 0x2D00, 0xEDC1, 0xEC81, 0x2C40,
0xE401, 0x24C0, 0x2580, 0xE541, 0x2700, 0xE7C1, 0xE681, 0x2640,
0x2200, 0xE2C1, 0xE381, 0x2340, 0xE101, 0x21C0, 0x2080, 0xE041,
0xA001, 0x60C0, 0x6180, 0xA141, 0x6300, 0xA3C1, 0xA281, 0x6240,
0x6600, 0xA6C1, 0xA781, 0x6740, 0xA501, 0x65C0, 0x6480, 0xA441,
0x6C00, 0xACC1, 0xAD81, 0x6D40, 0xAF01, 0x6FC0, 0x6E80, 0xAE41,
0xAA01, 0x6AC0, 0x6B80, 0xAB41, 0x6900, 0xA9C1, 0xA881, 0x6840,
0x7800, 0xB8C1, 0xB981, 0x7940, 0xBB01, 0x7BC0, 0x7A80, 0xBA41,
0xBE01, 0x7EC0, 0x7F80, 0xBF41, 0x7D00, 0xBDC1, 0xBC81, 0x7C40,
0xB401, 0x74C0, 0x7580, 0xB541, 0x7700, 0xB7C1, 0xB681, 0x7640,
0x7200, 0xB2C1, 0xB381, 0x7340, 0xB101, 0x71C0, 0x7080, 0xB041,
0x5000, 0x90C1, 0x9181, 0x5140, 0x9301, 0x53C0, 0x5280, 0x9241,
0x9601, 0x56C0, 0x5780, 0x9741, 0x5500, 0x95C1, 0x9481, 0x5440,
0x9C01, 0x5CC0, 0x5D80, 0x9D41, 0x5F00, 0x9FC1, 0x9E81, 0x5E40,
0x5A00, 0x9AC1, 0x9B81, 0x5B40, 0x9901, 0x59C0, 0x5880, 0x9841,
0x8801, 0x48C0, 0x4980, 0x8941, 0x4B00, 0x8BC1, 0x8A81, 0x4A40,
0x4E00, 0x8EC1, 0x8F81, 0x4F40, 0x8D01, 0x4DC0, 0x4C80, 0x8C41,
0x4400, 0x84C1, 0x8581, 0x4540, 0x8701, 0x47C0, 0x4680, 0x8641,
0x8201, 0x42C0, 0x4380, 0x8341, 0x4100, 0x81C1, 0x8081, 0x4040
};
return (crc >> 8) ^ ETL_CRC_MODBUS[(crc ^ value) & 0xFF];
}
inline uint16_t final(uint16_t crc) const
{
return crc;
}
};
//*************************************************************************
/// CRC16 MODBUS
//*************************************************************************
class crc16_modbus : public etl::frame_check_sequence<etl::crc_policy_16_modbus>
{
public:
//*************************************************************************
/// Default constructor.
//*************************************************************************
crc16_modbus()
{
this->reset();
}
//*************************************************************************
/// Constructor from range.
/// \param begin Start of the range.
/// \param end End of the range.
//*************************************************************************
template<typename TIterator>
crc16_modbus(TIterator begin, const TIterator end)
{
this->reset();
this->add(begin, end);
}
};
typedef crc16_poly_0x8005<0xFFFFU, 0x0000U, true> crc16_modbus;
}
#endif

51
include/etl/crc16_usb.h Normal file
View File

@ -0,0 +1,51 @@
///\file
/******************************************************************************
The MIT License(MIT)
Embedded Template Library.
https://github.com/ETLCPP/etl
https://www.etlcpp.com
Copyright(c) 2018 jwellbelove
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files(the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions :
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
******************************************************************************/
#ifndef ETL_CRC16_USB_INCLUDED
#define ETL_CRC16_USB_INCLUDED
#include <stdint.h>
#include "platform.h"
#include "private/crc16_poly_0x8005.h"
#if defined(ETL_COMPILER_KEIL)
#pragma diag_suppress 1300
#endif
///\defgroup crc16_modbus 16 bit CRC USB calculation
///\ingroup crc
namespace etl
{
typedef crc16_poly_0x8005<0xFFFFU, 0xFFFFU, true> crc16_usb;
}
#endif

49
include/etl/crc16_x25.h Normal file
View File

@ -0,0 +1,49 @@
///\file
/******************************************************************************
The MIT License(MIT)
Embedded Template Library.
https://github.com/ETLCPP/etl
https://www.etlcpp.com
Copyright(c) 2019 jwellbelove
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files(the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions :
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
******************************************************************************/
#ifndef ETL_CRC16_X25_INCLUDED
#define ETL_CRC16_X25_INCLUDED
#include "platform.h"
#include "private/crc16_poly_0x1021_.h"
#if defined(ETL_COMPILER_KEIL)
#pragma diag_suppress 1300
#endif
///\defgroup crc16_aug_ccitt 16 bit CRC X25 calculation
///\ingroup crc
namespace etl
{
typedef crc16_poly_0x1021<0xFFFFU, 0xFFFFU, true> crc16_x25;
}
#endif

View File

@ -0,0 +1,49 @@
///\file
/******************************************************************************
The MIT License(MIT)
Embedded Template Library.
https://github.com/ETLCPP/etl
https://www.etlcpp.com
Copyright(c) 2019 jwellbelove
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files(the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions :
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
******************************************************************************/
#ifndef ETL_CRC16_XMODEM_INCLUDED
#define ETL_CRC16_XMODEM_INCLUDED
#include "platform.h"
#include "private/crc16_poly_0x1021_.h"
#if defined(ETL_COMPILER_KEIL)
#pragma diag_suppress 1300
#endif
///\defgroup crc16_xmodem 16 bit CRC XMODEM calculation
///\ingroup crc
namespace etl
{
typedef crc16_poly_0x1021<0x0000U, 0x0000U, false> crc16_xmodem;
}
#endif

View File

@ -31,12 +31,8 @@ SOFTWARE.
#ifndef ETL_CRC32_INCLUDED
#define ETL_CRC32_INCLUDED
#include <stdint.h>
#include "platform.h"
#include "frame_check_sequence.h"
#include "stl/iterator.h"
#include "private/crc32_poly_0x04c11db7.h"
#if defined(ETL_COMPILER_KEIL)
#pragma diag_suppress 1300
@ -47,93 +43,7 @@ SOFTWARE.
namespace etl
{
//***************************************************************************
/// CRC32 policy.
/// Calculates CRC32 using polynomial 0x04C11DB7.
//***************************************************************************
struct crc_policy_32
{
typedef uint32_t value_type;
inline uint32_t initial() const
{
return 0xFFFFFFFF;
}
inline uint32_t add(uint32_t crc, uint8_t value) const
{
static const uint32_t CRC32[] =
{
0x00000000, 0x77073096, 0xEE0E612C, 0x990951BA, 0x076DC419, 0x706AF48F, 0xE963A535, 0x9E6495A3,
0x0EDB8832, 0x79DCB8A4, 0xE0D5E91E, 0x97D2D988, 0x09B64C2B, 0x7EB17CBD, 0xE7B82D07, 0x90BF1D91,
0x1DB71064, 0x6AB020F2, 0xF3B97148, 0x84BE41DE, 0x1ADAD47D, 0x6DDDE4EB, 0xF4D4B551, 0x83D385C7,
0x136C9856, 0x646BA8C0, 0xFD62F97A, 0x8A65C9EC, 0x14015C4F, 0x63066CD9, 0xFA0F3D63, 0x8D080DF5,
0x3B6E20C8, 0x4C69105E, 0xD56041E4, 0xA2677172, 0x3C03E4D1, 0x4B04D447, 0xD20D85FD, 0xA50AB56B,
0x35B5A8FA, 0x42B2986C, 0xDBBBC9D6, 0xACBCF940, 0x32D86CE3, 0x45DF5C75, 0xDCD60DCF, 0xABD13D59,
0x26D930AC, 0x51DE003A, 0xC8D75180, 0xBFD06116, 0x21B4F4B5, 0x56B3C423, 0xCFBA9599, 0xB8BDA50F,
0x2802B89E, 0x5F058808, 0xC60CD9B2, 0xB10BE924, 0x2F6F7C87, 0x58684C11, 0xC1611DAB, 0xB6662D3D,
0x76DC4190, 0x01DB7106, 0x98D220BC, 0xEFD5102A, 0x71B18589, 0x06B6B51F, 0x9FBFE4A5, 0xE8B8D433,
0x7807C9A2, 0x0F00F934, 0x9609A88E, 0xE10E9818, 0x7F6A0DBB, 0x086D3D2D, 0x91646C97, 0xE6635C01,
0x6B6B51F4, 0x1C6C6162, 0x856530D8, 0xF262004E, 0x6C0695ED, 0x1B01A57B, 0x8208F4C1, 0xF50FC457,
0x65B0D9C6, 0x12B7E950, 0x8BBEB8EA, 0xFCB9887C, 0x62DD1DDF, 0x15DA2D49, 0x8CD37CF3, 0xFBD44C65,
0x4DB26158, 0x3AB551CE, 0xA3BC0074, 0xD4BB30E2, 0x4ADFA541, 0x3DD895D7, 0xA4D1C46D, 0xD3D6F4FB,
0x4369E96A, 0x346ED9FC, 0xAD678846, 0xDA60B8D0, 0x44042D73, 0x33031DE5, 0xAA0A4C5F, 0xDD0D7CC9,
0x5005713C, 0x270241AA, 0xBE0B1010, 0xC90C2086, 0x5768B525, 0x206F85B3, 0xB966D409, 0xCE61E49F,
0x5EDEF90E, 0x29D9C998, 0xB0D09822, 0xC7D7A8B4, 0x59B33D17, 0x2EB40D81, 0xB7BD5C3B, 0xC0BA6CAD,
0xEDB88320, 0x9ABFB3B6, 0x03B6E20C, 0x74B1D29A, 0xEAD54739, 0x9DD277AF, 0x04DB2615, 0x73DC1683,
0xE3630B12, 0x94643B84, 0x0D6D6A3E, 0x7A6A5AA8, 0xE40ECF0B, 0x9309FF9D, 0x0A00AE27, 0x7D079EB1,
0xF00F9344, 0x8708A3D2, 0x1E01F268, 0x6906C2FE, 0xF762575D, 0x806567CB, 0x196C3671, 0x6E6B06E7,
0xFED41B76, 0x89D32BE0, 0x10DA7A5A, 0x67DD4ACC, 0xF9B9DF6F, 0x8EBEEFF9, 0x17B7BE43, 0x60B08ED5,
0xD6D6A3E8, 0xA1D1937E, 0x38D8C2C4, 0x4FDFF252, 0xD1BB67F1, 0xA6BC5767, 0x3FB506DD, 0x48B2364B,
0xD80D2BDA, 0xAF0A1B4C, 0x36034AF6, 0x41047A60, 0xDF60EFC3, 0xA867DF55, 0x316E8EEF, 0x4669BE79,
0xCB61B38C, 0xBC66831A, 0x256FD2A0, 0x5268E236, 0xCC0C7795, 0xBB0B4703, 0x220216B9, 0x5505262F,
0xC5BA3BBE, 0xB2BD0B28, 0x2BB45A92, 0x5CB36A04, 0xC2D7FFA7, 0xB5D0CF31, 0x2CD99E8B, 0x5BDEAE1D,
0x9B64C2B0, 0xEC63F226, 0x756AA39C, 0x026D930A, 0x9C0906A9, 0xEB0E363F, 0x72076785, 0x05005713,
0x95BF4A82, 0xE2B87A14, 0x7BB12BAE, 0x0CB61B38, 0x92D28E9B, 0xE5D5BE0D, 0x7CDCEFB7, 0x0BDBDF21,
0x86D3D2D4, 0xF1D4E242, 0x68DDB3F8, 0x1FDA836E, 0x81BE16CD, 0xF6B9265B, 0x6FB077E1, 0x18B74777,
0x88085AE6, 0xFF0F6A70, 0x66063BCA, 0x11010B5C, 0x8F659EFF, 0xF862AE69, 0x616BFFD3, 0x166CCF45,
0xA00AE278, 0xD70DD2EE, 0x4E048354, 0x3903B3C2, 0xA7672661, 0xD06016F7, 0x4969474D, 0x3E6E77DB,
0xAED16A4A, 0xD9D65ADC, 0x40DF0B66, 0x37D83BF0, 0xA9BCAE53, 0xDEBB9EC5, 0x47B2CF7F, 0x30B5FFE9,
0xBDBDF21C, 0xCABAC28A, 0x53B39330, 0x24B4A3A6, 0xBAD03605, 0xCDD70693, 0x54DE5729, 0x23D967BF,
0xB3667A2E, 0xC4614AB8, 0x5D681B02, 0x2A6F2B94, 0xB40BBE37, 0xC30C8EA1, 0x5A05DF1B, 0x2D02EF8D
};
return (crc >> 8) ^ CRC32[(crc ^ value) & 0xFF];
}
inline uint32_t final(uint32_t crc) const
{
return crc ^ 0xFFFFFFFF;
}
};
//*************************************************************************
/// CRC32
//*************************************************************************
class crc32 : public etl::frame_check_sequence<etl::crc_policy_32>
{
public:
//*************************************************************************
/// Default constructor.
//*************************************************************************
crc32()
{
this->reset();
}
//*************************************************************************
/// Constructor from range.
/// \param begin Start of the range.
/// \param end End of the range.
//*************************************************************************
template<typename TIterator>
crc32(TIterator begin, const TIterator end)
{
this->reset();
this->add(begin, end);
}
};
typedef crc32_poly_0x04c11db7<0xFFFFFFFFU, 0xFFFFFFFFU, true> crc32;
}
#endif

49
include/etl/crc32_bzip2.h Normal file
View File

@ -0,0 +1,49 @@
///\file
/******************************************************************************
The MIT License(MIT)
Embedded Template Library.
https://github.com/ETLCPP/etl
https://www.etlcpp.com
Copyright(c) 2019 jwellbelove
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files(the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions :
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
******************************************************************************/
#ifndef ETL_CRC32_BZIP2_INCLUDED
#define ETL_CRC32_BZIP2_INCLUDED
#include "platform.h"
#include "private/crc32_poly_0x04c11db7.h"
#if defined(ETL_COMPILER_KEIL)
#pragma diag_suppress 1300
#endif
///\defgroup crc32 BZIP2 32 bit CRC calculation
///\ingroup crc
namespace etl
{
typedef crc32_poly_0x04c11db7<0xFFFFFFFFU, 0xFFFFFFFFU, false> crc32_bzip2;
}
#endif

View File

@ -31,12 +31,8 @@ SOFTWARE.
#ifndef ETL_CRC32_C_INCLUDED
#define ETL_CRC32_C_INCLUDED
#include <stdint.h>
#include "platform.h"
#include "frame_check_sequence.h"
#include "stl/iterator.h"
#include "private/crc32_poly_0x1edc6f41.h"
#if defined(ETL_COMPILER_KEIL)
#pragma diag_suppress 1300
@ -47,93 +43,7 @@ SOFTWARE.
namespace etl
{
//***************************************************************************
/// CRC32_C policy.
/// Calculates CRC32_C using polynomial 0x1EDC6F41.
//***************************************************************************
struct crc_policy_32_c
{
typedef uint32_t value_type;
inline uint32_t initial() const
{
return 0xFFFFFFFF;
}
inline uint32_t add(uint32_t crc, uint8_t value) const
{
static const uint32_t CRC32_C[] =
{
0x00000000L, 0xF26B8303L, 0xE13B70F7L, 0x1350F3F4L, 0xC79A971FL, 0x35F1141CL, 0x26A1E7E8L, 0xD4CA64EBL,
0x8AD958CFL, 0x78B2DBCCL, 0x6BE22838L, 0x9989AB3BL, 0x4D43CFD0L, 0xBF284CD3L, 0xAC78BF27L, 0x5E133C24L,
0x105EC76FL, 0xE235446CL, 0xF165B798L, 0x030E349BL, 0xD7C45070L, 0x25AFD373L, 0x36FF2087L, 0xC494A384L,
0x9A879FA0L, 0x68EC1CA3L, 0x7BBCEF57L, 0x89D76C54L, 0x5D1D08BFL, 0xAF768BBCL, 0xBC267848L, 0x4E4DFB4BL,
0x20BD8EDEL, 0xD2D60DDDL, 0xC186FE29L, 0x33ED7D2AL, 0xE72719C1L, 0x154C9AC2L, 0x061C6936L, 0xF477EA35L,
0xAA64D611L, 0x580F5512L, 0x4B5FA6E6L, 0xB93425E5L, 0x6DFE410EL, 0x9F95C20DL, 0x8CC531F9L, 0x7EAEB2FAL,
0x30E349B1L, 0xC288CAB2L, 0xD1D83946L, 0x23B3BA45L, 0xF779DEAEL, 0x05125DADL, 0x1642AE59L, 0xE4292D5AL,
0xBA3A117EL, 0x4851927DL, 0x5B016189L, 0xA96AE28AL, 0x7DA08661L, 0x8FCB0562L, 0x9C9BF696L, 0x6EF07595L,
0x417B1DBCL, 0xB3109EBFL, 0xA0406D4BL, 0x522BEE48L, 0x86E18AA3L, 0x748A09A0L, 0x67DAFA54L, 0x95B17957L,
0xCBA24573L, 0x39C9C670L, 0x2A993584L, 0xD8F2B687L, 0x0C38D26CL, 0xFE53516FL, 0xED03A29BL, 0x1F682198L,
0x5125DAD3L, 0xA34E59D0L, 0xB01EAA24L, 0x42752927L, 0x96BF4DCCL, 0x64D4CECFL, 0x77843D3BL, 0x85EFBE38L,
0xDBFC821CL, 0x2997011FL, 0x3AC7F2EBL, 0xC8AC71E8L, 0x1C661503L, 0xEE0D9600L, 0xFD5D65F4L, 0x0F36E6F7L,
0x61C69362L, 0x93AD1061L, 0x80FDE395L, 0x72966096L, 0xA65C047DL, 0x5437877EL, 0x4767748AL, 0xB50CF789L,
0xEB1FCBADL, 0x197448AEL, 0x0A24BB5AL, 0xF84F3859L, 0x2C855CB2L, 0xDEEEDFB1L, 0xCDBE2C45L, 0x3FD5AF46L,
0x7198540DL, 0x83F3D70EL, 0x90A324FAL, 0x62C8A7F9L, 0xB602C312L, 0x44694011L, 0x5739B3E5L, 0xA55230E6L,
0xFB410CC2L, 0x092A8FC1L, 0x1A7A7C35L, 0xE811FF36L, 0x3CDB9BDDL, 0xCEB018DEL, 0xDDE0EB2AL, 0x2F8B6829L,
0x82F63B78L, 0x709DB87BL, 0x63CD4B8FL, 0x91A6C88CL, 0x456CAC67L, 0xB7072F64L, 0xA457DC90L, 0x563C5F93L,
0x082F63B7L, 0xFA44E0B4L, 0xE9141340L, 0x1B7F9043L, 0xCFB5F4A8L, 0x3DDE77ABL, 0x2E8E845FL, 0xDCE5075CL,
0x92A8FC17L, 0x60C37F14L, 0x73938CE0L, 0x81F80FE3L, 0x55326B08L, 0xA759E80BL, 0xB4091BFFL, 0x466298FCL,
0x1871A4D8L, 0xEA1A27DBL, 0xF94AD42FL, 0x0B21572CL, 0xDFEB33C7L, 0x2D80B0C4L, 0x3ED04330L, 0xCCBBC033L,
0xA24BB5A6L, 0x502036A5L, 0x4370C551L, 0xB11B4652L, 0x65D122B9L, 0x97BAA1BAL, 0x84EA524EL, 0x7681D14DL,
0x2892ED69L, 0xDAF96E6AL, 0xC9A99D9EL, 0x3BC21E9DL, 0xEF087A76L, 0x1D63F975L, 0x0E330A81L, 0xFC588982L,
0xB21572C9L, 0x407EF1CAL, 0x532E023EL, 0xA145813DL, 0x758FE5D6L, 0x87E466D5L, 0x94B49521L, 0x66DF1622L,
0x38CC2A06L, 0xCAA7A905L, 0xD9F75AF1L, 0x2B9CD9F2L, 0xFF56BD19L, 0x0D3D3E1AL, 0x1E6DCDEEL, 0xEC064EEDL,
0xC38D26C4L, 0x31E6A5C7L, 0x22B65633L, 0xD0DDD530L, 0x0417B1DBL, 0xF67C32D8L, 0xE52CC12CL, 0x1747422FL,
0x49547E0BL, 0xBB3FFD08L, 0xA86F0EFCL, 0x5A048DFFL, 0x8ECEE914L, 0x7CA56A17L, 0x6FF599E3L, 0x9D9E1AE0L,
0xD3D3E1ABL, 0x21B862A8L, 0x32E8915CL, 0xC083125FL, 0x144976B4L, 0xE622F5B7L, 0xF5720643L, 0x07198540L,
0x590AB964L, 0xAB613A67L, 0xB831C993L, 0x4A5A4A90L, 0x9E902E7BL, 0x6CFBAD78L, 0x7FAB5E8CL, 0x8DC0DD8FL,
0xE330A81AL, 0x115B2B19L, 0x020BD8EDL, 0xF0605BEEL, 0x24AA3F05L, 0xD6C1BC06L, 0xC5914FF2L, 0x37FACCF1L,
0x69E9F0D5L, 0x9B8273D6L, 0x88D28022L, 0x7AB90321L, 0xAE7367CAL, 0x5C18E4C9L, 0x4F48173DL, 0xBD23943EL,
0xF36E6F75L, 0x0105EC76L, 0x12551F82L, 0xE03E9C81L, 0x34F4F86AL, 0xC69F7B69L, 0xD5CF889DL, 0x27A40B9EL,
0x79B737BAL, 0x8BDCB4B9L, 0x988C474DL, 0x6AE7C44EL, 0xBE2DA0A5L, 0x4C4623A6L, 0x5F16D052L, 0xAD7D5351L
};
return (crc >> 8) ^ CRC32_C[(crc ^ value) & 0xFF];
}
inline uint32_t final(uint32_t crc) const
{
return crc ^ 0xFFFFFFFF;
}
};
//*************************************************************************
/// CRC32_C
//*************************************************************************
class crc32_c : public etl::frame_check_sequence<etl::crc_policy_32_c>
{
public:
//*************************************************************************
/// Default constructor.
//*************************************************************************
crc32_c()
{
this->reset();
}
//*************************************************************************
/// Constructor from range.
/// \param begin Start of the range.
/// \param end End of the range.
//*************************************************************************
template<typename TIterator>
crc32_c(TIterator begin, const TIterator end)
{
this->reset();
this->add(begin, end);
}
};
typedef crc32_poly_0x1edc6f41<0xFFFFFFFFU, 0xFFFFFFFFU, true> crc32_c;
}
#endif

49
include/etl/crc32_mpeg2.h Normal file
View File

@ -0,0 +1,49 @@
///\file
/******************************************************************************
The MIT License(MIT)
Embedded Template Library.
https://github.com/ETLCPP/etl
https://www.etlcpp.com
Copyright(c) 2019 jwellbelove
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files(the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions :
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
******************************************************************************/
#ifndef ETL_CRC32_MPEG2_INCLUDED
#define ETL_CRC32_MPEG2_INCLUDED
#include "platform.h"
#include "private/crc32_poly_0x04c11db7.h"
#if defined(ETL_COMPILER_KEIL)
#pragma diag_suppress 1300
#endif
///\defgroup crc32 MPEG2 32 bit CRC calculation
///\ingroup crc
namespace etl
{
typedef crc32_poly_0x04c11db7<0xFFFFFFFFU, 0x00000000U, false> crc32_mpeg2;
}
#endif

49
include/etl/crc32_posix.h Normal file
View File

@ -0,0 +1,49 @@
///\file
/******************************************************************************
The MIT License(MIT)
Embedded Template Library.
https://github.com/ETLCPP/etl
https://www.etlcpp.com
Copyright(c) 2019 jwellbelove
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files(the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions :
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
******************************************************************************/
#ifndef ETL_CRC32_POSIX_INCLUDED
#define ETL_CRC32_POSIX_INCLUDED
#include "platform.h"
#include "private/crc32_poly_0x04c11db7.h"
#if defined(ETL_COMPILER_KEIL)
#pragma diag_suppress 1300
#endif
///\defgroup crc32 POSIX 32 bit CRC calculation
///\ingroup crc
namespace etl
{
typedef crc32_poly_0x04c11db7<0x00000000U, 0xFFFFFFFFU, false> crc32_posix;
}
#endif

View File

@ -31,12 +31,8 @@ SOFTWARE.
#ifndef ETL_CRC64_ECMA_INCLUDED
#define ETL_CRC64_ECMA_INCLUDED
#include <stdint.h>
#include "platform.h"
#include "frame_check_sequence.h"
#include "stl/iterator.h"
#include "private/crc64_poly_0x42f0e1eba9ea3693.h"
#if defined(ETL_COMPILER_KEIL)
#pragma diag_suppress 1300
@ -47,125 +43,7 @@ SOFTWARE.
namespace etl
{
//***************************************************************************
/// CRC64 policy.
/// Calculates CRC64 ECMA using polynomial 0x42F0E1EBA9EA3693.
//***************************************************************************
struct crc_policy_64_ecma
{
typedef uint64_t value_type;
inline uint64_t initial() const
{
return 0;
}
inline uint64_t add(uint64_t crc, uint8_t value) const
{
static const uint64_t CRC64_ECMA[] =
{
0x0000000000000000, 0x42F0E1EBA9EA3693, 0x85E1C3D753D46D26, 0xC711223CFA3E5BB5,
0x493366450E42ECDF, 0x0BC387AEA7A8DA4C, 0xCCD2A5925D9681F9, 0x8E224479F47CB76A,
0x9266CC8A1C85D9BE, 0xD0962D61B56FEF2D, 0x17870F5D4F51B498, 0x5577EEB6E6BB820B,
0xDB55AACF12C73561, 0x99A54B24BB2D03F2, 0x5EB4691841135847, 0x1C4488F3E8F96ED4,
0x663D78FF90E185EF, 0x24CD9914390BB37C, 0xE3DCBB28C335E8C9, 0xA12C5AC36ADFDE5A,
0x2F0E1EBA9EA36930, 0x6DFEFF5137495FA3, 0xAAEFDD6DCD770416, 0xE81F3C86649D3285,
0xF45BB4758C645C51, 0xB6AB559E258E6AC2, 0x71BA77A2DFB03177, 0x334A9649765A07E4,
0xBD68D2308226B08E, 0xFF9833DB2BCC861D, 0x388911E7D1F2DDA8, 0x7A79F00C7818EB3B,
0xCC7AF1FF21C30BDE, 0x8E8A101488293D4D, 0x499B3228721766F8, 0x0B6BD3C3DBFD506B,
0x854997BA2F81E701, 0xC7B97651866BD192, 0x00A8546D7C558A27, 0x4258B586D5BFBCB4,
0x5E1C3D753D46D260, 0x1CECDC9E94ACE4F3, 0xDBFDFEA26E92BF46, 0x990D1F49C77889D5,
0x172F5B3033043EBF, 0x55DFBADB9AEE082C, 0x92CE98E760D05399, 0xD03E790CC93A650A,
0xAA478900B1228E31, 0xE8B768EB18C8B8A2, 0x2FA64AD7E2F6E317, 0x6D56AB3C4B1CD584,
0xE374EF45BF6062EE, 0xA1840EAE168A547D, 0x66952C92ECB40FC8, 0x2465CD79455E395B,
0x3821458AADA7578F, 0x7AD1A461044D611C, 0xBDC0865DFE733AA9, 0xFF3067B657990C3A,
0x711223CFA3E5BB50, 0x33E2C2240A0F8DC3, 0xF4F3E018F031D676, 0xB60301F359DBE0E5,
0xDA050215EA6C212F, 0x98F5E3FE438617BC, 0x5FE4C1C2B9B84C09, 0x1D14202910527A9A,
0x93366450E42ECDF0, 0xD1C685BB4DC4FB63, 0x16D7A787B7FAA0D6, 0x5427466C1E109645,
0x4863CE9FF6E9F891, 0x0A932F745F03CE02, 0xCD820D48A53D95B7, 0x8F72ECA30CD7A324,
0x0150A8DAF8AB144E, 0x43A04931514122DD, 0x84B16B0DAB7F7968, 0xC6418AE602954FFB,
0xBC387AEA7A8DA4C0, 0xFEC89B01D3679253, 0x39D9B93D2959C9E6, 0x7B2958D680B3FF75,
0xF50B1CAF74CF481F, 0xB7FBFD44DD257E8C, 0x70EADF78271B2539, 0x321A3E938EF113AA,
0x2E5EB66066087D7E, 0x6CAE578BCFE24BED, 0xABBF75B735DC1058, 0xE94F945C9C3626CB,
0x676DD025684A91A1, 0x259D31CEC1A0A732, 0xE28C13F23B9EFC87, 0xA07CF2199274CA14,
0x167FF3EACBAF2AF1, 0x548F120162451C62, 0x939E303D987B47D7, 0xD16ED1D631917144,
0x5F4C95AFC5EDC62E, 0x1DBC74446C07F0BD, 0xDAAD56789639AB08, 0x985DB7933FD39D9B,
0x84193F60D72AF34F, 0xC6E9DE8B7EC0C5DC, 0x01F8FCB784FE9E69, 0x43081D5C2D14A8FA,
0xCD2A5925D9681F90, 0x8FDAB8CE70822903, 0x48CB9AF28ABC72B6, 0x0A3B7B1923564425,
0x70428B155B4EAF1E, 0x32B26AFEF2A4998D, 0xF5A348C2089AC238, 0xB753A929A170F4AB,
0x3971ED50550C43C1, 0x7B810CBBFCE67552, 0xBC902E8706D82EE7, 0xFE60CF6CAF321874,
0xE224479F47CB76A0, 0xA0D4A674EE214033, 0x67C58448141F1B86, 0x253565A3BDF52D15,
0xAB1721DA49899A7F, 0xE9E7C031E063ACEC, 0x2EF6E20D1A5DF759, 0x6C0603E6B3B7C1CA,
0xF6FAE5C07D3274CD, 0xB40A042BD4D8425E, 0x731B26172EE619EB, 0x31EBC7FC870C2F78,
0xBFC9838573709812, 0xFD39626EDA9AAE81, 0x3A28405220A4F534, 0x78D8A1B9894EC3A7,
0x649C294A61B7AD73, 0x266CC8A1C85D9BE0, 0xE17DEA9D3263C055, 0xA38D0B769B89F6C6,
0x2DAF4F0F6FF541AC, 0x6F5FAEE4C61F773F, 0xA84E8CD83C212C8A, 0xEABE6D3395CB1A19,
0x90C79D3FEDD3F122, 0xD2377CD44439C7B1, 0x15265EE8BE079C04, 0x57D6BF0317EDAA97,
0xD9F4FB7AE3911DFD, 0x9B041A914A7B2B6E, 0x5C1538ADB04570DB, 0x1EE5D94619AF4648,
0x02A151B5F156289C, 0x4051B05E58BC1E0F, 0x87409262A28245BA, 0xC5B073890B687329,
0x4B9237F0FF14C443, 0x0962D61B56FEF2D0, 0xCE73F427ACC0A965, 0x8C8315CC052A9FF6,
0x3A80143F5CF17F13, 0x7870F5D4F51B4980, 0xBF61D7E80F251235, 0xFD913603A6CF24A6,
0x73B3727A52B393CC, 0x31439391FB59A55F, 0xF652B1AD0167FEEA, 0xB4A25046A88DC879,
0xA8E6D8B54074A6AD, 0xEA16395EE99E903E, 0x2D071B6213A0CB8B, 0x6FF7FA89BA4AFD18,
0xE1D5BEF04E364A72, 0xA3255F1BE7DC7CE1, 0x64347D271DE22754, 0x26C49CCCB40811C7,
0x5CBD6CC0CC10FAFC, 0x1E4D8D2B65FACC6F, 0xD95CAF179FC497DA, 0x9BAC4EFC362EA149,
0x158E0A85C2521623, 0x577EEB6E6BB820B0, 0x906FC95291867B05, 0xD29F28B9386C4D96,
0xCEDBA04AD0952342, 0x8C2B41A1797F15D1, 0x4B3A639D83414E64, 0x09CA82762AAB78F7,
0x87E8C60FDED7CF9D, 0xC51827E4773DF90E, 0x020905D88D03A2BB, 0x40F9E43324E99428,
0x2CFFE7D5975E55E2, 0x6E0F063E3EB46371, 0xA91E2402C48A38C4, 0xEBEEC5E96D600E57,
0x65CC8190991CB93D, 0x273C607B30F68FAE, 0xE02D4247CAC8D41B, 0xA2DDA3AC6322E288,
0xBE992B5F8BDB8C5C, 0xFC69CAB42231BACF, 0x3B78E888D80FE17A, 0x7988096371E5D7E9,
0xF7AA4D1A85996083, 0xB55AACF12C735610, 0x724B8ECDD64D0DA5, 0x30BB6F267FA73B36,
0x4AC29F2A07BFD00D, 0x08327EC1AE55E69E, 0xCF235CFD546BBD2B, 0x8DD3BD16FD818BB8,
0x03F1F96F09FD3CD2, 0x41011884A0170A41, 0x86103AB85A2951F4, 0xC4E0DB53F3C36767,
0xD8A453A01B3A09B3, 0x9A54B24BB2D03F20, 0x5D45907748EE6495, 0x1FB5719CE1045206,
0x919735E51578E56C, 0xD367D40EBC92D3FF, 0x1476F63246AC884A, 0x568617D9EF46BED9,
0xE085162AB69D5E3C, 0xA275F7C11F7768AF, 0x6564D5FDE549331A, 0x279434164CA30589,
0xA9B6706FB8DFB2E3, 0xEB46918411358470, 0x2C57B3B8EB0BDFC5, 0x6EA7525342E1E956,
0x72E3DAA0AA188782, 0x30133B4B03F2B111, 0xF7021977F9CCEAA4, 0xB5F2F89C5026DC37,
0x3BD0BCE5A45A6B5D, 0x79205D0E0DB05DCE, 0xBE317F32F78E067B, 0xFCC19ED95E6430E8,
0x86B86ED5267CDBD3, 0xC4488F3E8F96ED40, 0x0359AD0275A8B6F5, 0x41A94CE9DC428066,
0xCF8B0890283E370C, 0x8D7BE97B81D4019F, 0x4A6ACB477BEA5A2A, 0x089A2AACD2006CB9,
0x14DEA25F3AF9026D, 0x562E43B4931334FE, 0x913F6188692D6F4B, 0xD3CF8063C0C759D8,
0x5DEDC41A34BBEEB2, 0x1F1D25F19D51D821, 0xD80C07CD676F8394, 0x9AFCE626CE85B507
};
return (crc << 8) ^ CRC64_ECMA[((crc >> 56) ^ value) & 0xFF];
}
inline uint64_t final(uint64_t crc) const
{
return crc;
}
};
//*************************************************************************
/// CRC64 ECMA
//*************************************************************************
class crc64_ecma : public etl::frame_check_sequence<etl::crc_policy_64_ecma>
{
public:
//*************************************************************************
/// Default constructor.
//*************************************************************************
crc64_ecma()
{
this->reset();
}
//*************************************************************************
/// Constructor from range.
/// \param begin Start of the range.
/// \param end End of the range.
//*************************************************************************
template<typename TIterator>
crc64_ecma(TIterator begin, const TIterator end)
{
this->reset();
this->add(begin, end);
}
};
typedef crc64_poly_0x42f0e1eba9ea3693<0x0000000000000000U, 0x0000000000000000U, false> crc64_ecma;
}
#endif

View File

@ -31,13 +31,8 @@ SOFTWARE.
#ifndef ETL_CRC8_CCITT_INCLUDED
#define ETL_CRC8_CCITT_INCLUDED
#include <stdint.h>
#include "platform.h"
#include "frame_check_sequence.h"
#include "stl/algorithm.h"
#include "stl/iterator.h"
#include "private/crc8_poly_0x07.h"
#if defined(ETL_COMPILER_KEIL)
#pragma diag_suppress 1300
@ -48,77 +43,7 @@ SOFTWARE.
namespace etl
{
//***************************************************************************
/// CRC8 CCITT policy.
/// Calculates CRC8 CCITT using polynomial 0x07.
//***************************************************************************
struct crc_policy_8_ccitt
{
typedef uint8_t value_type;
inline uint8_t initial() const
{
return 0;
}
inline uint8_t add(uint8_t crc, uint8_t value) const
{
static const uint8_t CRC8_CCITT[256] =
{
0x00, 0x07, 0x0E, 0x09, 0x1C, 0x1B, 0x12, 0x15, 0x38, 0x3F, 0x36, 0x31, 0x24, 0x23, 0x2A, 0x2D,
0x70, 0x77, 0x7E, 0x79, 0x6C, 0x6B, 0x62, 0x65, 0x48, 0x4F, 0x46, 0x41, 0x54, 0x53, 0x5A, 0x5D,
0xE0, 0xE7, 0xEE, 0xE9, 0xFC, 0xFB, 0xF2, 0xF5, 0xD8, 0xDF, 0xD6, 0xD1, 0xC4, 0xC3, 0xCA, 0xCD,
0x90, 0x97, 0x9E, 0x99, 0x8C, 0x8B, 0x82, 0x85, 0xA8, 0xAF, 0xA6, 0xA1, 0xB4, 0xB3, 0xBA, 0xBD,
0xC7, 0xC0, 0xC9, 0xCE, 0xDB, 0xDC, 0xD5, 0xD2, 0xFF, 0xF8, 0xF1, 0xF6, 0xE3, 0xE4, 0xED, 0xEA,
0xB7, 0xB0, 0xB9, 0xBE, 0xAB, 0xAC, 0xA5, 0xA2, 0x8F, 0x88, 0x81, 0x86, 0x93, 0x94, 0x9D, 0x9A,
0x27, 0x20, 0x29, 0x2E, 0x3B, 0x3C, 0x35, 0x32, 0x1F, 0x18, 0x11, 0x16, 0x03, 0x04, 0x0D, 0x0A,
0x57, 0x50, 0x59, 0x5E, 0x4B, 0x4C, 0x45, 0x42, 0x6F, 0x68, 0x61, 0x66, 0x73, 0x74, 0x7D, 0x7A,
0x89, 0x8E, 0x87, 0x80, 0x95, 0x92, 0x9B, 0x9C, 0xB1, 0xB6, 0xBF, 0xB8, 0xAD, 0xAA, 0xA3, 0xA4,
0xF9, 0xFE, 0xF7, 0xF0, 0xE5, 0xE2, 0xEB, 0xEC, 0xC1, 0xC6, 0xCF, 0xC8, 0xDD, 0xDA, 0xD3, 0xD4,
0x69, 0x6E, 0x67, 0x60, 0x75, 0x72, 0x7B, 0x7C, 0x51, 0x56, 0x5F, 0x58, 0x4D, 0x4A, 0x43, 0x44,
0x19, 0x1E, 0x17, 0x10, 0x05, 0x02, 0x0B, 0x0C, 0x21, 0x26, 0x2F, 0x28, 0x3D, 0x3A, 0x33, 0x34,
0x4E, 0x49, 0x40, 0x47, 0x52, 0x55, 0x5C, 0x5B, 0x76, 0x71, 0x78, 0x7F, 0x6A, 0x6D, 0x64, 0x63,
0x3E, 0x39, 0x30, 0x37, 0x22, 0x25, 0x2C, 0x2B, 0x06, 0x01, 0x08, 0x0F, 0x1A, 0x1D, 0x14, 0x13,
0xAE, 0xA9, 0xA0, 0xA7, 0xB2, 0xB5, 0xBC, 0xBB, 0x96, 0x91, 0x98, 0x9F, 0x8A, 0x8D, 0x84, 0x83,
0xDE, 0xD9, 0xD0, 0xD7, 0xC2, 0xC5, 0xCC, 0xCB, 0xE6, 0xE1, 0xE8, 0xEF, 0xFA, 0xFD, 0xF4, 0xF3
};
return CRC8_CCITT[crc ^ value];
}
inline uint8_t final(uint8_t crc) const
{
return crc;
}
};
//*************************************************************************
/// CRC8 CCITT
//*************************************************************************
class crc8_ccitt : public etl::frame_check_sequence<etl::crc_policy_8_ccitt>
{
public:
//*************************************************************************
/// Default constructor.
//*************************************************************************
crc8_ccitt()
{
this->reset();
}
//*************************************************************************
/// Constructor from range.
/// \param begin Start of the range.
/// \param end End of the range.
//*************************************************************************
template<typename TIterator>
crc8_ccitt(TIterator begin, const TIterator end)
{
this->reset();
this->add(begin, end);
}
};
typedef crc8_poly_0x07<0x00U, 0x00U, false> crc8_ccitt;
}
#endif

49
include/etl/crc8_rohc.h Normal file
View File

@ -0,0 +1,49 @@
///\file
/******************************************************************************
The MIT License(MIT)
Embedded Template Library.
https://github.com/ETLCPP/etl
https://www.etlcpp.com
Copyright(c) 2019 jwellbelove
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files(the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions :
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
******************************************************************************/
#ifndef ETL_CRC8_ROHC_INCLUDED
#define ETL_CRC8_ROHC_INCLUDED
#include "platform.h"
#include "private/crc8_poly_0x07.h"
#if defined(ETL_COMPILER_KEIL)
#pragma diag_suppress 1300
#endif
///\defgroup crc8_ccitt 8 bit CRC calculation
///\ingroup crc
namespace etl
{
typedef crc8_poly_0x07<0xFF, 0x00, true, true> crc8_rohc;
}
#endif

View File

@ -0,0 +1,212 @@
///\file
/******************************************************************************
The MIT License(MIT)
Embedded Template Library.
https://github.com/ETLCPP/etl
https://www.etlcpp.com
Copyright(c) 2019 jwellbelove
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files(the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions :
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
******************************************************************************/
#ifndef ETL_CRC16_POLY_0X1021_INCLUDED
#define ETL_CRC16_POLY_0X1021_INCLUDED
#include <stdint.h>
#include "../platform.h"
#include "../frame_check_sequence.h"
#include "../binary.h"
#include "../stl/iterator.h"
#if defined(ETL_COMPILER_KEIL)
#pragma diag_suppress 1300
#endif
///\defgroup crc16_ccitt 16 bit CRC Poly 0x1021 calculation
///\ingroup crc
namespace etl
{
//***************************************************************************
class crc16_table_poly_0x1021
{
protected:
crc16_table_poly_0x1021()
: table(get_table())
{
}
static const uint16_t * const get_table()
{
static const uint16_t table[256] =
{
0x0000, 0x1021, 0x2042, 0x3063, 0x4084, 0x50A5, 0x60C6, 0x70E7, 0x8108, 0x9129, 0xA14A, 0xB16B, 0xC18C, 0xD1AD, 0xE1CE, 0xF1EF,
0x1231, 0x0210, 0x3273, 0x2252, 0x52B5, 0x4294, 0x72F7, 0x62D6, 0x9339, 0x8318, 0xB37B, 0xA35A, 0xD3BD, 0xC39C, 0xF3FF, 0xE3DE,
0x2462, 0x3443, 0x0420, 0x1401, 0x64E6, 0x74C7, 0x44A4, 0x5485, 0xA56A, 0xB54B, 0x8528, 0x9509, 0xE5EE, 0xF5CF, 0xC5AC, 0xD58D,
0x3653, 0x2672, 0x1611, 0x0630, 0x76D7, 0x66F6, 0x5695, 0x46B4, 0xB75B, 0xA77A, 0x9719, 0x8738, 0xF7DF, 0xE7FE, 0xD79D, 0xC7BC,
0x48C4, 0x58E5, 0x6886, 0x78A7, 0x0840, 0x1861, 0x2802, 0x3823, 0xC9CC, 0xD9ED, 0xE98E, 0xF9AF, 0x8948, 0x9969, 0xA90A, 0xB92B,
0x5AF5, 0x4AD4, 0x7AB7, 0x6A96, 0x1A71, 0x0A50, 0x3A33, 0x2A12, 0xDBFD, 0xCBDC, 0xFBBF, 0xEB9E, 0x9B79, 0x8B58, 0xBB3B, 0xAB1A,
0x6CA6, 0x7C87, 0x4CE4, 0x5CC5, 0x2C22, 0x3C03, 0x0C60, 0x1C41, 0xEDAE, 0xFD8F, 0xCDEC, 0xDDCD, 0xAD2A, 0xBD0B, 0x8D68, 0x9D49,
0x7E97, 0x6EB6, 0x5ED5, 0x4EF4, 0x3E13, 0x2E32, 0x1E51, 0x0E70, 0xFF9F, 0xEFBE, 0xDFDD, 0xCFFC, 0xBF1B, 0xAF3A, 0x9F59, 0x8F78,
0x9188, 0x81A9, 0xB1CA, 0xA1EB, 0xD10C, 0xC12D, 0xF14E, 0xE16F, 0x1080, 0x00A1, 0x30C2, 0x20E3, 0x5004, 0x4025, 0x7046, 0x6067,
0x83B9, 0x9398, 0xA3FB, 0xB3DA, 0xC33D, 0xD31C, 0xE37F, 0xF35E, 0x02B1, 0x1290, 0x22F3, 0x32D2, 0x4235, 0x5214, 0x6277, 0x7256,
0xB5EA, 0xA5CB, 0x95A8, 0x8589, 0xF56E, 0xE54F, 0xD52C, 0xC50D, 0x34E2, 0x24C3, 0x14A0, 0x0481, 0x7466, 0x6447, 0x5424, 0x4405,
0xA7DB, 0xB7FA, 0x8799, 0x97B8, 0xE75F, 0xF77E, 0xC71D, 0xD73C, 0x26D3, 0x36F2, 0x0691, 0x16B0, 0x6657, 0x7676, 0x4615, 0x5634,
0xD94C, 0xC96D, 0xF90E, 0xE92F, 0x99C8, 0x89E9, 0xB98A, 0xA9AB, 0x5844, 0x4865, 0x7806, 0x6827, 0x18C0, 0x08E1, 0x3882, 0x28A3,
0xCB7D, 0xDB5C, 0xEB3F, 0xFB1E, 0x8BF9, 0x9BD8, 0xABBB, 0xBB9A, 0x4A75, 0x5A54, 0x6A37, 0x7A16, 0x0AF1, 0x1AD0, 0x2AB3, 0x3A92,
0xFD2E, 0xED0F, 0xDD6C, 0xCD4D, 0xBDAA, 0xAD8B, 0x9DE8, 0x8DC9, 0x7C26, 0x6C07, 0x5C64, 0x4C45, 0x3CA2, 0x2C83, 0x1CE0, 0x0CC1,
0xEF1F, 0xFF3E, 0xCF5D, 0xDF7C, 0xAF9B, 0xBFBA, 0x8FD9, 0x9FF8, 0x6E17, 0x7E36, 0x4E55, 0x5E74, 0x2E93, 0x3EB2, 0x0ED1, 0x1EF0
};
return table;
}
const uint16_t * const table;
};
//***************************************************************************
class crc16_table_poly_0x1021_reflected
{
protected:
crc16_table_poly_0x1021_reflected()
: table(get_table())
{
}
static const uint16_t * const get_table()
{
static const uint16_t table[256] =
{
0x0000, 0x1189, 0x2312, 0x329B, 0x4624, 0x57AD, 0x6536, 0x74BF, 0x8C48, 0x9DC1, 0xAF5A, 0xBED3, 0xCA6C, 0xDBE5, 0xE97E, 0xF8F7,
0x1081, 0x0108, 0x3393, 0x221A, 0x56A5, 0x472C, 0x75B7, 0x643E, 0x9CC9, 0x8D40, 0xBFDB, 0xAE52, 0xDAED, 0xCB64, 0xF9FF, 0xE876,
0x2102, 0x308B, 0x0210, 0x1399, 0x6726, 0x76AF, 0x4434, 0x55BD, 0xAD4A, 0xBCC3, 0x8E58, 0x9FD1, 0xEB6E, 0xFAE7, 0xC87C, 0xD9F5,
0x3183, 0x200A, 0x1291, 0x0318, 0x77A7, 0x662E, 0x54B5, 0x453C, 0xBDCB, 0xAC42, 0x9ED9, 0x8F50, 0xFBEF, 0xEA66, 0xD8FD, 0xC974,
0x4204, 0x538D, 0x6116, 0x709F, 0x0420, 0x15A9, 0x2732, 0x36BB, 0xCE4C, 0xDFC5, 0xED5E, 0xFCD7, 0x8868, 0x99E1, 0xAB7A, 0xBAF3,
0x5285, 0x430C, 0x7197, 0x601E, 0x14A1, 0x0528, 0x37B3, 0x263A, 0xDECD, 0xCF44, 0xFDDF, 0xEC56, 0x98E9, 0x8960, 0xBBFB, 0xAA72,
0x6306, 0x728F, 0x4014, 0x519D, 0x2522, 0x34AB, 0x0630, 0x17B9, 0xEF4E, 0xFEC7, 0xCC5C, 0xDDD5, 0xA96A, 0xB8E3, 0x8A78, 0x9BF1,
0x7387, 0x620E, 0x5095, 0x411C, 0x35A3, 0x242A, 0x16B1, 0x0738, 0xFFCF, 0xEE46, 0xDCDD, 0xCD54, 0xB9EB, 0xA862, 0x9AF9, 0x8B70,
0x8408, 0x9581, 0xA71A, 0xB693, 0xC22C, 0xD3A5, 0xE13E, 0xF0B7, 0x0840, 0x19C9, 0x2B52, 0x3ADB, 0x4E64, 0x5FED, 0x6D76, 0x7CFF,
0x9489, 0x8500, 0xB79B, 0xA612, 0xD2AD, 0xC324, 0xF1BF, 0xE036, 0x18C1, 0x0948, 0x3BD3, 0x2A5A, 0x5EE5, 0x4F6C, 0x7DF7, 0x6C7E,
0xA50A, 0xB483, 0x8618, 0x9791, 0xE32E, 0xF2A7, 0xC03C, 0xD1B5, 0x2942, 0x38CB, 0x0A50, 0x1BD9, 0x6F66, 0x7EEF, 0x4C74, 0x5DFD,
0xB58B, 0xA402, 0x9699, 0x8710, 0xF3AF, 0xE226, 0xD0BD, 0xC134, 0x39C3, 0x284A, 0x1AD1, 0x0B58, 0x7FE7, 0x6E6E, 0x5CF5, 0x4D7C,
0xC60C, 0xD785, 0xE51E, 0xF497, 0x8028, 0x91A1, 0xA33A, 0xB2B3, 0x4A44, 0x5BCD, 0x6956, 0x78DF, 0x0C60, 0x1DE9, 0x2F72, 0x3EFB,
0xD68D, 0xC704, 0xF59F, 0xE416, 0x90A9, 0x8120, 0xB3BB, 0xA232, 0x5AC5, 0x4B4C, 0x79D7, 0x685E, 0x1CE1, 0x0D68, 0x3FF3, 0x2E7A,
0xE70E, 0xF687, 0xC41C, 0xD595, 0xA12A, 0xB0A3, 0x8238, 0x93B1, 0x6B46, 0x7ACF, 0x4854, 0x59DD, 0x2D62, 0x3CEB, 0x0E70, 0x1FF9,
0xF78F, 0xE606, 0xD49D, 0xC514, 0xB1AB, 0xA022, 0x92B9, 0x8330, 0x7BC7, 0x6A4E, 0x58D5, 0x495C, 0x3DE3, 0x2C6A, 0x1EF1, 0x0F78
};
return table;
}
const uint16_t * const table;
};
//***************************************************************************
/// CRC16 Poly 0x1021 policy.
/// Calculates CRC16 using polynomial 0x1021
//***************************************************************************
template <const uint16_t INITIAL, const uint16_t XOR_OUT, const bool REFLECT = false>
struct crc16_policy_poly_0x1021 : public crc16_table_poly_0x1021
{
typedef uint16_t value_type;
//*************************************************************************
ETL_CONSTEXPR uint16_t initial() const
{
return INITIAL;
}
//*************************************************************************
uint16_t add(uint16_t crc, uint8_t value) const
{
return (crc << 8) ^ table[((crc >> 8) ^ value) & 0xFF];
}
//*************************************************************************
inline uint16_t final(uint16_t crc) const
{
return crc ^ XOR_OUT;
}
};
//***************************************************************************
/// CRC16 Poly 0x1021 reflected policy specialisation.
//***************************************************************************
template <const uint16_t INITIAL, const uint16_t XOR_OUT>
struct crc16_policy_poly_0x1021<INITIAL, XOR_OUT, true> : public crc16_table_poly_0x1021_reflected
{
typedef uint16_t value_type;
//*************************************************************************
ETL_CONSTEXPR uint16_t initial() const
{
return INITIAL;
}
//*************************************************************************
uint16_t add(uint16_t crc, uint8_t value) const
{
return (crc >> 8) ^ table[(crc ^ value) & 0xFF];
}
//*************************************************************************
uint16_t final(uint16_t crc) const
{
return crc ^ XOR_OUT;
}
};
//*************************************************************************
/// CRC16 Poly 0x1021
//*************************************************************************
template <const uint16_t INITIAL, const uint16_t XOR_OUT, const bool REFLECT>
class crc16_poly_0x1021 : public etl::frame_check_sequence<etl::crc16_policy_poly_0x1021<INITIAL, XOR_OUT, REFLECT> >
{
public:
//*************************************************************************
/// Default constructor.
//*************************************************************************
crc16_poly_0x1021()
{
this->reset();
}
//*************************************************************************
/// Constructor from range.
/// \param begin Start of the range.
/// \param end End of the range.
//*************************************************************************
template<typename TIterator>
crc16_poly_0x1021(TIterator begin, const TIterator end)
{
this->reset();
this->add(begin, end);
}
};
}
#endif

View File

@ -0,0 +1,212 @@
///\file
/******************************************************************************
The MIT License(MIT)
Embedded Template Library.
https://github.com/ETLCPP/etl
https://www.etlcpp.com
Copyright(c) 2018 jwellbelove
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files(the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions :
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
******************************************************************************/
#ifndef ETL_CRC16_POLY_0X8005_INCLUDED
#define ETL_CRC16_POLY_0X8005_INCLUDED
#include <stdint.h>
#include "../platform.h"
#include "../frame_check_sequence.h"
#include "../binary.h"
#include "../stl/iterator.h"
#if defined(ETL_COMPILER_KEIL)
#pragma diag_suppress 1300
#endif
///\defgroup crc16_ccitt 16 bit CRC Poly 0x8005 calculation
///\ingroup crc
namespace etl
{
//***************************************************************************
class crc16_table_poly_0x8005
{
protected:
crc16_table_poly_0x8005()
: table(get_table())
{
}
static const uint16_t * const get_table()
{
static const uint16_t table[256] =
{
0x0000, 0x8005, 0x800F, 0x000A, 0x801B, 0x001E, 0x0014, 0x8011, 0x8033, 0x0036, 0x003C, 0x8039, 0x0028, 0x802D, 0x8027, 0x0022,
0x8063, 0x0066, 0x006C, 0x8069, 0x0078, 0x807D, 0x8077, 0x0072, 0x0050, 0x8055, 0x805F, 0x005A, 0x804B, 0x004E, 0x0044, 0x8041,
0x80C3, 0x00C6, 0x00CC, 0x80C9, 0x00D8, 0x80DD, 0x80D7, 0x00D2, 0x00F0, 0x80F5, 0x80FF, 0x00FA, 0x80EB, 0x00EE, 0x00E4, 0x80E1,
0x00A0, 0x80A5, 0x80AF, 0x00AA, 0x80BB, 0x00BE, 0x00B4, 0x80B1, 0x8093, 0x0096, 0x009C, 0x8099, 0x0088, 0x808D, 0x8087, 0x0082,
0x8183, 0x0186, 0x018C, 0x8189, 0x0198, 0x819D, 0x8197, 0x0192, 0x01B0, 0x81B5, 0x81BF, 0x01BA, 0x81AB, 0x01AE, 0x01A4, 0x81A1,
0x01E0, 0x81E5, 0x81EF, 0x01EA, 0x81FB, 0x01FE, 0x01F4, 0x81F1, 0x81D3, 0x01D6, 0x01DC, 0x81D9, 0x01C8, 0x81CD, 0x81C7, 0x01C2,
0x0140, 0x8145, 0x814F, 0x014A, 0x815B, 0x015E, 0x0154, 0x8151, 0x8173, 0x0176, 0x017C, 0x8179, 0x0168, 0x816D, 0x8167, 0x0162,
0x8123, 0x0126, 0x012C, 0x8129, 0x0138, 0x813D, 0x8137, 0x0132, 0x0110, 0x8115, 0x811F, 0x011A, 0x810B, 0x010E, 0x0104, 0x8101,
0x8303, 0x0306, 0x030C, 0x8309, 0x0318, 0x831D, 0x8317, 0x0312, 0x0330, 0x8335, 0x833F, 0x033A, 0x832B, 0x032E, 0x0324, 0x8321,
0x0360, 0x8365, 0x836F, 0x036A, 0x837B, 0x037E, 0x0374, 0x8371, 0x8353, 0x0356, 0x035C, 0x8359, 0x0348, 0x834D, 0x8347, 0x0342,
0x03C0, 0x83C5, 0x83CF, 0x03CA, 0x83DB, 0x03DE, 0x03D4, 0x83D1, 0x83F3, 0x03F6, 0x03FC, 0x83F9, 0x03E8, 0x83ED, 0x83E7, 0x03E2,
0x83A3, 0x03A6, 0x03AC, 0x83A9, 0x03B8, 0x83BD, 0x83B7, 0x03B2, 0x0390, 0x8395, 0x839F, 0x039A, 0x838B, 0x038E, 0x0384, 0x8381,
0x0280, 0x8285, 0x828F, 0x028A, 0x829B, 0x029E, 0x0294, 0x8291, 0x82B3, 0x02B6, 0x02BC, 0x82B9, 0x02A8, 0x82AD, 0x82A7, 0x02A2,
0x82E3, 0x02E6, 0x02EC, 0x82E9, 0x02F8, 0x82FD, 0x82F7, 0x02F2, 0x02D0, 0x82D5, 0x82DF, 0x02DA, 0x82CB, 0x02CE, 0x02C4, 0x82C1,
0x8243, 0x0246, 0x024C, 0x8249, 0x0258, 0x825D, 0x8257, 0x0252, 0x0270, 0x8275, 0x827F, 0x027A, 0x826B, 0x026E, 0x0264, 0x8261,
0x0220, 0x8225, 0x822F, 0x022A, 0x823B, 0x023E, 0x0234, 0x8231, 0x8213, 0x0216, 0x021C, 0x8219, 0x0208, 0x820D, 0x8207, 0x0202
};
return table;
}
const uint16_t * const table;
};
//***************************************************************************
class crc16_table_poly_0x8005_reflected
{
protected:
crc16_table_poly_0x8005_reflected()
: table(get_table())
{
}
static const uint16_t * const get_table()
{
static const uint16_t table[256] =
{
0x0000, 0xC0C1, 0xC181, 0x0140, 0xC301, 0x03C0, 0x0280, 0xC241, 0xC601, 0x06C0, 0x0780, 0xC741, 0x0500, 0xC5C1, 0xC481, 0x0440,
0xCC01, 0x0CC0, 0x0D80, 0xCD41, 0x0F00, 0xCFC1, 0xCE81, 0x0E40, 0x0A00, 0xCAC1, 0xCB81, 0x0B40, 0xC901, 0x09C0, 0x0880, 0xC841,
0xD801, 0x18C0, 0x1980, 0xD941, 0x1B00, 0xDBC1, 0xDA81, 0x1A40, 0x1E00, 0xDEC1, 0xDF81, 0x1F40, 0xDD01, 0x1DC0, 0x1C80, 0xDC41,
0x1400, 0xD4C1, 0xD581, 0x1540, 0xD701, 0x17C0, 0x1680, 0xD641, 0xD201, 0x12C0, 0x1380, 0xD341, 0x1100, 0xD1C1, 0xD081, 0x1040,
0xF001, 0x30C0, 0x3180, 0xF141, 0x3300, 0xF3C1, 0xF281, 0x3240, 0x3600, 0xF6C1, 0xF781, 0x3740, 0xF501, 0x35C0, 0x3480, 0xF441,
0x3C00, 0xFCC1, 0xFD81, 0x3D40, 0xFF01, 0x3FC0, 0x3E80, 0xFE41, 0xFA01, 0x3AC0, 0x3B80, 0xFB41, 0x3900, 0xF9C1, 0xF881, 0x3840,
0x2800, 0xE8C1, 0xE981, 0x2940, 0xEB01, 0x2BC0, 0x2A80, 0xEA41, 0xEE01, 0x2EC0, 0x2F80, 0xEF41, 0x2D00, 0xEDC1, 0xEC81, 0x2C40,
0xE401, 0x24C0, 0x2580, 0xE541, 0x2700, 0xE7C1, 0xE681, 0x2640, 0x2200, 0xE2C1, 0xE381, 0x2340, 0xE101, 0x21C0, 0x2080, 0xE041,
0xA001, 0x60C0, 0x6180, 0xA141, 0x6300, 0xA3C1, 0xA281, 0x6240, 0x6600, 0xA6C1, 0xA781, 0x6740, 0xA501, 0x65C0, 0x6480, 0xA441,
0x6C00, 0xACC1, 0xAD81, 0x6D40, 0xAF01, 0x6FC0, 0x6E80, 0xAE41, 0xAA01, 0x6AC0, 0x6B80, 0xAB41, 0x6900, 0xA9C1, 0xA881, 0x6840,
0x7800, 0xB8C1, 0xB981, 0x7940, 0xBB01, 0x7BC0, 0x7A80, 0xBA41, 0xBE01, 0x7EC0, 0x7F80, 0xBF41, 0x7D00, 0xBDC1, 0xBC81, 0x7C40,
0xB401, 0x74C0, 0x7580, 0xB541, 0x7700, 0xB7C1, 0xB681, 0x7640, 0x7200, 0xB2C1, 0xB381, 0x7340, 0xB101, 0x71C0, 0x7080, 0xB041,
0x5000, 0x90C1, 0x9181, 0x5140, 0x9301, 0x53C0, 0x5280, 0x9241, 0x9601, 0x56C0, 0x5780, 0x9741, 0x5500, 0x95C1, 0x9481, 0x5440,
0x9C01, 0x5CC0, 0x5D80, 0x9D41, 0x5F00, 0x9FC1, 0x9E81, 0x5E40, 0x5A00, 0x9AC1, 0x9B81, 0x5B40, 0x9901, 0x59C0, 0x5880, 0x9841,
0x8801, 0x48C0, 0x4980, 0x8941, 0x4B00, 0x8BC1, 0x8A81, 0x4A40, 0x4E00, 0x8EC1, 0x8F81, 0x4F40, 0x8D01, 0x4DC0, 0x4C80, 0x8C41,
0x4400, 0x84C1, 0x8581, 0x4540, 0x8701, 0x47C0, 0x4680, 0x8641, 0x8201, 0x42C0, 0x4380, 0x8341, 0x4100, 0x81C1, 0x8081, 0x4040
};
return table;
}
const uint16_t * const table;
};
//***************************************************************************
/// CRC16 Poly 0x8005 policy.
/// Calculates CRC16 using polynomial 0x8005
//***************************************************************************
template <const uint16_t INITIAL, const uint16_t XOR_OUT, const bool REFLECT = false>
struct crc16_policy_poly_0x8005 : public crc16_table_poly_0x8005
{
typedef uint16_t value_type;
//*************************************************************************
ETL_CONSTEXPR uint16_t initial() const
{
return INITIAL;
}
//*************************************************************************
uint16_t add(uint16_t crc, uint8_t value) const
{
return (crc << 8) ^ table[((crc >> 8) ^ value) & 0xFF];
}
//*************************************************************************
inline uint16_t final(uint16_t crc) const
{
return crc ^ XOR_OUT;
}
};
//***************************************************************************
/// CRC16 Poly 0x8005 reflected policy.
//***************************************************************************
template <const uint16_t INITIAL, const uint16_t XOR_OUT>
struct crc16_policy_poly_0x8005< INITIAL, XOR_OUT, true> : public crc16_table_poly_0x8005_reflected
{
typedef uint16_t value_type;
//*************************************************************************
ETL_CONSTEXPR uint16_t initial() const
{
return INITIAL;
}
//*************************************************************************
uint16_t add(uint16_t crc, uint8_t value) const
{
return (crc >> 8) ^ table[(crc ^ value) & 0xFF];
}
//*************************************************************************
inline uint16_t final(uint16_t crc) const
{
return crc ^ XOR_OUT;
}
};
//*************************************************************************
/// CRC16 Poly 0x8005
//*************************************************************************
template <const uint16_t INITIAL, const uint16_t XOR_OUT, const bool REFLECT>
class crc16_poly_0x8005 : public etl::frame_check_sequence<etl::crc16_policy_poly_0x8005<INITIAL, XOR_OUT, REFLECT> >
{
public:
//*************************************************************************
/// Default constructor.
//*************************************************************************
crc16_poly_0x8005()
{
this->reset();
}
//*************************************************************************
/// Constructor from range.
/// \param begin Start of the range.
/// \param end End of the range.
//*************************************************************************
template<typename TIterator>
crc16_poly_0x8005(TIterator begin, const TIterator end)
{
this->reset();
this->add(begin, end);
}
};
}
#endif

View File

@ -0,0 +1,212 @@
///\file
/******************************************************************************
The MIT License(MIT)
Embedded Template Library.
https://github.com/ETLCPP/etl
https://www.etlcpp.com
Copyright(c) 2018 jwellbelove
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files(the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions :
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
******************************************************************************/
#ifndef ETL_CRC16_TABLE_POLY_0X04C11DB7_INCLUDED
#define ETL_CRC16_TABLE_POLY_0X04C11DB7_INCLUDED
#include <stdint.h>
#include "../platform.h"
#include "../frame_check_sequence.h"
#include "../binary.h"
#include "../stl/iterator.h"
#if defined(ETL_COMPILER_KEIL)
#pragma diag_suppress 1300
#endif
///\defgroup crc32_poly 0x04C11DB7 32 bit CRC Poly 0x04C11DB7 calculation
///\ingroup crc
namespace etl
{
//***************************************************************************
class crc32_table_poly_0x04c11db7
{
protected:
crc32_table_poly_0x04c11db7()
: table(get_table())
{
}
static const uint32_t * const get_table()
{
static const uint32_t table[256] =
{
0x00000000, 0x04C11DB7, 0x09823B6E, 0x0D4326D9, 0x130476DC, 0x17C56B6B, 0x1A864DB2, 0x1E475005, 0x2608EDB8, 0x22C9F00F, 0x2F8AD6D6, 0x2B4BCB61, 0x350C9B64, 0x31CD86D3, 0x3C8EA00A, 0x384FBDBD,
0x4C11DB70, 0x48D0C6C7, 0x4593E01E, 0x4152FDA9, 0x5F15ADAC, 0x5BD4B01B, 0x569796C2, 0x52568B75, 0x6A1936C8, 0x6ED82B7F, 0x639B0DA6, 0x675A1011, 0x791D4014, 0x7DDC5DA3, 0x709F7B7A, 0x745E66CD,
0x9823B6E0, 0x9CE2AB57, 0x91A18D8E, 0x95609039, 0x8B27C03C, 0x8FE6DD8B, 0x82A5FB52, 0x8664E6E5, 0xBE2B5B58, 0xBAEA46EF, 0xB7A96036, 0xB3687D81, 0xAD2F2D84, 0xA9EE3033, 0xA4AD16EA, 0xA06C0B5D,
0xD4326D90, 0xD0F37027, 0xDDB056FE, 0xD9714B49, 0xC7361B4C, 0xC3F706FB, 0xCEB42022, 0xCA753D95, 0xF23A8028, 0xF6FB9D9F, 0xFBB8BB46, 0xFF79A6F1, 0xE13EF6F4, 0xE5FFEB43, 0xE8BCCD9A, 0xEC7DD02D,
0x34867077, 0x30476DC0, 0x3D044B19, 0x39C556AE, 0x278206AB, 0x23431B1C, 0x2E003DC5, 0x2AC12072, 0x128E9DCF, 0x164F8078, 0x1B0CA6A1, 0x1FCDBB16, 0x018AEB13, 0x054BF6A4, 0x0808D07D, 0x0CC9CDCA,
0x7897AB07, 0x7C56B6B0, 0x71159069, 0x75D48DDE, 0x6B93DDDB, 0x6F52C06C, 0x6211E6B5, 0x66D0FB02, 0x5E9F46BF, 0x5A5E5B08, 0x571D7DD1, 0x53DC6066, 0x4D9B3063, 0x495A2DD4, 0x44190B0D, 0x40D816BA,
0xACA5C697, 0xA864DB20, 0xA527FDF9, 0xA1E6E04E, 0xBFA1B04B, 0xBB60ADFC, 0xB6238B25, 0xB2E29692, 0x8AAD2B2F, 0x8E6C3698, 0x832F1041, 0x87EE0DF6, 0x99A95DF3, 0x9D684044, 0x902B669D, 0x94EA7B2A,
0xE0B41DE7, 0xE4750050, 0xE9362689, 0xEDF73B3E, 0xF3B06B3B, 0xF771768C, 0xFA325055, 0xFEF34DE2, 0xC6BCF05F, 0xC27DEDE8, 0xCF3ECB31, 0xCBFFD686, 0xD5B88683, 0xD1799B34, 0xDC3ABDED, 0xD8FBA05A,
0x690CE0EE, 0x6DCDFD59, 0x608EDB80, 0x644FC637, 0x7A089632, 0x7EC98B85, 0x738AAD5C, 0x774BB0EB, 0x4F040D56, 0x4BC510E1, 0x46863638, 0x42472B8F, 0x5C007B8A, 0x58C1663D, 0x558240E4, 0x51435D53,
0x251D3B9E, 0x21DC2629, 0x2C9F00F0, 0x285E1D47, 0x36194D42, 0x32D850F5, 0x3F9B762C, 0x3B5A6B9B, 0x0315D626, 0x07D4CB91, 0x0A97ED48, 0x0E56F0FF, 0x1011A0FA, 0x14D0BD4D, 0x19939B94, 0x1D528623,
0xF12F560E, 0xF5EE4BB9, 0xF8AD6D60, 0xFC6C70D7, 0xE22B20D2, 0xE6EA3D65, 0xEBA91BBC, 0xEF68060B, 0xD727BBB6, 0xD3E6A601, 0xDEA580D8, 0xDA649D6F, 0xC423CD6A, 0xC0E2D0DD, 0xCDA1F604, 0xC960EBB3,
0xBD3E8D7E, 0xB9FF90C9, 0xB4BCB610, 0xB07DABA7, 0xAE3AFBA2, 0xAAFBE615, 0xA7B8C0CC, 0xA379DD7B, 0x9B3660C6, 0x9FF77D71, 0x92B45BA8, 0x9675461F, 0x8832161A, 0x8CF30BAD, 0x81B02D74, 0x857130C3,
0x5D8A9099, 0x594B8D2E, 0x5408ABF7, 0x50C9B640, 0x4E8EE645, 0x4A4FFBF2, 0x470CDD2B, 0x43CDC09C, 0x7B827D21, 0x7F436096, 0x7200464F, 0x76C15BF8, 0x68860BFD, 0x6C47164A, 0x61043093, 0x65C52D24,
0x119B4BE9, 0x155A565E, 0x18197087, 0x1CD86D30, 0x029F3D35, 0x065E2082, 0x0B1D065B, 0x0FDC1BEC, 0x3793A651, 0x3352BBE6, 0x3E119D3F, 0x3AD08088, 0x2497D08D, 0x2056CD3A, 0x2D15EBE3, 0x29D4F654,
0xC5A92679, 0xC1683BCE, 0xCC2B1D17, 0xC8EA00A0, 0xD6AD50A5, 0xD26C4D12, 0xDF2F6BCB, 0xDBEE767C, 0xE3A1CBC1, 0xE760D676, 0xEA23F0AF, 0xEEE2ED18, 0xF0A5BD1D, 0xF464A0AA, 0xF9278673, 0xFDE69BC4,
0x89B8FD09, 0x8D79E0BE, 0x803AC667, 0x84FBDBD0, 0x9ABC8BD5, 0x9E7D9662, 0x933EB0BB, 0x97FFAD0C, 0xAFB010B1, 0xAB710D06, 0xA6322BDF, 0xA2F33668, 0xBCB4666D, 0xB8757BDA, 0xB5365D03, 0xB1F740B4
};
return table;
}
const uint32_t * const table;
};
//***************************************************************************
class crc32_table_poly_0x04c11db7_reflected
{
protected:
crc32_table_poly_0x04c11db7_reflected()
: table(get_table())
{
}
static const uint32_t * const get_table()
{
static const uint32_t table[256] =
{
0x00000000, 0x77073096, 0xEE0E612C, 0x990951BA, 0x076DC419, 0x706AF48F, 0xE963A535, 0x9E6495A3, 0x0EDB8832, 0x79DCB8A4, 0xE0D5E91E, 0x97D2D988, 0x09B64C2B, 0x7EB17CBD, 0xE7B82D07, 0x90BF1D91,
0x1DB71064, 0x6AB020F2, 0xF3B97148, 0x84BE41DE, 0x1ADAD47D, 0x6DDDE4EB, 0xF4D4B551, 0x83D385C7, 0x136C9856, 0x646BA8C0, 0xFD62F97A, 0x8A65C9EC, 0x14015C4F, 0x63066CD9, 0xFA0F3D63, 0x8D080DF5,
0x3B6E20C8, 0x4C69105E, 0xD56041E4, 0xA2677172, 0x3C03E4D1, 0x4B04D447, 0xD20D85FD, 0xA50AB56B, 0x35B5A8FA, 0x42B2986C, 0xDBBBC9D6, 0xACBCF940, 0x32D86CE3, 0x45DF5C75, 0xDCD60DCF, 0xABD13D59,
0x26D930AC, 0x51DE003A, 0xC8D75180, 0xBFD06116, 0x21B4F4B5, 0x56B3C423, 0xCFBA9599, 0xB8BDA50F, 0x2802B89E, 0x5F058808, 0xC60CD9B2, 0xB10BE924, 0x2F6F7C87, 0x58684C11, 0xC1611DAB, 0xB6662D3D,
0x76DC4190, 0x01DB7106, 0x98D220BC, 0xEFD5102A, 0x71B18589, 0x06B6B51F, 0x9FBFE4A5, 0xE8B8D433, 0x7807C9A2, 0x0F00F934, 0x9609A88E, 0xE10E9818, 0x7F6A0DBB, 0x086D3D2D, 0x91646C97, 0xE6635C01,
0x6B6B51F4, 0x1C6C6162, 0x856530D8, 0xF262004E, 0x6C0695ED, 0x1B01A57B, 0x8208F4C1, 0xF50FC457, 0x65B0D9C6, 0x12B7E950, 0x8BBEB8EA, 0xFCB9887C, 0x62DD1DDF, 0x15DA2D49, 0x8CD37CF3, 0xFBD44C65,
0x4DB26158, 0x3AB551CE, 0xA3BC0074, 0xD4BB30E2, 0x4ADFA541, 0x3DD895D7, 0xA4D1C46D, 0xD3D6F4FB, 0x4369E96A, 0x346ED9FC, 0xAD678846, 0xDA60B8D0, 0x44042D73, 0x33031DE5, 0xAA0A4C5F, 0xDD0D7CC9,
0x5005713C, 0x270241AA, 0xBE0B1010, 0xC90C2086, 0x5768B525, 0x206F85B3, 0xB966D409, 0xCE61E49F, 0x5EDEF90E, 0x29D9C998, 0xB0D09822, 0xC7D7A8B4, 0x59B33D17, 0x2EB40D81, 0xB7BD5C3B, 0xC0BA6CAD,
0xEDB88320, 0x9ABFB3B6, 0x03B6E20C, 0x74B1D29A, 0xEAD54739, 0x9DD277AF, 0x04DB2615, 0x73DC1683, 0xE3630B12, 0x94643B84, 0x0D6D6A3E, 0x7A6A5AA8, 0xE40ECF0B, 0x9309FF9D, 0x0A00AE27, 0x7D079EB1,
0xF00F9344, 0x8708A3D2, 0x1E01F268, 0x6906C2FE, 0xF762575D, 0x806567CB, 0x196C3671, 0x6E6B06E7, 0xFED41B76, 0x89D32BE0, 0x10DA7A5A, 0x67DD4ACC, 0xF9B9DF6F, 0x8EBEEFF9, 0x17B7BE43, 0x60B08ED5,
0xD6D6A3E8, 0xA1D1937E, 0x38D8C2C4, 0x4FDFF252, 0xD1BB67F1, 0xA6BC5767, 0x3FB506DD, 0x48B2364B, 0xD80D2BDA, 0xAF0A1B4C, 0x36034AF6, 0x41047A60, 0xDF60EFC3, 0xA867DF55, 0x316E8EEF, 0x4669BE79,
0xCB61B38C, 0xBC66831A, 0x256FD2A0, 0x5268E236, 0xCC0C7795, 0xBB0B4703, 0x220216B9, 0x5505262F, 0xC5BA3BBE, 0xB2BD0B28, 0x2BB45A92, 0x5CB36A04, 0xC2D7FFA7, 0xB5D0CF31, 0x2CD99E8B, 0x5BDEAE1D,
0x9B64C2B0, 0xEC63F226, 0x756AA39C, 0x026D930A, 0x9C0906A9, 0xEB0E363F, 0x72076785, 0x05005713, 0x95BF4A82, 0xE2B87A14, 0x7BB12BAE, 0x0CB61B38, 0x92D28E9B, 0xE5D5BE0D, 0x7CDCEFB7, 0x0BDBDF21,
0x86D3D2D4, 0xF1D4E242, 0x68DDB3F8, 0x1FDA836E, 0x81BE16CD, 0xF6B9265B, 0x6FB077E1, 0x18B74777, 0x88085AE6, 0xFF0F6A70, 0x66063BCA, 0x11010B5C, 0x8F659EFF, 0xF862AE69, 0x616BFFD3, 0x166CCF45,
0xA00AE278, 0xD70DD2EE, 0x4E048354, 0x3903B3C2, 0xA7672661, 0xD06016F7, 0x4969474D, 0x3E6E77DB, 0xAED16A4A, 0xD9D65ADC, 0x40DF0B66, 0x37D83BF0, 0xA9BCAE53, 0xDEBB9EC5, 0x47B2CF7F, 0x30B5FFE9,
0xBDBDF21C, 0xCABAC28A, 0x53B39330, 0x24B4A3A6, 0xBAD03605, 0xCDD70693, 0x54DE5729, 0x23D967BF, 0xB3667A2E, 0xC4614AB8, 0x5D681B02, 0x2A6F2B94, 0xB40BBE37, 0xC30C8EA1, 0x5A05DF1B, 0x2D02EF8D
};
return table;
}
const uint32_t * const table;
};
//***************************************************************************
/// CRC32 Poly 0x04C11DB7 policy.
/// Calculates CRC32 using polynomial 0x04C11DB7
//***************************************************************************
template <const uint32_t INITIAL, const uint32_t XOR_OUT, const bool REFLECT = false>
struct crc32_policy_poly_0x04c11db7 : public crc32_table_poly_0x04c11db7
{
typedef uint32_t value_type;
//*************************************************************************
ETL_CONSTEXPR uint32_t initial() const
{
return INITIAL;
}
//*************************************************************************
uint32_t add(uint32_t crc, uint8_t value) const
{
return (crc << 8) ^ table[((crc >> 24) ^ value) & 0xFF];
}
//*************************************************************************
uint32_t final(uint32_t crc) const
{
return crc ^ XOR_OUT;
}
};
//***************************************************************************
/// CRC32 Poly 0x04C11DB7 reflected policy specialisation.
//***************************************************************************
template <const uint32_t INITIAL, const uint32_t XOR_OUT>
struct crc32_policy_poly_0x04c11db7<INITIAL, XOR_OUT, true> : public crc32_table_poly_0x04c11db7_reflected
{
typedef uint32_t value_type;
//*************************************************************************
ETL_CONSTEXPR uint32_t initial() const
{
return INITIAL;
}
//*************************************************************************
uint32_t add(uint32_t crc, uint8_t value) const
{
return (crc >> 8) ^ table[(crc ^ value) & 0xFF];
}
//*************************************************************************
uint32_t final(uint32_t crc) const
{
return crc ^ XOR_OUT;
}
};
//*************************************************************************
/// CRC32 Poly 0x04C11DB7
//*************************************************************************
template <const uint32_t INITIAL, const uint32_t XOR_OUT, const bool REFLECT>
class crc32_poly_0x04c11db7 : public etl::frame_check_sequence<etl::crc32_policy_poly_0x04c11db7<INITIAL, XOR_OUT, REFLECT> >
{
public:
//*************************************************************************
/// Default constructor.
//*************************************************************************
crc32_poly_0x04c11db7()
{
this->reset();
}
//*************************************************************************
/// Constructor from range.
/// \param begin Start of the range.
/// \param end End of the range.
//*************************************************************************
template<typename TIterator>
crc32_poly_0x04c11db7(TIterator begin, const TIterator end)
{
this->reset();
this->add(begin, end);
}
};
}
#endif

View File

@ -0,0 +1,212 @@
///\file
/******************************************************************************
The MIT License(MIT)
Embedded Template Library.
https://github.com/ETLCPP/etl
https://www.etlcpp.com
Copyright(c) 2019 jwellbelove
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files(the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions :
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
******************************************************************************/
#ifndef ETL_CRC16_TABLE_POLY_0X1EDC6F41_INCLUDED
#define ETL_CRC16_TABLE_POLY_0X1EDC6F41_INCLUDED
#include <stdint.h>
#include "../platform.h"
#include "../frame_check_sequence.h"
#include "../binary.h"
#include "../stl/iterator.h"
#if defined(ETL_COMPILER_KEIL)
#pragma diag_suppress 1300
#endif
///\defgroup crc32_poly 0x1EDC6F41 32 bit CRC Poly 0x1EDC6F41 calculation
///\ingroup crc
namespace etl
{
//***************************************************************************
class crc32_table_poly_0x1edc6f41
{
protected:
crc32_table_poly_0x1edc6f41()
: table(get_table())
{
}
static const uint32_t * const get_table()
{
static const uint32_t table[256] =
{
0x00000000, 0xC0C1D64F, 0xEF0EDC87, 0x2FCF0AC8, 0xF8E959E3, 0x38288FAC, 0x17E78564, 0xD726532B, 0xF31A9B51, 0x33DB4D1E, 0x1C1447D6, 0xDCD59199, 0x0BF3C2B2, 0xCB3214FD, 0xE4FD1E35, 0x243CC87A,
0xF6E37A08, 0x3622AC47, 0x19EDA68F, 0xD92C70C0, 0x0E0A23EB, 0xCECBF5A4, 0xE104FF6C, 0x21C52923, 0x05F9E159, 0xC5383716, 0xEAF73DDE, 0x2A36EB91, 0xFD10B8BA, 0x3DD16EF5, 0x121E643D, 0xD2DFB272,
0x7B71BD04, 0xBBB06B4B, 0x947F6183, 0x54BEB7CC, 0x8398E4E7, 0x435932A8, 0x6C963860, 0xAC57EE2F, 0x886B2655, 0x48AAF01A, 0x6765FAD2, 0xA7A42C9D, 0x70827FB6, 0xB043A9F9, 0x9F8CA331, 0x5F4D757E,
0x8D92C70C, 0x4D531143, 0x629C1B8B, 0xA25DCDC4, 0x757B9EEF, 0xB5BA48A0, 0x9A754268, 0x5AB49427, 0x7E885C5D, 0xBE498A12, 0x918680DA, 0x51475695, 0x866105BE, 0x46A0D3F1, 0x696FD939, 0xA9AE0F76,
0x3DB8DE82, 0xFD7908CD, 0xD2B60205, 0x1277D44A, 0xC5518761, 0x0590512E, 0x2A5F5BE6, 0xEA9E8DA9, 0xCEA245D3, 0x0E63939C, 0x21AC9954, 0xE16D4F1B, 0x364B1C30, 0xF68ACA7F, 0xD945C0B7, 0x198416F8,
0xCB5BA48A, 0x0B9A72C5, 0x2455780D, 0xE494AE42, 0x33B2FD69, 0xF3732B26, 0xDCBC21EE, 0x1C7DF7A1, 0x38413FDB, 0xF880E994, 0xD74FE35C, 0x178E3513, 0xC0A86638, 0x0069B077, 0x2FA6BABF, 0xEF676CF0,
0x46C96386, 0x8608B5C9, 0xA9C7BF01, 0x6906694E, 0xBE203A65, 0x7EE1EC2A, 0x512EE6E2, 0x91EF30AD, 0xB5D3F8D7, 0x75122E98, 0x5ADD2450, 0x9A1CF21F, 0x4D3AA134, 0x8DFB777B, 0xA2347DB3, 0x62F5ABFC,
0xB02A198E, 0x70EBCFC1, 0x5F24C509, 0x9FE51346, 0x48C3406D, 0x88029622, 0xA7CD9CEA, 0x670C4AA5, 0x433082DF, 0x83F15490, 0xAC3E5E58, 0x6CFF8817, 0xBBD9DB3C, 0x7B180D73, 0x54D707BB, 0x9416D1F4,
0x1EDC6F41, 0xDE1DB90E, 0xF1D2B3C6, 0x31136589, 0xE63536A2, 0x26F4E0ED, 0x093BEA25, 0xC9FA3C6A, 0xEDC6F410, 0x2D07225F, 0x02C82897, 0xC209FED8, 0x152FADF3, 0xD5EE7BBC, 0xFA217174, 0x3AE0A73B,
0xE83F1549, 0x28FEC306, 0x0731C9CE, 0xC7F01F81, 0x10D64CAA, 0xD0179AE5, 0xFFD8902D, 0x3F194662, 0x1B258E18, 0xDBE45857, 0xF42B529F, 0x34EA84D0, 0xE3CCD7FB, 0x230D01B4, 0x0CC20B7C, 0xCC03DD33,
0x65ADD245, 0xA56C040A, 0x8AA30EC2, 0x4A62D88D, 0x9D448BA6, 0x5D855DE9, 0x724A5721, 0xB28B816E, 0x96B74914, 0x56769F5B, 0x79B99593, 0xB97843DC, 0x6E5E10F7, 0xAE9FC6B8, 0x8150CC70, 0x41911A3F,
0x934EA84D, 0x538F7E02, 0x7C4074CA, 0xBC81A285, 0x6BA7F1AE, 0xAB6627E1, 0x84A92D29, 0x4468FB66, 0x6054331C, 0xA095E553, 0x8F5AEF9B, 0x4F9B39D4, 0x98BD6AFF, 0x587CBCB0, 0x77B3B678, 0xB7726037,
0x2364B1C3, 0xE3A5678C, 0xCC6A6D44, 0x0CABBB0B, 0xDB8DE820, 0x1B4C3E6F, 0x348334A7, 0xF442E2E8, 0xD07E2A92, 0x10BFFCDD, 0x3F70F615, 0xFFB1205A, 0x28977371, 0xE856A53E, 0xC799AFF6, 0x075879B9,
0xD587CBCB, 0x15461D84, 0x3A89174C, 0xFA48C103, 0x2D6E9228, 0xEDAF4467, 0xC2604EAF, 0x02A198E0, 0x269D509A, 0xE65C86D5, 0xC9938C1D, 0x09525A52, 0xDE740979, 0x1EB5DF36, 0x317AD5FE, 0xF1BB03B1,
0x58150CC7, 0x98D4DA88, 0xB71BD040, 0x77DA060F, 0xA0FC5524, 0x603D836B, 0x4FF289A3, 0x8F335FEC, 0xAB0F9796, 0x6BCE41D9, 0x44014B11, 0x84C09D5E, 0x53E6CE75, 0x9327183A, 0xBCE812F2, 0x7C29C4BD,
0xAEF676CF, 0x6E37A080, 0x41F8AA48, 0x81397C07, 0x561F2F2C, 0x96DEF963, 0xB911F3AB, 0x79D025E4, 0x5DECED9E, 0x9D2D3BD1, 0xB2E23119, 0x7223E756, 0xA505B47D, 0x65C46232, 0x4A0B68FA, 0x8ACABEB5
};
return table;
}
const uint32_t * const table;
};
//***************************************************************************
class crc32_table_poly_0x1edc6f41_reflected
{
protected:
crc32_table_poly_0x1edc6f41_reflected()
: table(get_table())
{
}
static const uint32_t * const get_table()
{
static const uint32_t table[256] =
{
0x00000000, 0xF26B8303, 0xE13B70F7, 0x1350F3F4, 0xC79A971F, 0x35F1141C, 0x26A1E7E8, 0xD4CA64EB, 0x8AD958CF, 0x78B2DBCC, 0x6BE22838, 0x9989AB3B, 0x4D43CFD0, 0xBF284CD3, 0xAC78BF27, 0x5E133C24,
0x105EC76F, 0xE235446C, 0xF165B798, 0x030E349B, 0xD7C45070, 0x25AFD373, 0x36FF2087, 0xC494A384, 0x9A879FA0, 0x68EC1CA3, 0x7BBCEF57, 0x89D76C54, 0x5D1D08BF, 0xAF768BBC, 0xBC267848, 0x4E4DFB4B,
0x20BD8EDE, 0xD2D60DDD, 0xC186FE29, 0x33ED7D2A, 0xE72719C1, 0x154C9AC2, 0x061C6936, 0xF477EA35, 0xAA64D611, 0x580F5512, 0x4B5FA6E6, 0xB93425E5, 0x6DFE410E, 0x9F95C20D, 0x8CC531F9, 0x7EAEB2FA,
0x30E349B1, 0xC288CAB2, 0xD1D83946, 0x23B3BA45, 0xF779DEAE, 0x05125DAD, 0x1642AE59, 0xE4292D5A, 0xBA3A117E, 0x4851927D, 0x5B016189, 0xA96AE28A, 0x7DA08661, 0x8FCB0562, 0x9C9BF696, 0x6EF07595,
0x417B1DBC, 0xB3109EBF, 0xA0406D4B, 0x522BEE48, 0x86E18AA3, 0x748A09A0, 0x67DAFA54, 0x95B17957, 0xCBA24573, 0x39C9C670, 0x2A993584, 0xD8F2B687, 0x0C38D26C, 0xFE53516F, 0xED03A29B, 0x1F682198,
0x5125DAD3, 0xA34E59D0, 0xB01EAA24, 0x42752927, 0x96BF4DCC, 0x64D4CECF, 0x77843D3B, 0x85EFBE38, 0xDBFC821C, 0x2997011F, 0x3AC7F2EB, 0xC8AC71E8, 0x1C661503, 0xEE0D9600, 0xFD5D65F4, 0x0F36E6F7,
0x61C69362, 0x93AD1061, 0x80FDE395, 0x72966096, 0xA65C047D, 0x5437877E, 0x4767748A, 0xB50CF789, 0xEB1FCBAD, 0x197448AE, 0x0A24BB5A, 0xF84F3859, 0x2C855CB2, 0xDEEEDFB1, 0xCDBE2C45, 0x3FD5AF46,
0x7198540D, 0x83F3D70E, 0x90A324FA, 0x62C8A7F9, 0xB602C312, 0x44694011, 0x5739B3E5, 0xA55230E6, 0xFB410CC2, 0x092A8FC1, 0x1A7A7C35, 0xE811FF36, 0x3CDB9BDD, 0xCEB018DE, 0xDDE0EB2A, 0x2F8B6829,
0x82F63B78, 0x709DB87B, 0x63CD4B8F, 0x91A6C88C, 0x456CAC67, 0xB7072F64, 0xA457DC90, 0x563C5F93, 0x082F63B7, 0xFA44E0B4, 0xE9141340, 0x1B7F9043, 0xCFB5F4A8, 0x3DDE77AB, 0x2E8E845F, 0xDCE5075C,
0x92A8FC17, 0x60C37F14, 0x73938CE0, 0x81F80FE3, 0x55326B08, 0xA759E80B, 0xB4091BFF, 0x466298FC, 0x1871A4D8, 0xEA1A27DB, 0xF94AD42F, 0x0B21572C, 0xDFEB33C7, 0x2D80B0C4, 0x3ED04330, 0xCCBBC033,
0xA24BB5A6, 0x502036A5, 0x4370C551, 0xB11B4652, 0x65D122B9, 0x97BAA1BA, 0x84EA524E, 0x7681D14D, 0x2892ED69, 0xDAF96E6A, 0xC9A99D9E, 0x3BC21E9D, 0xEF087A76, 0x1D63F975, 0x0E330A81, 0xFC588982,
0xB21572C9, 0x407EF1CA, 0x532E023E, 0xA145813D, 0x758FE5D6, 0x87E466D5, 0x94B49521, 0x66DF1622, 0x38CC2A06, 0xCAA7A905, 0xD9F75AF1, 0x2B9CD9F2, 0xFF56BD19, 0x0D3D3E1A, 0x1E6DCDEE, 0xEC064EED,
0xC38D26C4, 0x31E6A5C7, 0x22B65633, 0xD0DDD530, 0x0417B1DB, 0xF67C32D8, 0xE52CC12C, 0x1747422F, 0x49547E0B, 0xBB3FFD08, 0xA86F0EFC, 0x5A048DFF, 0x8ECEE914, 0x7CA56A17, 0x6FF599E3, 0x9D9E1AE0,
0xD3D3E1AB, 0x21B862A8, 0x32E8915C, 0xC083125F, 0x144976B4, 0xE622F5B7, 0xF5720643, 0x07198540, 0x590AB964, 0xAB613A67, 0xB831C993, 0x4A5A4A90, 0x9E902E7B, 0x6CFBAD78, 0x7FAB5E8C, 0x8DC0DD8F,
0xE330A81A, 0x115B2B19, 0x020BD8ED, 0xF0605BEE, 0x24AA3F05, 0xD6C1BC06, 0xC5914FF2, 0x37FACCF1, 0x69E9F0D5, 0x9B8273D6, 0x88D28022, 0x7AB90321, 0xAE7367CA, 0x5C18E4C9, 0x4F48173D, 0xBD23943E,
0xF36E6F75, 0x0105EC76, 0x12551F82, 0xE03E9C81, 0x34F4F86A, 0xC69F7B69, 0xD5CF889D, 0x27A40B9E, 0x79B737BA, 0x8BDCB4B9, 0x988C474D, 0x6AE7C44E, 0xBE2DA0A5, 0x4C4623A6, 0x5F16D052, 0xAD7D5351
};
return table;
}
const uint32_t * const table;
};
//***************************************************************************
/// CRC32 Poly 0x1EDC6F41 policy.
/// Calculates CRC32 using polynomial 0x1EDC6F41
//***************************************************************************
template <const uint32_t INITIAL, const uint32_t XOR_OUT, const bool REFLECT = false>
struct crc32_policy_poly_0x1edc6f41 : public crc32_table_poly_0x1edc6f41
{
typedef uint32_t value_type;
//*************************************************************************
ETL_CONSTEXPR uint32_t initial() const
{
return INITIAL;
}
//*************************************************************************
uint32_t add(uint32_t crc, uint8_t value) const
{
return (crc << 8) ^ table[((crc >> 24) ^ value) & 0xFF];
}
//*************************************************************************
uint32_t final(uint32_t crc) const
{
return crc ^ XOR_OUT;
}
};
//***************************************************************************
/// CRC32 Poly 0x1EDC6F41 reflected policy specialisation.
//***************************************************************************
template <const uint32_t INITIAL, const uint32_t XOR_OUT>
struct crc32_policy_poly_0x1edc6f41<INITIAL, XOR_OUT, true> : public crc32_table_poly_0x1edc6f41_reflected
{
typedef uint32_t value_type;
//*************************************************************************
ETL_CONSTEXPR uint32_t initial() const
{
return INITIAL;
}
//*************************************************************************
uint32_t add(uint32_t crc, uint8_t value) const
{
return (crc >> 8) ^ table[(crc ^ value) & 0xFF];
}
//*************************************************************************
uint32_t final(uint32_t crc) const
{
return crc ^ XOR_OUT;
}
};
//*************************************************************************
/// CRC32 Poly 0x1EDC6F41
//*************************************************************************
template <const uint32_t INITIA, const uint32_t XOR_OUT, const bool REFLECT>
class crc32_poly_0x1edc6f41 : public etl::frame_check_sequence<etl::crc32_policy_poly_0x1edc6f41<INITIA, XOR_OUT, REFLECT> >
{
public:
//*************************************************************************
/// Default constructor.
//*************************************************************************
crc32_poly_0x1edc6f41()
{
this->reset();
}
//*************************************************************************
/// Constructor from range.
/// \param begin Start of the range.
/// \param end End of the range.
//*************************************************************************
template<typename TIterator>
crc32_poly_0x1edc6f41(TIterator begin, const TIterator end)
{
this->reset();
this->add(begin, end);
}
};
}
#endif

View File

@ -0,0 +1,242 @@
///\file
/******************************************************************************
The MIT License(MIT)
Embedded Template Library.
https://github.com/ETLCPP/etl
https://www.etlcpp.com
Copyright(c) 2019 jwellbelove
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files(the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions :
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
******************************************************************************/
#ifndef ETL_CRC16_TABLE_POLY_0X42F0E1EBA9EA3693_INCLUDED
#define ETL_CRC16_TABLE_POLY_0X42F0E1EBA9EA3693_INCLUDED
#include <stdint.h>
#include "../platform.h"
#include "../frame_check_sequence.h"
#include "../binary.h"
#include "../stl/iterator.h"
#if defined(ETL_COMPILER_KEIL)
#pragma diag_suppress 1300
#endif
///\defgroup crc64_poly 0x42F0E1EBA9EA3693 64 bit CRC Poly 0x42F0E1EBA9EA3693 calculation
///\ingroup crc
namespace etl
{
//***************************************************************************
class crc64_table_poly_0x42f0e1eba9ea3693
{
protected:
crc64_table_poly_0x42f0e1eba9ea3693()
: table(get_table())
{
}
static const uint64_t * const get_table()
{
static const uint64_t table[256] =
{
0x0000000000000000, 0x42F0E1EBA9EA3693, 0x85E1C3D753D46D26, 0xC711223CFA3E5BB5, 0x493366450E42ECDF, 0x0BC387AEA7A8DA4C, 0xCCD2A5925D9681F9, 0x8E224479F47CB76A,
0x9266CC8A1C85D9BE, 0xD0962D61B56FEF2D, 0x17870F5D4F51B498, 0x5577EEB6E6BB820B, 0xDB55AACF12C73561, 0x99A54B24BB2D03F2, 0x5EB4691841135847, 0x1C4488F3E8F96ED4,
0x663D78FF90E185EF, 0x24CD9914390BB37C, 0xE3DCBB28C335E8C9, 0xA12C5AC36ADFDE5A, 0x2F0E1EBA9EA36930, 0x6DFEFF5137495FA3, 0xAAEFDD6DCD770416, 0xE81F3C86649D3285,
0xF45BB4758C645C51, 0xB6AB559E258E6AC2, 0x71BA77A2DFB03177, 0x334A9649765A07E4, 0xBD68D2308226B08E, 0xFF9833DB2BCC861D, 0x388911E7D1F2DDA8, 0x7A79F00C7818EB3B,
0xCC7AF1FF21C30BDE, 0x8E8A101488293D4D, 0x499B3228721766F8, 0x0B6BD3C3DBFD506B, 0x854997BA2F81E701, 0xC7B97651866BD192, 0x00A8546D7C558A27, 0x4258B586D5BFBCB4,
0x5E1C3D753D46D260, 0x1CECDC9E94ACE4F3, 0xDBFDFEA26E92BF46, 0x990D1F49C77889D5, 0x172F5B3033043EBF, 0x55DFBADB9AEE082C, 0x92CE98E760D05399, 0xD03E790CC93A650A,
0xAA478900B1228E31, 0xE8B768EB18C8B8A2, 0x2FA64AD7E2F6E317, 0x6D56AB3C4B1CD584, 0xE374EF45BF6062EE, 0xA1840EAE168A547D, 0x66952C92ECB40FC8, 0x2465CD79455E395B,
0x3821458AADA7578F, 0x7AD1A461044D611C, 0xBDC0865DFE733AA9, 0xFF3067B657990C3A, 0x711223CFA3E5BB50, 0x33E2C2240A0F8DC3, 0xF4F3E018F031D676, 0xB60301F359DBE0E5,
0xDA050215EA6C212F, 0x98F5E3FE438617BC, 0x5FE4C1C2B9B84C09, 0x1D14202910527A9A, 0x93366450E42ECDF0, 0xD1C685BB4DC4FB63, 0x16D7A787B7FAA0D6, 0x5427466C1E109645,
0x4863CE9FF6E9F891, 0x0A932F745F03CE02, 0xCD820D48A53D95B7, 0x8F72ECA30CD7A324, 0x0150A8DAF8AB144E, 0x43A04931514122DD, 0x84B16B0DAB7F7968, 0xC6418AE602954FFB,
0xBC387AEA7A8DA4C0, 0xFEC89B01D3679253, 0x39D9B93D2959C9E6, 0x7B2958D680B3FF75, 0xF50B1CAF74CF481F, 0xB7FBFD44DD257E8C, 0x70EADF78271B2539, 0x321A3E938EF113AA,
0x2E5EB66066087D7E, 0x6CAE578BCFE24BED, 0xABBF75B735DC1058, 0xE94F945C9C3626CB, 0x676DD025684A91A1, 0x259D31CEC1A0A732, 0xE28C13F23B9EFC87, 0xA07CF2199274CA14,
0x167FF3EACBAF2AF1, 0x548F120162451C62, 0x939E303D987B47D7, 0xD16ED1D631917144, 0x5F4C95AFC5EDC62E, 0x1DBC74446C07F0BD, 0xDAAD56789639AB08, 0x985DB7933FD39D9B,
0x84193F60D72AF34F, 0xC6E9DE8B7EC0C5DC, 0x01F8FCB784FE9E69, 0x43081D5C2D14A8FA, 0xCD2A5925D9681F90, 0x8FDAB8CE70822903, 0x48CB9AF28ABC72B6, 0x0A3B7B1923564425,
0x70428B155B4EAF1E, 0x32B26AFEF2A4998D, 0xF5A348C2089AC238, 0xB753A929A170F4AB, 0x3971ED50550C43C1, 0x7B810CBBFCE67552, 0xBC902E8706D82EE7, 0xFE60CF6CAF321874,
0xE224479F47CB76A0, 0xA0D4A674EE214033, 0x67C58448141F1B86, 0x253565A3BDF52D15, 0xAB1721DA49899A7F, 0xE9E7C031E063ACEC, 0x2EF6E20D1A5DF759, 0x6C0603E6B3B7C1CA,
0xF6FAE5C07D3274CD, 0xB40A042BD4D8425E, 0x731B26172EE619EB, 0x31EBC7FC870C2F78, 0xBFC9838573709812, 0xFD39626EDA9AAE81, 0x3A28405220A4F534, 0x78D8A1B9894EC3A7,
0x649C294A61B7AD73, 0x266CC8A1C85D9BE0, 0xE17DEA9D3263C055, 0xA38D0B769B89F6C6, 0x2DAF4F0F6FF541AC, 0x6F5FAEE4C61F773F, 0xA84E8CD83C212C8A, 0xEABE6D3395CB1A19,
0x90C79D3FEDD3F122, 0xD2377CD44439C7B1, 0x15265EE8BE079C04, 0x57D6BF0317EDAA97, 0xD9F4FB7AE3911DFD, 0x9B041A914A7B2B6E, 0x5C1538ADB04570DB, 0x1EE5D94619AF4648,
0x02A151B5F156289C, 0x4051B05E58BC1E0F, 0x87409262A28245BA, 0xC5B073890B687329, 0x4B9237F0FF14C443, 0x0962D61B56FEF2D0, 0xCE73F427ACC0A965, 0x8C8315CC052A9FF6,
0x3A80143F5CF17F13, 0x7870F5D4F51B4980, 0xBF61D7E80F251235, 0xFD913603A6CF24A6, 0x73B3727A52B393CC, 0x31439391FB59A55F, 0xF652B1AD0167FEEA, 0xB4A25046A88DC879,
0xA8E6D8B54074A6AD, 0xEA16395EE99E903E, 0x2D071B6213A0CB8B, 0x6FF7FA89BA4AFD18, 0xE1D5BEF04E364A72, 0xA3255F1BE7DC7CE1, 0x64347D271DE22754, 0x26C49CCCB40811C7,
0x5CBD6CC0CC10FAFC, 0x1E4D8D2B65FACC6F, 0xD95CAF179FC497DA, 0x9BAC4EFC362EA149, 0x158E0A85C2521623, 0x577EEB6E6BB820B0, 0x906FC95291867B05, 0xD29F28B9386C4D96,
0xCEDBA04AD0952342, 0x8C2B41A1797F15D1, 0x4B3A639D83414E64, 0x09CA82762AAB78F7, 0x87E8C60FDED7CF9D, 0xC51827E4773DF90E, 0x020905D88D03A2BB, 0x40F9E43324E99428,
0x2CFFE7D5975E55E2, 0x6E0F063E3EB46371, 0xA91E2402C48A38C4, 0xEBEEC5E96D600E57, 0x65CC8190991CB93D, 0x273C607B30F68FAE, 0xE02D4247CAC8D41B, 0xA2DDA3AC6322E288,
0xBE992B5F8BDB8C5C, 0xFC69CAB42231BACF, 0x3B78E888D80FE17A, 0x7988096371E5D7E9, 0xF7AA4D1A85996083, 0xB55AACF12C735610, 0x724B8ECDD64D0DA5, 0x30BB6F267FA73B36,
0x4AC29F2A07BFD00D, 0x08327EC1AE55E69E, 0xCF235CFD546BBD2B, 0x8DD3BD16FD818BB8, 0x03F1F96F09FD3CD2, 0x41011884A0170A41, 0x86103AB85A2951F4, 0xC4E0DB53F3C36767,
0xD8A453A01B3A09B3, 0x9A54B24BB2D03F20, 0x5D45907748EE6495, 0x1FB5719CE1045206, 0x919735E51578E56C, 0xD367D40EBC92D3FF, 0x1476F63246AC884A, 0x568617D9EF46BED9,
0xE085162AB69D5E3C, 0xA275F7C11F7768AF, 0x6564D5FDE549331A, 0x279434164CA30589, 0xA9B6706FB8DFB2E3, 0xEB46918411358470, 0x2C57B3B8EB0BDFC5, 0x6EA7525342E1E956,
0x72E3DAA0AA188782, 0x30133B4B03F2B111, 0xF7021977F9CCEAA4, 0xB5F2F89C5026DC37, 0x3BD0BCE5A45A6B5D, 0x79205D0E0DB05DCE, 0xBE317F32F78E067B, 0xFCC19ED95E6430E8,
0x86B86ED5267CDBD3, 0xC4488F3E8F96ED40, 0x0359AD0275A8B6F5, 0x41A94CE9DC428066, 0xCF8B0890283E370C, 0x8D7BE97B81D4019F, 0x4A6ACB477BEA5A2A, 0x089A2AACD2006CB9,
0x14DEA25F3AF9026D, 0x562E43B4931334FE, 0x913F6188692D6F4B, 0xD3CF8063C0C759D8, 0x5DEDC41A34BBEEB2, 0x1F1D25F19D51D821, 0xD80C07CD676F8394, 0x9AFCE626CE85B507
};
return table;
}
const uint64_t * const table;
};
//***************************************************************************
class crc64_table_poly_0x42f0e1eba9ea3693_reflected
{
crc64_table_poly_0x42f0e1eba9ea3693_reflected()
: table(get_table())
{
}
static const uint64_t * const get_table()
{
static const uint64_t table[256] =
{
0x0000000000000000, 0xC96C5795D7870F42, 0x64B62BCAEBC387A1, 0xADDA7C5F3C4488E3, 0xFB374270A266CC92, 0x325B15E575E1C3D0, 0x9F8169BA49A54B33, 0x56ED3E2F9E224471,
0x7D9BA13851336649, 0xB4F7F6AD86B4690B, 0x192D8AF2BAF0E1E8, 0xD041DD676D77EEAA, 0x86ACE348F355AADB, 0x4FC0B4DD24D2A599, 0xE21AC88218962D7A, 0x2B769F17CF112238,
0xF7A18709FF1EBC66, 0x3ECDD09C2899B324, 0x9317ACC314DD3BC7, 0x5A7BFB56C35A3485, 0x0C96C5795D7870F4, 0xC5FA92EC8AFF7FB6, 0x6820EEB3B6BBF755, 0xA14CB926613CF817,
0x8A3A2631AE2DDA2F, 0x435671A479AAD56D, 0xEE8C0DFB45EE5D8E, 0x27E05A6E926952CC, 0x710D64410C4B16BD, 0xB86133D4DBCC19FF, 0x15BB4F8BE788911C, 0xDCD7181E300F9E5E,
0x7BD0C384FF8F5E33, 0xB2BC941128085171, 0x1F66E84E144CD992, 0xD60ABFDBC3CBD6D0, 0x80E781F45DE992A1, 0x498BD6618A6E9DE3, 0xE451AA3EB62A1500, 0x2D3DFDAB61AD1A42,
0x064B62BCAEBC387A, 0xCF273529793B3738, 0x62FD4976457FBFDB, 0xAB911EE392F8B099, 0xFD7C20CC0CDAF4E8, 0x34107759DB5DFBAA, 0x99CA0B06E7197349, 0x50A65C93309E7C0B,
0x8C71448D0091E255, 0x451D1318D716ED17, 0xE8C76F47EB5265F4, 0x21AB38D23CD56AB6, 0x774606FDA2F72EC7, 0xBE2A516875702185, 0x13F02D374934A966, 0xDA9C7AA29EB3A624,
0xF1EAE5B551A2841C, 0x3886B22086258B5E, 0x955CCE7FBA6103BD, 0x5C3099EA6DE60CFF, 0x0ADDA7C5F3C4488E, 0xC3B1F050244347CC, 0x6E6B8C0F1807CF2F, 0xA707DB9ACF80C06D,
0xF4843657A840A05B, 0x3DE861C27FC7AF19, 0x90321D9D438327FA, 0x595E4A08940428B8, 0x0FB374270A266CC9, 0xC6DF23B2DDA1638B, 0x6B055FEDE1E5EB68, 0xA26908783662E42A,
0x891F976FF973C612, 0x4073C0FA2EF4C950, 0xEDA9BCA512B041B3, 0x24C5EB30C5374EF1, 0x7228D51F5B150A80, 0xBB44828A8C9205C2, 0x169EFED5B0D68D21, 0xDFF2A94067518263,
0x0325B15E575E1C3D, 0xCA49E6CB80D9137F, 0x67939A94BC9D9B9C, 0xAEFFCD016B1A94DE, 0xF812F32EF538D0AF, 0x317EA4BB22BFDFED, 0x9CA4D8E41EFB570E, 0x55C88F71C97C584C,
0x7EBE1066066D7A74, 0xB7D247F3D1EA7536, 0x1A083BACEDAEFDD5, 0xD3646C393A29F297, 0x85895216A40BB6E6, 0x4CE50583738CB9A4, 0xE13F79DC4FC83147, 0x28532E49984F3E05,
0x8F54F5D357CFFE68, 0x4638A2468048F12A, 0xEBE2DE19BC0C79C9, 0x228E898C6B8B768B, 0x7463B7A3F5A932FA, 0xBD0FE036222E3DB8, 0x10D59C691E6AB55B, 0xD9B9CBFCC9EDBA19,
0xF2CF54EB06FC9821, 0x3BA3037ED17B9763, 0x96797F21ED3F1F80, 0x5F1528B43AB810C2, 0x09F8169BA49A54B3, 0xC094410E731D5BF1, 0x6D4E3D514F59D312, 0xA4226AC498DEDC50,
0x78F572DAA8D1420E, 0xB199254F7F564D4C, 0x1C4359104312C5AF, 0xD52F0E859495CAED, 0x83C230AA0AB78E9C, 0x4AAE673FDD3081DE, 0xE7741B60E174093D, 0x2E184CF536F3067F,
0x056ED3E2F9E22447, 0xCC0284772E652B05, 0x61D8F8281221A3E6, 0xA8B4AFBDC5A6ACA4, 0xFE5991925B84E8D5, 0x3735C6078C03E797, 0x9AEFBA58B0476F74, 0x5383EDCD67C06036,
0xB32E4CBE03A75F6F, 0x7A421B2BD420502D, 0xD7986774E864D8CE, 0x1EF430E13FE3D78C, 0x48190ECEA1C193FD, 0x8175595B76469CBF, 0x2CAF25044A02145C, 0xE5C372919D851B1E,
0xCEB5ED8652943926, 0x07D9BA1385133664, 0xAA03C64CB957BE87, 0x636F91D96ED0B1C5, 0x3582AFF6F0F2F5B4, 0xFCEEF8632775FAF6, 0x5134843C1B317215, 0x9858D3A9CCB67D57,
0x448FCBB7FCB9E309, 0x8DE39C222B3EEC4B, 0x2039E07D177A64A8, 0xE955B7E8C0FD6BEA, 0xBFB889C75EDF2F9B, 0x76D4DE52895820D9, 0xDB0EA20DB51CA83A, 0x1262F598629BA778,
0x39146A8FAD8A8540, 0xF0783D1A7A0D8A02, 0x5DA24145464902E1, 0x94CE16D091CE0DA3, 0xC22328FF0FEC49D2, 0x0B4F7F6AD86B4690, 0xA6950335E42FCE73, 0x6FF954A033A8C131,
0xC8FE8F3AFC28015C, 0x0192D8AF2BAF0E1E, 0xAC48A4F017EB86FD, 0x6524F365C06C89BF, 0x33C9CD4A5E4ECDCE, 0xFAA59ADF89C9C28C, 0x577FE680B58D4A6F, 0x9E13B115620A452D,
0xB5652E02AD1B6715, 0x7C0979977A9C6857, 0xD1D305C846D8E0B4, 0x18BF525D915FEFF6, 0x4E526C720F7DAB87, 0x873E3BE7D8FAA4C5, 0x2AE447B8E4BE2C26, 0xE388102D33392364,
0x3F5F08330336BD3A, 0xF6335FA6D4B1B278, 0x5BE923F9E8F53A9B, 0x9285746C3F7235D9, 0xC4684A43A15071A8, 0x0D041DD676D77EEA, 0xA0DE61894A93F609, 0x69B2361C9D14F94B,
0x42C4A90B5205DB73, 0x8BA8FE9E8582D431, 0x267282C1B9C65CD2, 0xEF1ED5546E415390, 0xB9F3EB7BF06317E1, 0x709FBCEE27E418A3, 0xDD45C0B11BA09040, 0x14299724CC279F02,
0x47AA7AE9ABE7FF34, 0x8EC62D7C7C60F076, 0x231C512340247895, 0xEA7006B697A377D7, 0xBC9D3899098133A6, 0x75F16F0CDE063CE4, 0xD82B1353E242B407, 0x114744C635C5BB45,
0x3A31DBD1FAD4997D, 0xF35D8C442D53963F, 0x5E87F01B11171EDC, 0x97EBA78EC690119E, 0xC10699A158B255EF, 0x086ACE348F355AAD, 0xA5B0B26BB371D24E, 0x6CDCE5FE64F6DD0C,
0xB00BFDE054F94352, 0x7967AA75837E4C10, 0xD4BDD62ABF3AC4F3, 0x1DD181BF68BDCBB1, 0x4B3CBF90F69F8FC0, 0x8250E80521188082, 0x2F8A945A1D5C0861, 0xE6E6C3CFCADB0723,
0xCD905CD805CA251B, 0x04FC0B4DD24D2A59, 0xA9267712EE09A2BA, 0x604A2087398EADF8, 0x36A71EA8A7ACE989, 0xFFCB493D702BE6CB, 0x521135624C6F6E28, 0x9B7D62F79BE8616A,
0x3C7AB96D5468A107, 0xF516EEF883EFAE45, 0x58CC92A7BFAB26A6, 0x91A0C532682C29E4, 0xC74DFB1DF60E6D95, 0x0E21AC88218962D7, 0xA3FBD0D71DCDEA34, 0x6A978742CA4AE576,
0x41E11855055BC74E, 0x888D4FC0D2DCC80C, 0x2557339FEE9840EF, 0xEC3B640A391F4FAD, 0xBAD65A25A73D0BDC, 0x73BA0DB070BA049E, 0xDE6071EF4CFE8C7D, 0x170C267A9B79833F,
0xCBDB3E64AB761D61, 0x02B769F17CF11223, 0xAF6D15AE40B59AC0, 0x6601423B97329582, 0x30EC7C140910D1F3, 0xF9802B81DE97DEB1, 0x545A57DEE2D35652, 0x9D36004B35545910,
0xB6409F5CFA457B28, 0x7F2CC8C92DC2746A, 0xD2F6B4961186FC89, 0x1B9AE303C601F3CB, 0x4D77DD2C5823B7BA, 0x841B8AB98FA4B8F8, 0x29C1F6E6B3E0301B, 0xE0ADA17364673F59
};
return table;
}
const uint64_t * const table;
};
//***************************************************************************
/// CRC64 Poly 0x42F0E1EBA9EA3693 policy.
/// Calculates CRC64 using polynomial 0x42F0E1EBA9EA3693
//***************************************************************************
template <const uint64_t INITIAL, const uint64_t XOR_OUT, const bool REFLECT = false>
struct crc64_policy_poly_0x42f0e1eba9ea3693 : public crc64_table_poly_0x42f0e1eba9ea3693
{
typedef uint64_t value_type;
//*************************************************************************
ETL_CONSTEXPR uint64_t initial() const
{
return INITIAL;
}
//*************************************************************************
uint64_t add(uint64_t crc, uint8_t value) const
{
return (crc << 8) ^ table[((crc >> 56) ^ value) & 0xFF];
}
//*************************************************************************
uint64_t final(uint64_t crc) const
{
return crc ^ XOR_OUT;
}
};
//***************************************************************************
/// CRC64 Poly 0x42F0E1EBA9EA3693 reflected policy specialisation.
//***************************************************************************
template <const uint64_t INITIAL, const uint64_t XOR_OUT>
struct crc64_policy_poly_0x42f0e1eba9ea3693<INITIAL, XOR_OUT, true> : public crc64_table_poly_0x42f0e1eba9ea3693_reflected
{
typedef uint64_t value_type;
//*************************************************************************
ETL_CONSTEXPR uint64_t initial() const
{
return INITIAL;
}
//*************************************************************************
uint64_t add(uint64_t crc, uint8_t value) const
{
return (crc >> 8) ^ table[(crc ^ value) & 0xFF];
}
//*************************************************************************
uint64_t final(uint64_t crc) const
{
return crc ^ XOR_OUT;
}
};
//*************************************************************************
/// CRC64 Poly 0x42F0E1EBA9EA3693
//*************************************************************************
template <const uint64_t INITIA, const uint64_t XOR_OUT, const bool REFLECT>
class crc64_poly_0x42f0e1eba9ea3693 : public etl::frame_check_sequence<etl::crc64_policy_poly_0x42f0e1eba9ea3693<INITIA, XOR_OUT, REFLECT> >
{
public:
//*************************************************************************
/// Default constructor.
//*************************************************************************
crc64_poly_0x42f0e1eba9ea3693()
{
this->reset();
}
//*************************************************************************
/// Constructor from range.
/// \param begin Start of the range.
/// \param end End of the range.
//*************************************************************************
template<typename TIterator>
crc64_poly_0x42f0e1eba9ea3693(TIterator begin, const TIterator end)
{
this->reset();
this->add(begin, end);
}
};
}
#endif

View File

@ -0,0 +1,212 @@
///\file
/******************************************************************************
The MIT License(MIT)
Embedded Template Library.
https://github.com/ETLCPP/etl
https://www.etlcpp.com
Copyright(c) 2019 jwellbelove
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files(the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions :
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
******************************************************************************/
#ifndef ETL_CRC8_POLY_0x07_INCLUDED
#define ETL_CRC8_POLY_0x07_INCLUDED
#include <stdint.h>
#include "../platform.h"
#include "../frame_check_sequence.h"
#include "../binary.h"
#include "../stl/iterator.h"
#if defined(ETL_COMPILER_KEIL)
#pragma diag_suppress 1300
#endif
///\defgroup crc8_poly_0x07 8 bit CRC Poly 0x07 calculation
///\ingroup crc
namespace etl
{
//***************************************************************************
class crc8_table_poly_0x07
{
protected:
crc8_table_poly_0x07()
: table(get_table())
{
}
static const uint8_t * const get_table()
{
static const uint8_t table[256] =
{
0x00, 0x07, 0x0E, 0x09, 0x1C, 0x1B, 0x12, 0x15, 0x38, 0x3F, 0x36, 0x31, 0x24, 0x23, 0x2A, 0x2D,
0x70, 0x77, 0x7E, 0x79, 0x6C, 0x6B, 0x62, 0x65, 0x48, 0x4F, 0x46, 0x41, 0x54, 0x53, 0x5A, 0x5D,
0xE0, 0xE7, 0xEE, 0xE9, 0xFC, 0xFB, 0xF2, 0xF5, 0xD8, 0xDF, 0xD6, 0xD1, 0xC4, 0xC3, 0xCA, 0xCD,
0x90, 0x97, 0x9E, 0x99, 0x8C, 0x8B, 0x82, 0x85, 0xA8, 0xAF, 0xA6, 0xA1, 0xB4, 0xB3, 0xBA, 0xBD,
0xC7, 0xC0, 0xC9, 0xCE, 0xDB, 0xDC, 0xD5, 0xD2, 0xFF, 0xF8, 0xF1, 0xF6, 0xE3, 0xE4, 0xED, 0xEA,
0xB7, 0xB0, 0xB9, 0xBE, 0xAB, 0xAC, 0xA5, 0xA2, 0x8F, 0x88, 0x81, 0x86, 0x93, 0x94, 0x9D, 0x9A,
0x27, 0x20, 0x29, 0x2E, 0x3B, 0x3C, 0x35, 0x32, 0x1F, 0x18, 0x11, 0x16, 0x03, 0x04, 0x0D, 0x0A,
0x57, 0x50, 0x59, 0x5E, 0x4B, 0x4C, 0x45, 0x42, 0x6F, 0x68, 0x61, 0x66, 0x73, 0x74, 0x7D, 0x7A,
0x89, 0x8E, 0x87, 0x80, 0x95, 0x92, 0x9B, 0x9C, 0xB1, 0xB6, 0xBF, 0xB8, 0xAD, 0xAA, 0xA3, 0xA4,
0xF9, 0xFE, 0xF7, 0xF0, 0xE5, 0xE2, 0xEB, 0xEC, 0xC1, 0xC6, 0xCF, 0xC8, 0xDD, 0xDA, 0xD3, 0xD4,
0x69, 0x6E, 0x67, 0x60, 0x75, 0x72, 0x7B, 0x7C, 0x51, 0x56, 0x5F, 0x58, 0x4D, 0x4A, 0x43, 0x44,
0x19, 0x1E, 0x17, 0x10, 0x05, 0x02, 0x0B, 0x0C, 0x21, 0x26, 0x2F, 0x28, 0x3D, 0x3A, 0x33, 0x34,
0x4E, 0x49, 0x40, 0x47, 0x52, 0x55, 0x5C, 0x5B, 0x76, 0x71, 0x78, 0x7F, 0x6A, 0x6D, 0x64, 0x63,
0x3E, 0x39, 0x30, 0x37, 0x22, 0x25, 0x2C, 0x2B, 0x06, 0x01, 0x08, 0x0F, 0x1A, 0x1D, 0x14, 0x13,
0xAE, 0xA9, 0xA0, 0xA7, 0xB2, 0xB5, 0xBC, 0xBB, 0x96, 0x91, 0x98, 0x9F, 0x8A, 0x8D, 0x84, 0x83,
0xDE, 0xD9, 0xD0, 0xD7, 0xC2, 0xC5, 0xCC, 0xCB, 0xE6, 0xE1, 0xE8, 0xEF, 0xFA, 0xFD, 0xF4, 0xF3
};
return table;
}
const uint8_t * const table;
};
//***************************************************************************
class crc8_table_poly_0x07_reflected
{
protected:
crc8_table_poly_0x07_reflected()
: table(get_table())
{
}
static const uint8_t * const get_table()
{
static const uint8_t table[256] =
{
0x00, 0x31, 0x62, 0x53, 0xC4, 0xF5, 0xA6, 0x97, 0xB9, 0x88, 0xDB, 0xEA, 0x7D, 0x4C, 0x1F, 0x2E,
0x43, 0x72, 0x21, 0x10, 0x87, 0xB6, 0xE5, 0xD4, 0xFA, 0xCB, 0x98, 0xA9, 0x3E, 0x0F, 0x5C, 0x6D,
0x86, 0xB7, 0xE4, 0xD5, 0x42, 0x73, 0x20, 0x11, 0x3F, 0x0E, 0x5D, 0x6C, 0xFB, 0xCA, 0x99, 0xA8,
0xC5, 0xF4, 0xA7, 0x96, 0x01, 0x30, 0x63, 0x52, 0x7C, 0x4D, 0x1E, 0x2F, 0xB8, 0x89, 0xDA, 0xEB,
0x3D, 0x0C, 0x5F, 0x6E, 0xF9, 0xC8, 0x9B, 0xAA, 0x84, 0xB5, 0xE6, 0xD7, 0x40, 0x71, 0x22, 0x13,
0x7E, 0x4F, 0x1C, 0x2D, 0xBA, 0x8B, 0xD8, 0xE9, 0xC7, 0xF6, 0xA5, 0x94, 0x03, 0x32, 0x61, 0x50,
0xBB, 0x8A, 0xD9, 0xE8, 0x7F, 0x4E, 0x1D, 0x2C, 0x02, 0x33, 0x60, 0x51, 0xC6, 0xF7, 0xA4, 0x95,
0xF8, 0xC9, 0x9A, 0xAB, 0x3C, 0x0D, 0x5E, 0x6F, 0x41, 0x70, 0x23, 0x12, 0x85, 0xB4, 0xE7, 0xD6,
0x7A, 0x4B, 0x18, 0x29, 0xBE, 0x8F, 0xDC, 0xED, 0xC3, 0xF2, 0xA1, 0x90, 0x07, 0x36, 0x65, 0x54,
0x39, 0x08, 0x5B, 0x6A, 0xFD, 0xCC, 0x9F, 0xAE, 0x80, 0xB1, 0xE2, 0xD3, 0x44, 0x75, 0x26, 0x17,
0xFC, 0xCD, 0x9E, 0xAF, 0x38, 0x09, 0x5A, 0x6B, 0x45, 0x74, 0x27, 0x16, 0x81, 0xB0, 0xE3, 0xD2,
0xBF, 0x8E, 0xDD, 0xEC, 0x7B, 0x4A, 0x19, 0x28, 0x06, 0x37, 0x64, 0x55, 0xC2, 0xF3, 0xA0, 0x91,
0x47, 0x76, 0x25, 0x14, 0x83, 0xB2, 0xE1, 0xD0, 0xFE, 0xCF, 0x9C, 0xAD, 0x3A, 0x0B, 0x58, 0x69,
0x04, 0x35, 0x66, 0x57, 0xC0, 0xF1, 0xA2, 0x93, 0xBD, 0x8C, 0xDF, 0xEE, 0x79, 0x48, 0x1B, 0x2A,
0xC1, 0xF0, 0xA3, 0x92, 0x05, 0x34, 0x67, 0x56, 0x78, 0x49, 0x1A, 0x2B, 0xBC, 0x8D, 0xDE, 0xEF,
0x82, 0xB3, 0xE0, 0xD1, 0x46, 0x77, 0x24, 0x15, 0x3B, 0x0A, 0x59, 0x68, 0xFF, 0xCE, 0x9D, 0xAC
};
return table;
}
const uint8_t * const table;
};
//***************************************************************************
/// CRC8 Poly 0x07 policy.
/// Calculates CRC8 using polynomial 0x07
//***************************************************************************
template <const uint8_t INITIAL, const uint8_t XOR_OUT, const bool REFLECT = false>
struct crc8_policy_poly_0x07 : public crc8_table_poly_0x07
{
typedef uint8_t value_type;
//*************************************************************************
ETL_CONSTEXPR uint8_t initial() const
{
return INITIAL;
}
//*************************************************************************
uint8_t add(uint8_t crc, uint8_t value) const
{
return table[crc ^ value];
}
//*************************************************************************
uint8_t final(uint8_t crc) const
{
return crc ^ XOR_OUT;
}
};
//***************************************************************************
/// CRC8 Poly 0x07 reflected policy specialisation.
//***************************************************************************
template <const uint8_t INITIAL, const uint8_t XOR_OUT>
struct crc8_policy_poly_0x07<INITIAL, XOR_OUT, true> : public crc8_table_poly_0x07_reflected
{
typedef uint8_t value_type;
//*************************************************************************
ETL_CONSTEXPR uint8_t initial() const
{
return INITIAL;
}
//*************************************************************************
uint8_t add(uint8_t crc, uint8_t value) const
{
return table[crc ^ value];
}
//*************************************************************************
uint8_t final(uint8_t crc) const
{
return crc ^ XOR_OUT;
}
};
//*************************************************************************
/// CRC8 Poly 0x07
//*************************************************************************
template <const uint8_t INITIAL, const uint8_t XOR_OUT, const bool REFLECT>
class crc8_poly_0x07 : public etl::frame_check_sequence<etl::crc8_policy_poly_0x07<INITIAL, XOR_OUT, REFLECT> >
{
public:
//*************************************************************************
/// Default constructor.
//*************************************************************************
crc8_poly_0x07()
{
this->reset();
}
//*************************************************************************
/// Constructor from range.
/// \param begin Start of the range.
/// \param end End of the range.
//*************************************************************************
template<typename TIterator>
crc8_poly_0x07(TIterator begin, const TIterator end)
{
this->reset();
this->add(begin, end);
}
};
}
#endif

View File

@ -38,8 +38,8 @@ SOFTWARE.
///\ingroup utilities
#define ETL_VERSION_MAJOR 15
#define ETL_VERSION_MINOR 3
#define ETL_VERSION_PATCH 1
#define ETL_VERSION_MINOR 4
#define ETL_VERSION_PATCH 0
#define ETL_VERSION ETL_STRINGIFY(ETL_VERSION_MAJOR) "." ETL_STRINGIFY(ETL_VERSION_MINOR) "." ETL_STRINGIFY(ETL_VERSION_PATCH)
#define ETL_VERSION_W ETL_STRINGIFY(ETL_VERSION_MAJOR) L"." ETL_STRINGIFY(ETL_VERSION_MINOR) L"." ETL_STRINGIFY(ETL_VERSION_PATCH)

View File

@ -1,6 +1,6 @@
{
"name": "Embedded Template Library",
"version": "15.3.1",
"version": "15.4.0",
"authors": {
"name": "John Wellbelove",
"email": "<john.wellbelove@etlcpp.com>"

View File

@ -1,5 +1,5 @@
name=Embedded Template Library
version=15.3.1
version=15.4.0
author= John Wellbelove <john.wellbelove@etlcpp.com>
maintainer=John Wellbelove <john.wellbelove@etlcpp.com>
license=MIT

View File

@ -1,3 +1,8 @@
===============================================================================
15.4.0
Refactored CRC classes for better code sharing and reduced resource requirements
Added new CRC definitions
===============================================================================
15.3.1
Changes to alternate STL limits.h for ARM5 compiler compatibility

View File

@ -36,11 +36,24 @@ SOFTWARE.
#include "etl/crc8_ccitt.h"
#include "etl/crc16.h"
#include "etl/crc16_ccitt.h"
#include "etl/crc16_aug_ccitt.h"
#include "etl/crc16_kermit.h"
#include "etl/crc16_modbus.h"
#include "etl/crc16_usb.h"
#include "etl/crc16_xmodem.h"
#include "etl/crc16_genibus.h"
#include "etl/crc16_x25.h"
#include "etl/crc32.h"
#include "etl/crc32_c.h"
#include "etl/crc32_bzip2.h"
#include "etl/crc32_mpeg2.h"
#include "etl/crc32_posix.h"
#include "etl/crc64_ecma.h"
//*****************************************************************************
// The results for these tests were created from https://crccalc.com/
//*****************************************************************************
namespace
{
SUITE(test_crc)
@ -325,6 +338,286 @@ namespace
CHECK_EQUAL(crc1, crc3);
}
//*************************************************************************
TEST(test_crc16_usb)
{
std::string data("123456789");
uint16_t crc = etl::crc16_usb(data.begin(), data.end());
CHECK_EQUAL(0xB4C8, crc);
}
//*************************************************************************
TEST(test_crc16_usb_add_values)
{
std::string data("123456789");
etl::crc16_usb crc_calculator;
for (size_t i = 0; i < data.size(); ++i)
{
crc_calculator.add(data[i]);
}
uint16_t crc = crc_calculator;
CHECK_EQUAL(0xB4C8, crc);
}
//*************************************************************************
TEST(test_crc16_usb_add_range)
{
std::string data("123456789");
etl::crc16_usb crc_calculator;
crc_calculator.add(data.begin(), data.end());
uint16_t crc = crc_calculator.value();
CHECK_EQUAL(0xB4C8, crc);
}
//*************************************************************************
TEST(test_crc16_usb_add_range_endian)
{
std::vector<uint8_t> data1 = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08 };
std::vector<uint32_t> data2 = { 0x04030201, 0x08070605 };
std::vector<uint8_t> data3 = { 0x08, 0x07, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01 };
uint16_t crc1 = etl::crc16_usb(data1.begin(), data1.end());
uint16_t crc2 = etl::crc16_usb((uint8_t*)&data2[0], (uint8_t*)(&data2[0] + data2.size()));
CHECK_EQUAL(crc1, crc2);
uint16_t crc3 = etl::crc16_usb(data3.rbegin(), data3.rend());
CHECK_EQUAL(crc1, crc3);
}
//*************************************************************************
TEST(test_crc16_xmodem)
{
std::string data("123456789");
uint16_t crc = etl::crc16_xmodem(data.begin(), data.end());
CHECK_EQUAL(0x31C3, crc);
}
//*************************************************************************
TEST(test_crc16_xmodem_add_values)
{
std::string data("123456789");
etl::crc16_xmodem crc_calculator;
for (size_t i = 0; i < data.size(); ++i)
{
crc_calculator.add(data[i]);
}
uint16_t crc = crc_calculator;
CHECK_EQUAL(0x31C3, crc);
}
//*************************************************************************
TEST(test_crc16_xmodem_add_range)
{
std::string data("123456789");
etl::crc16_xmodem crc_calculator;
crc_calculator.add(data.begin(), data.end());
uint16_t crc = crc_calculator.value();
CHECK_EQUAL(0x31C3, crc);
}
//*************************************************************************
TEST(test_crc16_xmodem_add_range_endian)
{
std::vector<uint8_t> data1 = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08 };
std::vector<uint32_t> data2 = { 0x04030201, 0x08070605 };
std::vector<uint8_t> data3 = { 0x08, 0x07, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01 };
uint16_t crc1 = etl::crc16_xmodem(data1.begin(), data1.end());
uint16_t crc2 = etl::crc16_xmodem((uint8_t*)&data2[0], (uint8_t*)(&data2[0] + data2.size()));
CHECK_EQUAL(crc1, crc2);
uint16_t crc3 = etl::crc16_xmodem(data3.rbegin(), data3.rend());
CHECK_EQUAL(crc1, crc3);
}
//*************************************************************************
TEST(test_crc16_aug_ccitt)
{
std::string data("123456789");
uint16_t crc = etl::crc16_aug_ccitt(data.begin(), data.end());
CHECK_EQUAL(0xE5CC, crc);
}
//*************************************************************************
TEST(test_crc16_aug_ccitt_add_values)
{
std::string data("123456789");
etl::crc16_aug_ccitt crc_calculator;
for (size_t i = 0; i < data.size(); ++i)
{
crc_calculator.add(data[i]);
}
uint16_t crc = crc_calculator;
CHECK_EQUAL(0xE5CC, crc);
}
//*************************************************************************
TEST(test_crc16_aug_ccitt_add_range)
{
std::string data("123456789");
etl::crc16_aug_ccitt crc_calculator;
crc_calculator.add(data.begin(), data.end());
uint16_t crc = crc_calculator.value();
CHECK_EQUAL(0xE5CC, crc);
}
//*************************************************************************
TEST(test_crc16_aug_ccitt_add_range_endian)
{
std::vector<uint8_t> data1 = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08 };
std::vector<uint32_t> data2 = { 0x04030201, 0x08070605 };
std::vector<uint8_t> data3 = { 0x08, 0x07, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01 };
uint16_t crc1 = etl::crc16_aug_ccitt(data1.begin(), data1.end());
uint16_t crc2 = etl::crc16_aug_ccitt((uint8_t*)&data2[0], (uint8_t*)(&data2[0] + data2.size()));
CHECK_EQUAL(crc1, crc2);
uint16_t crc3 = etl::crc16_aug_ccitt(data3.rbegin(), data3.rend());
CHECK_EQUAL(crc1, crc3);
}
//*************************************************************************
TEST(test_crc16_genibus)
{
std::string data("123456789");
uint16_t crc = etl::crc16_genibus(data.begin(), data.end());
CHECK_EQUAL(0xD64E, crc);
}
//*************************************************************************
TEST(test_crc16_genibus_add_values)
{
std::string data("123456789");
etl::crc16_genibus crc_calculator;
for (size_t i = 0; i < data.size(); ++i)
{
crc_calculator.add(data[i]);
}
uint16_t crc = crc_calculator;
CHECK_EQUAL(0xD64E, crc);
}
//*************************************************************************
TEST(test_crc16_genibus_add_range)
{
std::string data("123456789");
etl::crc16_genibus crc_calculator;
crc_calculator.add(data.begin(), data.end());
uint16_t crc = crc_calculator.value();
CHECK_EQUAL(0xD64E, crc);
}
//*************************************************************************
TEST(test_crc16_genibus_add_range_endian)
{
std::vector<uint8_t> data1 = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08 };
std::vector<uint32_t> data2 = { 0x04030201, 0x08070605 };
std::vector<uint8_t> data3 = { 0x08, 0x07, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01 };
uint16_t crc1 = etl::crc16_genibus(data1.begin(), data1.end());
uint16_t crc2 = etl::crc16_genibus((uint8_t*)&data2[0], (uint8_t*)(&data2[0] + data2.size()));
CHECK_EQUAL(crc1, crc2);
uint16_t crc3 = etl::crc16_genibus(data3.rbegin(), data3.rend());
CHECK_EQUAL(crc1, crc3);
}
//*************************************************************************
TEST(test_crc16_x25)
{
std::string data("123456789");
uint16_t crc = etl::crc16_x25(data.begin(), data.end());
CHECK_EQUAL(0x906E, crc);
}
//*************************************************************************
TEST(test_crc16_x25_add_values)
{
std::string data("123456789");
etl::crc16_x25 crc_calculator;
for (size_t i = 0; i < data.size(); ++i)
{
crc_calculator.add(data[i]);
}
uint16_t crc = crc_calculator;
CHECK_EQUAL(0x906E, crc);
}
//*************************************************************************
TEST(test_crc16_x25_add_range)
{
std::string data("123456789");
etl::crc16_x25 crc_calculator;
crc_calculator.add(data.begin(), data.end());
uint16_t crc = crc_calculator.value();
CHECK_EQUAL(0x906E, crc);
}
//*************************************************************************
TEST(test_crc16_x25_add_range_endian)
{
std::vector<uint8_t> data1 = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08 };
std::vector<uint32_t> data2 = { 0x04030201, 0x08070605 };
std::vector<uint8_t> data3 = { 0x08, 0x07, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01 };
uint16_t crc1 = etl::crc16_x25(data1.begin(), data1.end());
uint16_t crc2 = etl::crc16_x25((uint8_t*)&data2[0], (uint8_t*)(&data2[0] + data2.size()));
CHECK_EQUAL(crc1, crc2);
uint16_t crc3 = etl::crc16_x25(data3.rbegin(), data3.rend());
CHECK_EQUAL(crc1, crc3);
}
//*************************************************************************
TEST(test_crc32)
{
@ -382,6 +675,234 @@ namespace
CHECK_EQUAL(crc1, crc3);
}
//*************************************************************************
TEST(test_crc32_c)
{
std::string data("123456789");
uint32_t crc = etl::crc32_c(data.begin(), data.end());
CHECK_EQUAL(0xE3069283, crc);
}
//*************************************************************************
TEST(test_crc32_c_add_values)
{
std::string data("123456789");
etl::crc32_c crc_calculator;
for (size_t i = 0; i < data.size(); ++i)
{
crc_calculator.add(data[i]);
}
uint32_t crc = crc_calculator;
CHECK_EQUAL(0xE3069283, crc);
}
//*************************************************************************
TEST(test_crc32_c_add_range)
{
std::string data("123456789");
etl::crc32_c crc_calculator;
crc_calculator.add(data.begin(), data.end());
uint32_t crc = crc_calculator.value();
CHECK_EQUAL(0xE3069283, crc);
}
//*************************************************************************
TEST(test_crc32_c_add_range_endian)
{
std::vector<uint8_t> data1 = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08 };
std::vector<uint32_t> data2 = { 0x04030201, 0x08070605 };
std::vector<uint8_t> data3 = { 0x08, 0x07, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01 };
uint32_t crc1 = etl::crc32_c(data1.begin(), data1.end());
uint32_t crc2 = etl::crc32_c((uint8_t*)&data2[0], (uint8_t*)(&data2[0] + data2.size()));
CHECK_EQUAL(crc1, crc2);
uint32_t crc3 = etl::crc32_c(data3.rbegin(), data3.rend());
CHECK_EQUAL(crc1, crc3);
}
//*************************************************************************
TEST(test_crc32_bzip2)
{
std::string data("123456789");
uint32_t crc = etl::crc32_bzip2(data.begin(), data.end());
CHECK_EQUAL(0xFC891918, crc);
}
//*************************************************************************
TEST(test_crc32_bzip2_add_values)
{
std::string data("123456789");
etl::crc32_bzip2 crc_calculator;
for (size_t i = 0; i < data.size(); ++i)
{
crc_calculator.add(data[i]);
}
uint32_t crc = crc_calculator;
CHECK_EQUAL(0xFC891918, crc);
}
//*************************************************************************
TEST(test_crc32_bzip2_add_range)
{
std::string data("123456789");
etl::crc32_bzip2 crc_calculator;
crc_calculator.add(data.begin(), data.end());
uint32_t crc = crc_calculator.value();
CHECK_EQUAL(0xFC891918, crc);
}
//*************************************************************************
TEST(test_crc32_bzip2_add_range_endian)
{
std::vector<uint8_t> data1 = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08 };
std::vector<uint32_t> data2 = { 0x04030201, 0x08070605 };
std::vector<uint8_t> data3 = { 0x08, 0x07, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01 };
uint32_t crc1 = etl::crc32_bzip2(data1.begin(), data1.end());
uint32_t crc2 = etl::crc32_bzip2((uint8_t*)&data2[0], (uint8_t*)(&data2[0] + data2.size()));
CHECK_EQUAL(crc1, crc2);
uint32_t crc3 = etl::crc32_bzip2(data3.rbegin(), data3.rend());
CHECK_EQUAL(crc1, crc3);
}
//*************************************************************************
TEST(test_crc32_posix)
{
std::string data("123456789");
uint32_t crc = etl::crc32_posix(data.begin(), data.end());
CHECK_EQUAL(0x765E7680, crc);
}
//*************************************************************************
TEST(test_crc32_posix_add_values)
{
std::string data("123456789");
etl::crc32_posix crc_calculator;
for (size_t i = 0; i < data.size(); ++i)
{
crc_calculator.add(data[i]);
}
uint32_t crc = crc_calculator;
CHECK_EQUAL(0x765E7680, crc);
}
//*************************************************************************
TEST(test_crc32_posix_add_range)
{
std::string data("123456789");
etl::crc32_posix crc_calculator;
crc_calculator.add(data.begin(), data.end());
uint32_t crc = crc_calculator.value();
CHECK_EQUAL(0x765E7680, crc);
}
//*************************************************************************
TEST(test_crc32_posix_add_range_endian)
{
std::vector<uint8_t> data1 = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08 };
std::vector<uint32_t> data2 = { 0x04030201, 0x08070605 };
std::vector<uint8_t> data3 = { 0x08, 0x07, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01 };
uint32_t crc1 = etl::crc32_posix(data1.begin(), data1.end());
uint32_t crc2 = etl::crc32_posix((uint8_t*)&data2[0], (uint8_t*)(&data2[0] + data2.size()));
CHECK_EQUAL(crc1, crc2);
uint32_t crc3 = etl::crc32_posix(data3.rbegin(), data3.rend());
CHECK_EQUAL(crc1, crc3);
}
//*************************************************************************
TEST(test_crc32_mpeg2)
{
std::string data("123456789");
uint32_t crc = etl::crc32_mpeg2(data.begin(), data.end());
CHECK_EQUAL(0x0376E6E7, crc);
}
//*************************************************************************
TEST(test_crc32_mpeg2_add_values)
{
std::string data("123456789");
etl::crc32_mpeg2 crc_calculator;
for (size_t i = 0; i < data.size(); ++i)
{
crc_calculator.add(data[i]);
}
uint32_t crc = crc_calculator;
CHECK_EQUAL(0x0376E6E7, crc);
}
//*************************************************************************
TEST(test_crc32_mpeg2_add_range)
{
std::string data("123456789");
etl::crc32_mpeg2 crc_calculator;
crc_calculator.add(data.begin(), data.end());
uint32_t crc = crc_calculator.value();
CHECK_EQUAL(0x0376E6E7, crc);
}
//*************************************************************************
TEST(test_crc32_mpeg2_add_range_endian)
{
std::vector<uint8_t> data1 = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08 };
std::vector<uint32_t> data2 = { 0x04030201, 0x08070605 };
std::vector<uint8_t> data3 = { 0x08, 0x07, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01 };
uint32_t crc1 = etl::crc32_mpeg2(data1.begin(), data1.end());
uint32_t crc2 = etl::crc32_mpeg2((uint8_t*)&data2[0], (uint8_t*)(&data2[0] + data2.size()));
CHECK_EQUAL(crc1, crc2);
uint32_t crc3 = etl::crc32_mpeg2(data3.rbegin(), data3.rend());
CHECK_EQUAL(crc1, crc3);
}
//*************************************************************************
TEST(test_crc64_ecma)
{

View File

@ -710,8 +710,17 @@
<ClInclude Include="..\..\include\etl\combinations.h" />
<ClInclude Include="..\..\include\etl\compare.h" />
<ClInclude Include="..\..\include\etl\constant.h" />
<ClInclude Include="..\..\include\etl\crc16_aug_ccitt.h" />
<ClInclude Include="..\..\include\etl\crc16_genibus.h" />
<ClInclude Include="..\..\include\etl\crc16_modbus.h" />
<ClInclude Include="..\..\include\etl\crc16_usb.h" />
<ClInclude Include="..\..\include\etl\crc16_x25.h" />
<ClInclude Include="..\..\include\etl\crc16_xmodem.h" />
<ClInclude Include="..\..\include\etl\crc32_bzip2.h" />
<ClInclude Include="..\..\include\etl\crc32_c.h" />
<ClInclude Include="..\..\include\etl\crc32_mpeg2.h" />
<ClInclude Include="..\..\include\etl\crc32_posix.h" />
<ClInclude Include="..\..\include\etl\crc8_rohc.h" />
<ClInclude Include="..\..\include\etl\cumulative_moving_average.h" />
<ClInclude Include="..\..\include\etl\delegate.h" />
<ClInclude Include="..\..\include\etl\delegate_service.h" />
@ -729,6 +738,12 @@
<ClInclude Include="..\..\include\etl\private\choose_namespace.h" />
<ClInclude Include="..\..\include\etl\private\choose_pair_types.h" />
<ClInclude Include="..\..\include\etl\private\choose_tag_types.h" />
<ClInclude Include="..\..\include\etl\private\crc16_poly_0x1021_.h" />
<ClInclude Include="..\..\include\etl\private\crc16_poly_0x8005.h" />
<ClInclude Include="..\..\include\etl\private\crc32_poly_0x04c11db7.h" />
<ClInclude Include="..\..\include\etl\private\crc32_poly_0x1edc6f41.h" />
<ClInclude Include="..\..\include\etl\private\crc64_poly_0x42f0e1eba9ea3693.h" />
<ClInclude Include="..\..\include\etl\private\crc8_poly_0x07.h" />
<ClInclude Include="..\..\include\etl\private\to_string_helper.h" />
<ClInclude Include="..\..\include\etl\profiles\armv7.h" />
<ClInclude Include="..\..\include\etl\profiles\armv7_no_stl.h" />
@ -1253,6 +1268,7 @@
<None Include="..\..\include\etl\generate_type_lookup.bat" />
<None Include="..\..\include\etl\generate_type_traits.bat" />
<None Include="..\..\include\etl\generate_variant_pool.bat" />
<None Include="..\..\README.md" />
<None Include="cpp.hint" />
</ItemGroup>
<ItemGroup>

View File

@ -76,6 +76,12 @@
<Filter Include="ETL\Strings">
<UniqueIdentifier>{da88d71d-e5ea-4c26-9807-94616d31addb}</UniqueIdentifier>
</Filter>
<Filter Include="Resource Files\CI">
<UniqueIdentifier>{0eaad66f-3ce3-4952-8ae8-c935e6aa7c1d}</UniqueIdentifier>
</Filter>
<Filter Include="Resource Files\CI\CircleCI">
<UniqueIdentifier>{0d5824b1-3ef9-43e0-b2d5-15d6246b843e}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\include\etl\enum_type.h">
@ -795,6 +801,51 @@
<ClInclude Include="..\..\include\etl\private\choose_pair_types.h">
<Filter>ETL\Private</Filter>
</ClInclude>
<ClInclude Include="..\..\include\etl\private\crc8_poly_0x07.h">
<Filter>ETL\Private</Filter>
</ClInclude>
<ClInclude Include="..\..\include\etl\private\crc16_poly_0x1021_.h">
<Filter>ETL\Private</Filter>
</ClInclude>
<ClInclude Include="..\..\include\etl\private\crc16_poly_0x8005.h">
<Filter>ETL\Private</Filter>
</ClInclude>
<ClInclude Include="..\..\include\etl\private\crc32_poly_0x1edc6f41.h">
<Filter>ETL\Private</Filter>
</ClInclude>
<ClInclude Include="..\..\include\etl\private\crc32_poly_0x04c11db7.h">
<Filter>ETL\Private</Filter>
</ClInclude>
<ClInclude Include="..\..\include\etl\private\crc64_poly_0x42f0e1eba9ea3693.h">
<Filter>ETL\Private</Filter>
</ClInclude>
<ClInclude Include="..\..\include\etl\crc8_rohc.h">
<Filter>ETL\Maths</Filter>
</ClInclude>
<ClInclude Include="..\..\include\etl\crc16_aug_ccitt.h">
<Filter>ETL\Maths</Filter>
</ClInclude>
<ClInclude Include="..\..\include\etl\crc16_genibus.h">
<Filter>ETL\Maths</Filter>
</ClInclude>
<ClInclude Include="..\..\include\etl\crc16_usb.h">
<Filter>ETL\Maths</Filter>
</ClInclude>
<ClInclude Include="..\..\include\etl\crc16_x25.h">
<Filter>ETL\Maths</Filter>
</ClInclude>
<ClInclude Include="..\..\include\etl\crc16_xmodem.h">
<Filter>ETL\Maths</Filter>
</ClInclude>
<ClInclude Include="..\..\include\etl\crc32_bzip2.h">
<Filter>ETL\Maths</Filter>
</ClInclude>
<ClInclude Include="..\..\include\etl\crc32_mpeg2.h">
<Filter>ETL\Maths</Filter>
</ClInclude>
<ClInclude Include="..\..\include\etl\crc32_posix.h">
<Filter>ETL\Maths</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\main.cpp">
@ -1301,6 +1352,9 @@
<None Include="..\..\library.json">
<Filter>Resource Files</Filter>
</None>
<None Include="..\..\README.md">
<Filter>Resource Files</Filter>
</None>
</ItemGroup>
<ItemGroup>
<Text Include="..\..\include\etl\file_error_numbers.txt">