From 7102205be3f20739bf55eb42c4177305f881fed0 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Fri, 1 Dec 2023 09:00:05 +1100 Subject: [PATCH] AP_Math: added crc_sum_of_bytes_16() --- libraries/AP_Math/crc.cpp | 14 ++++++++++---- libraries/AP_Math/crc.h | 5 ++++- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/libraries/AP_Math/crc.cpp b/libraries/AP_Math/crc.cpp index 985a02c290..de81543b48 100644 --- a/libraries/AP_Math/crc.cpp +++ b/libraries/AP_Math/crc.cpp @@ -599,13 +599,19 @@ uint8_t parity(uint8_t byte) return p; } -// sums the bytes in the supplied buffer, returns that sum mod 256 -// (i.e. shoved into a uint8_t) -uint8_t crc_sum_of_bytes(uint8_t *data, uint16_t count) +// sums the bytes in the supplied buffer, returns that sum mod 0xFFFF +uint16_t crc_sum_of_bytes_16(const uint8_t *data, uint16_t count) { - uint8_t ret = 0; + uint16_t ret = 0; for (uint32_t i=0; i