summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/crc_byte.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/lib/crc_byte.c b/src/lib/crc_byte.c
index 0ac006363a..c04449d13f 100644
--- a/src/lib/crc_byte.c
+++ b/src/lib/crc_byte.c
@@ -36,3 +36,17 @@ uint16_t crc16_byte(uint16_t prev_crc, uint8_t data)
prev_crc ^= ((prev_crc & 0xff) << 4) << 1;
return prev_crc;
}
+
+uint32_t crc32_byte(uint32_t prev_crc, uint8_t data)
+{
+ prev_crc ^= (uint32_t)data << 24;
+
+ for (int i = 0; i < 8; i++) {
+ if ((prev_crc & 0x80000000UL) != 0)
+ prev_crc = ((prev_crc << 1) ^ 0x04C11DB7UL);
+ else
+ prev_crc <<= 1;
+ }
+
+ return prev_crc;
+}