32 #ifndef ROSFLIGHT_FIRMWARE_UTIL_H 33 #define ROSFLIGHT_FIRMWARE_UTIL_H 52 inline uint16_t
checksum_fletcher16(
const uint8_t *src,
size_t len,
bool finalize =
true, uint16_t start = 0)
54 static constexpr
size_t max_block_length = 5800;
57 uint32_t c1 = (
start & 0xFF00) >> 8;
58 uint32_t c2 =
start & 0x00FF;
61 for (; len > 0; len -= block_length)
63 block_length = len < max_block_length ? len : max_block_length;
64 for (
size_t i = 0;
i < block_length;
i++)
74 uint16_t checksum = c1 << 8 | c2;
76 if (finalize && checksum == 0)
84 #endif // ROSFLIGHT_FIRMWARE_UTIL_H
uint16_t checksum_fletcher16(const uint8_t *src, size_t len, bool finalize=true, uint16_t start=0)
Fletcher 16-bit checksum.