AP_Math: added CRC16_CCITT non-standard variant

This commit is contained in:
Tom Pittenger 2021-04-27 00:01:46 -07:00 committed by Andrew Tridgell
parent f16e1cac0d
commit 8c9dcf4ad8
2 changed files with 12 additions and 0 deletions

View File

@ -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
*

View File

@ -37,6 +37,10 @@ uint8_t crc_sum8(const uint8_t *p, uint8_t len);
// Contact: Fergus Noble <fergus@swift-nav.com>
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