MeshProtocolSimulator
1.0.0
|
Calculate CRC simply and fast using this class. Calculation is done using hardware CRC calculation unit. More...
#include <HardwareCRC.h>
Public Member Functions | |
bool | begin () |
Enables CRC hardware calculation unit. More... | |
bool | setPolynomial7 (uint32_t polynomial=CRC7_POLY) |
Sets CRC-7 polynomial. More... | |
bool | setPolynomial8 (uint32_t polynomial=CRC8_POLY) |
Sets CRC-8 polynomial. More... | |
bool | setPolynomial16 (uint32_t polynomial=CRC16_POLY) |
Sets CRC-16 polynomial. More... | |
bool | setPolynomial32 (uint32_t polynomial=CRC32_POLY) |
Sets CRC-32 polynomial. More... | |
uint32_t | getPolynomial () |
Gets polynomial, that was set. More... | |
uint8_t | getPolynomialLength () |
Gets polynomial length in bits. More... | |
uint32_t | getInitValue () |
Gets initial value, that was set using reset(), compute() or computeAndWriteToEnd() method. More... | |
uint32_t | getLastCRC (uint32_t finalXOR=0x00) |
Gets last calculated CRC result. More... | |
void | reset (uint32_t initValue=DEFAULT_HCRC_INITVAL) |
Resets calculation and sets initial value. More... | |
uint32_t | append (const uint8_t data, uint32_t finalXOR=0x00) |
Appends another data to previous CRC calculation and calculates new CRC value. More... | |
uint32_t | append (const uint8_t *data, uint32_t dataLength, uint32_t finalXOR=0x00) |
Appends another data to previous CRC calculation and calculates new CRC value. More... | |
uint32_t | append (const int8_t *data, uint32_t dataLength, uint32_t finalXOR=0x00) |
Appends another data to previous CRC calculation and calculates new CRC value. More... | |
uint32_t | append (const uint16_t data, uint32_t finalXOR=0x00) |
Appends another data to previous CRC calculation and calculates new CRC value. More... | |
uint32_t | append (const uint16_t *data, uint32_t dataLength, uint32_t finalXOR=0x00) |
Appends another data to previous CRC calculation and calculates new CRC value. More... | |
uint32_t | append (const int16_t *data, uint32_t dataLength, uint32_t finalXOR=0x00) |
Appends another data to previous CRC calculation and calculates new CRC value. More... | |
uint32_t | append (const uint32_t data, uint32_t finalXOR=0x00) |
Appends another data to previous CRC calculation and calculates new CRC value. More... | |
uint32_t | append (const uint32_t *data, uint32_t dataLength, uint32_t finalXOR=0x00) |
Appends another data to previous CRC calculation and calculates new CRC value. More... | |
uint32_t | append (const int32_t *data, uint32_t dataLength, uint32_t finalXOR=0x00) |
Appends another data to previous CRC calculation and calculates new CRC value. More... | |
uint32_t | compute (const uint8_t *data, uint32_t dataLength, uint32_t initValue=DEFAULT_HCRC_INITVAL, uint32_t finalXOR=0x00) |
Resets and computes CRC value of the whole array. reset() method is called at the method begin. More... | |
uint32_t | compute (const int8_t *data, uint32_t dataLength, uint32_t initValue=DEFAULT_HCRC_INITVAL, uint32_t finalXOR=0x00) |
Resets and computes CRC value of the whole array. reset() method is called at the method begin. More... | |
uint32_t | compute (const uint16_t *data, uint32_t dataLength, uint32_t initValue=DEFAULT_HCRC_INITVAL, uint32_t finalXOR=0x00) |
Resets and computes CRC value of the whole array. reset() method is called at the method begin. More... | |
uint32_t | compute (const int16_t *data, uint32_t dataLength, uint32_t initValue=DEFAULT_HCRC_INITVAL, uint32_t finalXOR=0x00) |
Resets and computes CRC value of the whole array. reset() method is called at the method begin. More... | |
uint32_t | compute (const uint32_t *data, uint32_t dataLength, uint32_t initValue=DEFAULT_HCRC_INITVAL, uint32_t finalXOR=0x00) |
Resets and computes CRC value of the whole array. reset() method is called at the method begin. More... | |
uint32_t | compute (const int32_t *data, uint32_t dataLength, uint32_t initValue=DEFAULT_HCRC_INITVAL, uint32_t finalXOR=0x00) |
Resets and computes CRC value of the whole array. reset() method is called at the method begin. More... | |
uint32_t | computeAndWriteToEnd (uint8_t *data, uint32_t dataLength, uint32_t initValue=DEFAULT_HCRC_INITVAL, uint32_t finalXOR=0x00) |
Resets, computes CRC value of the whole array and attaches calculated CRC value at the end of the array. reset() method is called at the method begin. More... | |
uint32_t | computeAndWriteToEnd (int8_t *data, uint32_t dataLength, uint32_t initValue=DEFAULT_HCRC_INITVAL, uint32_t finalXOR=0x00) |
Resets, computes CRC value of the whole array and attaches calculated CRC value at the end of the array. reset() method is called at the method begin. More... | |
uint32_t | computeAndWriteToEnd (uint16_t *data, uint32_t dataLength, uint32_t initValue=DEFAULT_HCRC_INITVAL, uint32_t finalXOR=0x00) |
Resets, computes CRC value of the whole array and attaches calculated CRC value at the end of the array. reset() method is called at the method begin. More... | |
uint32_t | computeAndWriteToEnd (int16_t *data, uint32_t dataLength, uint32_t initValue=DEFAULT_HCRC_INITVAL, uint32_t finalXOR=0x00) |
Resets, computes CRC value of the whole array and attaches calculated CRC value at the end of the array. reset() method is called at the method begin. More... | |
uint32_t | computeAndWriteToEnd (uint32_t *data, uint32_t dataLength, uint32_t initValue=DEFAULT_HCRC_INITVAL, uint32_t finalXOR=0x00) |
Resets, computes CRC value of the whole array and attaches calculated CRC value at the end of the array. reset() method is called at the method begin. More... | |
uint32_t | computeAndWriteToEnd (int32_t *data, uint32_t dataLength, uint32_t initValue=DEFAULT_HCRC_INITVAL, uint32_t finalXOR=0x00) |
Resets, computes CRC value of the whole array and attaches calculated CRC value at the end of the array. reset() method is called at the method begin. More... | |
bool | check (const uint8_t *data, uint32_t dataLength, uint32_t initValue=DEFAULT_HCRC_INITVAL, uint32_t finalXOR=0x00) |
Checks if the array (with CRC attached at the end) is valid. reset() method is called at the method begin. More... | |
bool | check (const int8_t *data, uint32_t dataLength, uint32_t initValue=DEFAULT_HCRC_INITVAL, uint32_t finalXOR=0x00) |
Checks if the array (with CRC attached at the end) is valid. reset() method is called at the method begin. More... | |
bool | check (const uint16_t *data, uint32_t dataLength, uint32_t initValue=DEFAULT_HCRC_INITVAL, uint32_t finalXOR=0x00) |
Checks if the array (with CRC attached at the end) is valid. reset() method is called at the method begin. More... | |
bool | check (const int16_t *data, uint32_t dataLength, uint32_t initValue=DEFAULT_HCRC_INITVAL, uint32_t finalXOR=0x00) |
Checks if the array (with CRC attached at the end) is valid. reset() method is called at the method begin. More... | |
bool | check (const uint32_t *data, uint32_t dataLength, uint32_t initValue=DEFAULT_HCRC_INITVAL, uint32_t finalXOR=0x00) |
Checks if the array (with CRC attached at the end) is valid. reset() method is called at the method begin. More... | |
bool | check (const int32_t *data, uint32_t dataLength, uint32_t initValue=DEFAULT_HCRC_INITVAL, uint32_t finalXOR=0x00) |
Checks if the array (with CRC attached at the end) is valid. reset() method is called at the method begin. More... | |
uint32_t | getCheckValue (uint32_t initValue=DEFAULT_HCRC_INITVAL, uint32_t finalXOR=0x00) |
Calculates CRC check value. When settings were not changed, last check value is returned. To validate array(with CRC at the end), compute it's CRC value again and compare to the check value. More... | |
bool | setInputReverse (bool reverse) |
Sets, if input data bits will be reversed(reflected) or not. More... | |
bool | setOutputReverse (bool reverse) |
Sets, if output CRC data bits will be reversed(reflected) or not. More... | |
bool | getInputReverse () |
Gets, if input data bits will be reversed(reflected) or not. More... | |
bool | getOutputReverse () |
Gets, if output CRC data bits will be reversed(reflected) or not. More... | |
void | end () |
Disables hardware CRC calculation unit. | |
Static Public Attributes | |
static const bool | isCustomPolynomialSupported = 0 |
True when custom polynomials are supported. Methods setPolynomial7(), setPolynomial8(), setPolynomial16(), setPolynomial32() will work correctly. If not, CRC-32 polynomial is used. | |
static const bool | isIOReverseSupported = 0 |
True when input / output reversion (reflection) is supported. | |
static const bool | isCustomInitValueSupported = 0 |
True when custom initial value is supported, if not, 0xFFFFFFFFUL is set. | |
Protected Member Functions | |
void | setInputReverseSize (uint32_t reverse) |
Sets input reverse size to CR register. More... | |
Protected Attributes | |
uint8_t | lastCR = 0xFF |
uint32_t | lastFXOR = 0 |
uint32_t | lastCRCCheckValue = 0 |
uint8_t | inputReverse = HCRC_IN_REVERSE_DISABLED |
Calculate CRC simply and fast using this class. Calculation is done using hardware CRC calculation unit.
Pros:
|
inline |
Appends another data to previous CRC calculation and calculates new CRC value.
data | Array of half-words (2 bytes) to add. |
dataLength | Count of half-words in data array. |
finalXOR | Value, that is used to XOR by bits the calculated result. Set to 0 if you want to disable final XORing. |
|
inline |
Appends another data to previous CRC calculation and calculates new CRC value.
data | Array of words (4 bytes) to add. |
dataLength | Count of words in data array. |
finalXOR | Value, that is used to XOR by bits the calculated result. Set to 0 if you want to disable final XORing. |
|
inline |
Appends another data to previous CRC calculation and calculates new CRC value.
data | Byte array to add. |
dataLength | Count of bytes in data array. |
finalXOR | Value, that is used to XOR by bits the calculated result. Set to 0 if you want to disable final XORing. |
|
inline |
Appends another data to previous CRC calculation and calculates new CRC value.
data | Array of half-words (2 bytes) to add. |
dataLength | Count of half-words in data array. |
finalXOR | Value, that is used to XOR by bits the calculated result. Set to 0 if you want to disable final XORing. |
|
inline |
Appends another data to previous CRC calculation and calculates new CRC value.
data | One half-word (2 bytes) to add. |
finalXOR | Value, that is used to XOR by bits the calculated result. Set to 0 if you want to disable final XORing. |
|
inline |
Appends another data to previous CRC calculation and calculates new CRC value.
data | Array of words (4 bytes) to add. |
dataLength | Count of words in data array. |
finalXOR | Value, that is used to XOR by bits the calculated result. Set to 0 if you want to disable final XORing. |
|
inline |
Appends another data to previous CRC calculation and calculates new CRC value.
data | One word (4 bytes) to add. |
finalXOR | Value, that is used to XOR by bits the calculated result. Set to 0 if you want to disable final XORing. |
|
inline |
Appends another data to previous CRC calculation and calculates new CRC value.
data | Byte array to add. |
dataLength | Count of bytes in data array. |
finalXOR | Value, that is used to XOR by bits the calculated result. Set to 0 if you want to disable final XORing. |
|
inline |
Appends another data to previous CRC calculation and calculates new CRC value.
data | One byte to add. |
finalXOR | Value, that is used to XOR by bits the calculated result. Set to 0 if you want to disable final XORing. |
|
inline |
Enables CRC hardware calculation unit.
|
inline |
Checks if the array (with CRC attached at the end) is valid. reset() method is called at the method begin.
data | Array of half-words (2 bytes) to check. CRC has to be at the end of the array. |
dataLength | Count of half-words (2 bytes) in data array (excluding CRC). |
initValue | Initial calculation value. |
finalXOR | Value, that is used to XOR by bits the calculated result. Set to 0 if you want to disable final XORing. |
|
inline |
Checks if the array (with CRC attached at the end) is valid. reset() method is called at the method begin.
data | Array of words (4 bytes) to check. CRC has to be at the end of the array. |
dataLength | Count of words (4 bytes) in data array (excluding CRC). |
initValue | Initial calculation value. |
finalXOR | Value, that is used to XOR by bits the calculated result. Set to 0 if you want to disable final XORing. |
|
inline |
Checks if the array (with CRC attached at the end) is valid. reset() method is called at the method begin.
data | Array of bytes to check. CRC has to be at the end of the array. |
dataLength | Count of bytes in data array (excluding CRC). |
initValue | Initial calculation value. |
finalXOR | Value, that is used to XOR by bits the calculated result. Set to 0 if you want to disable final XORing. |
|
inline |
Checks if the array (with CRC attached at the end) is valid. reset() method is called at the method begin.
data | Array of half-words (2 bytes) to check. CRC has to be at the end of the array. |
dataLength | Count of half-words (2 bytes) in data array (excluding CRC). |
initValue | Initial calculation value. |
finalXOR | Value, that is used to XOR by bits the calculated result. Set to 0 if you want to disable final XORing. |
|
inline |
Checks if the array (with CRC attached at the end) is valid. reset() method is called at the method begin.
data | Array of words (4 bytes) to check. CRC has to be at the end of the array. |
dataLength | Count of words (4 bytes) in data array (excluding CRC). |
initValue | Initial calculation value. |
finalXOR | Value, that is used to XOR by bits the calculated result. Set to 0 if you want to disable final XORing. |
|
inline |
Checks if the array (with CRC attached at the end) is valid. reset() method is called at the method begin.
data | Array of bytes to check. CRC has to be at the end of the array. |
dataLength | Count of bytes in data array (excluding CRC). |
initValue | Initial calculation value. |
finalXOR | Value, that is used to XOR by bits the calculated result. Set to 0 if you want to disable final XORing. |
|
inline |
Resets and computes CRC value of the whole array. reset() method is called at the method begin.
data | Array of half-words (2 bytes) to add. |
dataLength | Count of half-words (2 bytes) in data array. |
initValue | Initial calculation value. |
finalXOR | Value, that is used to XOR by bits the calculated result. Set to 0 if you want to disable final XORing. |
|
inline |
Resets and computes CRC value of the whole array. reset() method is called at the method begin.
data | Array of words (4 bytes) to add. |
dataLength | Count of words (4 bytes) in data array. |
initValue | Initial calculation value. |
finalXOR | Value, that is used to XOR by bits the calculated result. Set to 0 if you want to disable final XORing. |
|
inline |
Resets and computes CRC value of the whole array. reset() method is called at the method begin.
data | Array of bytes to compute. |
dataLength | Count of bytes in data array. |
initValue | Initial calculation value. |
finalXOR | Value, that is used to XOR by bits the calculated result. Set to 0 if you want to disable final XORing. |
|
inline |
Resets and computes CRC value of the whole array. reset() method is called at the method begin.
data | Array of half-words (2 bytes) to add. |
dataLength | Count of half-words (2 bytes) in data array. |
initValue | Initial calculation value. |
finalXOR | Value, that is used to XOR by bits the calculated result. Set to 0 if you want to disable final XORing. |
|
inline |
Resets and computes CRC value of the whole array. reset() method is called at the method begin.
data | Array of words (4 bytes) to add. |
dataLength | Count of words (4 bytes) in data array. |
initValue | Initial calculation value. |
finalXOR | Value, that is used to XOR by bits the calculated result. Set to 0 if you want to disable final XORing. |
|
inline |
Resets and computes CRC value of the whole array. reset() method is called at the method begin.
data | Array of bytes to compute. |
dataLength | Count of bytes in data array. |
initValue | Initial calculation value. |
finalXOR | Value, that is used to XOR by bits the calculated result. Set to 0 if you want to disable final XORing. |
|
inline |
Resets, computes CRC value of the whole array and attaches calculated CRC value at the end of the array. reset() method is called at the method begin.
data | Array of half-words (2 bytes) to add. At the end of array must be reserved 4 bytes when CRC-32, 2 bytes when CRC-16 and 1 byte when CRC-8 or CRC-7 is used. |
dataLength | Count of half-words (2 bytes) in data array. Excluding bytes reserved for CRC value. |
initValue | Initial calculation value. |
finalXOR | Value, that is used to XOR by bits the calculated result. Set to 0 if you want to disable final XORing. |
|
inline |
Resets, computes CRC value of the whole array and attaches calculated CRC value at the end of the array. reset() method is called at the method begin.
data | Array of words (4 bytes) to add. At the end of array must be reserved 4 bytes when CRC-32, 2 bytes when CRC-16 and 1 byte when CRC-8 or CRC-7 is used. |
dataLength | Count of words (4 bytes) in data array. Excluding bytes reserved for CRC value. |
initValue | Initial calculation value. |
finalXOR | Value, that is used to XOR by bits the calculated result. Set to 0 if you want to disable final XORing. |
|
inline |
Resets, computes CRC value of the whole array and attaches calculated CRC value at the end of the array. reset() method is called at the method begin.
data | Array of bytes to compute. At the end of array must be reserved 4 bytes when CRC-32, 2 bytes when CRC-16 and 1 byte when CRC-8 or CRC-7 is used. |
dataLength | Count of bytes in data array. Excluding bytes reserved for CRC value. |
initValue | Initial calculation value. |
finalXOR | Value, that is used to XOR by bits the calculated result. Set to 0 if you want to disable final XORing. |
|
inline |
Resets, computes CRC value of the whole array and attaches calculated CRC value at the end of the array. reset() method is called at the method begin.
data | Array of half-words (2 bytes) to add. At the end of array must be reserved 4 bytes when CRC-32, 2 bytes when CRC-16 and 1 byte when CRC-8 or CRC-7 is used. |
dataLength | Count of half-words (2 bytes) in data array. Excluding bytes reserved for CRC value. |
initValue | Initial calculation value. |
finalXOR | Value, that is used to XOR by bits the calculated result. Set to 0 if you want to disable final XORing. |
|
inline |
Resets, computes CRC value of the whole array and attaches calculated CRC value at the end of the array. reset() method is called at the method begin.
data | Array of words (4 bytes) to add. At the end of array must be reserved 4 bytes when CRC-32, 2 bytes when CRC-16 and 1 byte when CRC-8 or CRC-7 is used. |
dataLength | Count of words (4 bytes) in data array. Excluding bytes reserved for CRC value. |
initValue | Initial calculation value. |
finalXOR | Value, that is used to XOR by bits the calculated result. Set to 0 if you want to disable final XORing. |
|
inline |
Resets, computes CRC value of the whole array and attaches calculated CRC value at the end of the array. reset() method is called at the method begin.
data | Array of bytes to compute. At the end of array must be reserved 4 bytes when CRC-32, 2 bytes when CRC-16 and 1 byte when CRC-8 or CRC-7 is used. |
dataLength | Count of bytes in data array. Excluding bytes reserved for CRC value. |
initValue | Initial calculation value. |
finalXOR | Value, that is used to XOR by bits the calculated result. Set to 0 if you want to disable final XORing. |
|
inline |
Calculates CRC check value. When settings were not changed, last check value is returned. To validate array(with CRC at the end), compute it's CRC value again and compare to the check value.
initValue | Initial calculation value. |
finalXOR | Value, that is used to XOR by bits the calculated result. Set to 0 if you want to disable final XORing. |
|
inline |
Gets initial value, that was set using reset(), compute() or computeAndWriteToEnd() method.
|
inline |
Gets, if input data bits will be reversed(reflected) or not.
|
inline |
Gets last calculated CRC result.
param | finalXOR Value, that is used to XOR by bits the calculated result. Set to 0 if you want to disable final XORing. |
|
inline |
Gets, if output CRC data bits will be reversed(reflected) or not.
|
inline |
Gets polynomial, that was set.
|
inline |
Gets polynomial length in bits.
|
inline |
Resets calculation and sets initial value.
initValue | Initial calculation value. |
|
inline |
Sets, if input data bits will be reversed(reflected) or not.
|
inlineprotected |
Sets input reverse size to CR register.
reverse | Size to set. |
|
inline |
Sets, if output CRC data bits will be reversed(reflected) or not.
|
inline |
Sets CRC-16 polynomial.
polynomial | Custom CRC-16 polynomial. See CRC_Poly_Terms to create custom polynomial, or see Def_CRC_Poly to use most used polynomials. |
|
inline |
Sets CRC-32 polynomial.
polynomial | Custom CRC-32 polynomial. See CRC_Poly_Terms to create custom polynomial, or see Def_CRC_Poly to use most used polynomials. |
|
inline |
Sets CRC-7 polynomial.
polynomial | Custom CRC-7 polynomial. See CRC_Poly_Terms to create custom polynomial, or see Def_CRC_Poly to use most used polynomials. |
|
inline |
Sets CRC-8 polynomial.
polynomial | Custom CRC-8 polynomial. See CRC_Poly_Terms to create custom polynomial, or see Def_CRC_Poly to use most used polynomials. |