diff --git a/libraries/AP_Math/crc.cpp b/libraries/AP_Math/crc.cpp index 24e1135313..ab0ec7be0e 100644 --- a/libraries/AP_Math/crc.cpp +++ b/libraries/AP_Math/crc.cpp @@ -339,6 +339,14 @@ uint16_t crc16_ccitt(const uint8_t *buf, uint32_t len, uint16_t crc) return crc; } +uint16_t crc16_ccitt_GDL90(const uint8_t *buf, uint32_t len, uint16_t crc) +{ + for (uint32_t i = 0; i < len; i++) { + crc = crc16tab[crc >> 8] ^ (crc << 8) ^ (uint16_t) *buf++; + } + return crc; +} + /** * Calculate Modbus CRC16 for array of bytes * diff --git a/libraries/AP_Math/crc.h b/libraries/AP_Math/crc.h index 276f73b469..bb369302f6 100644 --- a/libraries/AP_Math/crc.h +++ b/libraries/AP_Math/crc.h @@ -37,6 +37,10 @@ uint8_t crc_sum8(const uint8_t *p, uint8_t len); // Contact: Fergus Noble uint16_t crc16_ccitt(const uint8_t *buf, uint32_t len, uint16_t crc); +// CRC16_CCITT algorithm using the GDL90 parser method which is non-standard +// https://www.faa.gov/nextgen/programs/adsb/archival/media/gdl90_public_icd_reva.pdf +uint16_t crc16_ccitt_GDL90(const uint8_t *buf, uint32_t len, uint16_t crc); + uint16_t calc_crc_modbus(uint8_t *buf, uint16_t len); // generate 64bit FNV1a hash from buffer