From 4f8cc206da118dcc1ebdc7e0bfbd3990f50ee834 Mon Sep 17 00:00:00 2001 From: Martin Budden Date: Mon, 14 Aug 2017 09:57:44 +0100 Subject: [PATCH] Use common CRC function --- src/main/telemetry/crsf.c | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/src/main/telemetry/crsf.c b/src/main/telemetry/crsf.c index 7df74777ad..8d5f8952ec 100644 --- a/src/main/telemetry/crsf.c +++ b/src/main/telemetry/crsf.c @@ -67,19 +67,9 @@ static void crsfInitializeFrame(sbuf_t *dst) sbufWriteU8(dst, CRSF_ADDRESS_BROADCAST); } -static void crsfWriteCrc(sbuf_t *dst, uint8_t *start) -{ - uint8_t crc = 0; - uint8_t *end = sbufPtr(dst); - for (uint8_t *ptr = start; ptr < end; ++ptr) { - crc = crc8_dvb_s2(crc, *ptr); - } - sbufWriteU8(dst, crc); -} - static void crsfFinalize(sbuf_t *dst) { - crsfWriteCrc(dst, &crsfFrame[2]); // start at byte 2, since CRC does not include device address and frame length + crc8_dvb_s2_sbuf_append(dst, &crsfFrame[2]); // start at byte 2, since CRC does not include device address and frame length sbufSwitchToReader(dst, crsfFrame); // write the telemetry frame to the receiver. crsfRxWriteTelemetryData(sbufPtr(dst), sbufBytesRemaining(dst)); @@ -87,7 +77,7 @@ static void crsfFinalize(sbuf_t *dst) static int crsfFinalizeBuf(sbuf_t *dst, uint8_t *frame) { - crsfWriteCrc(dst, &crsfFrame[2]); // start at byte 2, since CRC does not include device address and frame length + crc8_dvb_s2_sbuf_append(dst, &crsfFrame[2]); // start at byte 2, since CRC does not include device address and frame length sbufSwitchToReader(dst, crsfFrame); const int frameSize = sbufBytesRemaining(dst); for (int ii = 0; sbufBytesRemaining(dst); ++ii) {