From ff2cfbaafbdf1b09b21a12ea0d8c7a951b7ed0b5 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sun, 27 Oct 2019 22:50:01 +1100 Subject: [PATCH] AP_Math: added smaller footprint crc32 --- libraries/AP_Math/crc.cpp | 16 ++++++++++++++++ libraries/AP_Math/crc.h | 1 + 2 files changed, 17 insertions(+) diff --git a/libraries/AP_Math/crc.cpp b/libraries/AP_Math/crc.cpp index 7c5a017c50..3f0b31a87d 100644 --- a/libraries/AP_Math/crc.cpp +++ b/libraries/AP_Math/crc.cpp @@ -167,6 +167,7 @@ static const uint32_t crc32_tab[] = { 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d }; + uint32_t crc_crc32(uint32_t crc, const uint8_t *buf, uint32_t size) { for (uint32_t i=0; i>= 1; + crc ^= (0xEDB88320 & mask); + } + } + return crc; +} + /* * Copyright (C) 2010 Swift Navigation Inc. * Contact: Fergus Noble diff --git a/libraries/AP_Math/crc.h b/libraries/AP_Math/crc.h index 2a307734ca..a970a99c90 100644 --- a/libraries/AP_Math/crc.h +++ b/libraries/AP_Math/crc.h @@ -22,6 +22,7 @@ uint8_t crc_crc8(const uint8_t *p, uint8_t len); uint16_t crc_xmodem_update(uint16_t crc, uint8_t data); uint16_t crc_xmodem(const uint8_t *data, uint16_t len); uint32_t crc_crc32(uint32_t crc, const uint8_t *buf, uint32_t size); +uint32_t crc32_small(uint32_t crc, const uint8_t *buf, uint32_t size); // Copyright (C) 2010 Swift Navigation Inc. // Contact: Fergus Noble