mirror of https://github.com/ArduPilot/ardupilot
AP_Math: move crc8_dvb_s2 here and add additional crc8 functions
This commit is contained in:
parent
d9f11c1a0a
commit
d4c5b945b3
|
@ -90,6 +90,26 @@ uint8_t crc_crc8(const uint8_t *p, uint8_t len)
|
|||
return crc & 0xFF;
|
||||
}
|
||||
|
||||
// crc8 from betaflight
|
||||
uint8_t crc8_dvb_s2(uint8_t crc, uint8_t a)
|
||||
{
|
||||
return crc8_dvb(crc, a, 0xD5);
|
||||
}
|
||||
|
||||
// crc8 from betaflight
|
||||
uint8_t crc8_dvb(uint8_t crc, uint8_t a, uint8_t seed)
|
||||
{
|
||||
crc ^= a;
|
||||
for (uint8_t i = 0; i < 8; ++i) {
|
||||
if (crc & 0x80) {
|
||||
crc = (crc << 1) ^ seed;
|
||||
} else {
|
||||
crc = crc << 1;
|
||||
}
|
||||
}
|
||||
return crc;
|
||||
}
|
||||
|
||||
/*
|
||||
xmodem CRC thanks to avr-liberty
|
||||
https://github.com/dreamiurg/avr-liberty
|
||||
|
|
|
@ -19,6 +19,8 @@
|
|||
|
||||
uint16_t crc_crc4(uint16_t *data);
|
||||
uint8_t crc_crc8(const uint8_t *p, uint8_t len);
|
||||
uint8_t crc8_dvb_s2(uint8_t crc, uint8_t a);
|
||||
uint8_t crc8_dvb(uint8_t crc, uint8_t a, uint8_t seed);
|
||||
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);
|
||||
|
|
Loading…
Reference in New Issue