Skip to content

Commit

Permalink
0.1.5 CRC
Browse files Browse the repository at this point in the history
  • Loading branch information
RobTillaart committed Dec 30, 2021
1 parent 6764965 commit ea8ae7e
Show file tree
Hide file tree
Showing 11 changed files with 14 additions and 14 deletions.
8 changes: 4 additions & 4 deletions libraries/CRC/CRC.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ uint64_t reverse64(uint64_t in)
///////////////////////////////////////////////////////////////////////////////////

// CRC POLYNOME = x8 + x5 + x4 + 1 = 1001 1000 = 0x8C
uint8_t crc8(uint8_t *array, uint8_t length, uint8_t polynome = 0xD5, uint8_t startmask = 0x00, uint8_t endmask = 0x00, bool reverseIn = false, bool reverseOut = false)
uint8_t crc8(const uint8_t *array, uint8_t length, const uint8_t polynome = 0xD5, const uint8_t startmask = 0x00, const uint8_t endmask = 0x00, const bool reverseIn = false, const bool reverseOut = false)
{
uint8_t crc = startmask;
while (length--)
Expand Down Expand Up @@ -96,7 +96,7 @@ uint8_t crc8(uint8_t *array, uint8_t length, uint8_t polynome = 0xD5, uint8_t st


// CRC POLYNOME = x15 + 1 = 1000 0000 0000 0001 = 0x8001
uint16_t crc16(uint8_t *array, uint8_t length, uint16_t polynome = 0x8001, uint16_t startmask = 0x0000, uint16_t endmask = 0x0000, bool reverseIn = false, bool reverseOut = false)
uint16_t crc16(const uint8_t *array, uint8_t length, const uint16_t polynome = 0x8001, const uint16_t startmask = 0x0000, const uint16_t endmask = 0x0000, const bool reverseIn = false, const bool reverseOut = false)
{
uint16_t crc = startmask;
while (length--)
Expand Down Expand Up @@ -131,7 +131,7 @@ uint16_t crc16_CCITT(uint8_t *array, uint8_t length)


// CRC-32 POLYNOME = x32 + ..... + 1
uint32_t crc32(uint8_t *array, uint8_t length, uint32_t polynome = 0x04C11DB7, uint32_t startmask = 0, uint32_t endmask = 0, bool reverseIn = false, bool reverseOut = false)
uint32_t crc32(const uint8_t *array, uint8_t length, const uint32_t polynome = 0x04C11DB7, const uint32_t startmask = 0, const uint32_t endmask = 0, const bool reverseIn = false, const bool reverseOut = false)
{
uint32_t crc = startmask;
while (length--)
Expand Down Expand Up @@ -159,7 +159,7 @@ uint32_t crc32(uint8_t *array, uint8_t length, uint32_t polynome = 0x04C11DB7, u


// CRC-CCITT POLYNOME = x64 + ..... + 1
uint64_t crc64(uint8_t *array, uint8_t length, uint64_t polynome, uint64_t startmask, uint64_t endmask, bool reverseIn, bool reverseOut)
uint64_t crc64(const uint8_t *array, uint8_t length, const uint64_t polynome, const uint64_t startmask, const uint64_t endmask, const bool reverseIn, const bool reverseOut)
{
uint64_t crc = startmask;
while (length--)
Expand Down
2 changes: 1 addition & 1 deletion libraries/CRC/CRC16.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ void CRC16::add(uint8_t value)
}


void CRC16::add(uint8_t * array, uint32_t length)
void CRC16::add(const uint8_t * array, uint8_t length)
{
_count += length;
while (length--)
Expand Down
2 changes: 1 addition & 1 deletion libraries/CRC/CRC16.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class CRC16
void setReverseOut(bool reverseOut) { _reverseOut = reverseOut; };

void add(uint8_t value);
void add(uint8_t * array, uint32_t length);
void add(const uint8_t * array, uint8_t length);

uint16_t getCRC(); // returns CRC
uint32_t count() { return _count; };
Expand Down
2 changes: 1 addition & 1 deletion libraries/CRC/CRC32.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ void CRC32::add(uint8_t value)
}


void CRC32::add(uint8_t * array, uint32_t length)
void CRC32::add(const uint8_t * array, uint8_t length)
{
_count += length;
while (length--)
Expand Down
2 changes: 1 addition & 1 deletion libraries/CRC/CRC32.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class CRC32
void setReverseOut(bool reverseOut) { _reverseOut = reverseOut; };

void add(uint8_t value);
void add(uint8_t * array, uint32_t length);
void add(const uint8_t * array, uint8_t length);

uint32_t getCRC(); // returns CRC
uint32_t count() { return _count; };
Expand Down
2 changes: 1 addition & 1 deletion libraries/CRC/CRC64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ void CRC64::add(uint8_t value)
}


void CRC64::add(uint8_t * array, uint32_t length)
void CRC64::add(const uint8_t * array, uint8_t length)
{
_count += length;
while (length--)
Expand Down
2 changes: 1 addition & 1 deletion libraries/CRC/CRC64.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class CRC64
void setReverseOut(bool reverseOut) { _reverseOut = reverseOut; };

void add(uint8_t value);
void add(uint8_t * array, uint32_t length);
void add(const uint8_t * array, uint8_t length);

uint64_t getCRC(); // returns CRC
uint64_t count() { return _count; };
Expand Down
2 changes: 1 addition & 1 deletion libraries/CRC/CRC8.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ void CRC8::add(uint8_t value)
}


void CRC8::add(uint8_t * array, uint32_t length)
void CRC8::add(const uint8_t * array, uint8_t length)
{
_count += length;
while (length--)
Expand Down
2 changes: 1 addition & 1 deletion libraries/CRC/CRC8.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class CRC8
void setReverseOut(bool reverseOut) { _reverseOut = reverseOut; };

void add(uint8_t value);
void add(uint8_t * array, uint32_t length);
void add(const uint8_t * array, uint8_t length);

uint8_t getCRC(); // returns CRC
uint32_t count() { return _count; };
Expand Down
2 changes: 1 addition & 1 deletion libraries/CRC/library.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"type": "git",
"url": "https://github.com/RobTillaart/CRC"
},
"version": "0.1.4",
"version": "0.1.5",
"license": "MIT",
"frameworks": "arduino",
"platforms": "*",
Expand Down
2 changes: 1 addition & 1 deletion libraries/CRC/library.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name=CRC
version=0.1.4
version=0.1.5
author=Rob Tillaart <[email protected]>
maintainer=Rob Tillaart <[email protected]>
sentence=Library for CRC for Arduino
Expand Down

0 comments on commit ea8ae7e

Please sign in to comment.