mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-25 17:25:20 +03:00
Tidy SRXL telemetry implementation
This commit is contained in:
parent
62aff67535
commit
0d1479fdde
3 changed files with 56 additions and 77 deletions
|
@ -44,6 +44,16 @@ uint16_t crc16_ccitt_update(uint16_t crc, const void *data, uint32_t length)
|
|||
return crc;
|
||||
}
|
||||
|
||||
void crc16_ccitt_sbuf_append(sbuf_t *dst, uint8_t *start)
|
||||
{
|
||||
uint16_t crc = 0;
|
||||
const uint8_t * const end = sbufPtr(dst);
|
||||
for (const uint8_t *ptr = start; ptr < end; ++ptr) {
|
||||
crc = crc16_ccitt(crc, *ptr);
|
||||
}
|
||||
sbufWriteU16(dst, crc);
|
||||
}
|
||||
|
||||
uint8_t crc8_dvb_s2(uint8_t crc, unsigned char a)
|
||||
{
|
||||
crc ^= a;
|
||||
|
@ -71,8 +81,8 @@ uint8_t crc8_dvb_s2_update(uint8_t crc, const void *data, uint32_t length)
|
|||
void crc8_dvb_s2_sbuf_append(sbuf_t *dst, uint8_t *start)
|
||||
{
|
||||
uint8_t crc = 0;
|
||||
const uint8_t *end = dst->ptr;
|
||||
for (uint8_t *ptr = start; ptr < end; ++ptr) {
|
||||
const uint8_t * const end = dst->ptr;
|
||||
for (const uint8_t *ptr = start; ptr < end; ++ptr) {
|
||||
crc = crc8_dvb_s2(crc, *ptr);
|
||||
}
|
||||
sbufWriteU8(dst, crc);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue