OpenDTU-old/lib/Hoymiles/src/crc.h
2023-12-12 00:21:14 +01:00

15 lines
465 B
C++

// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
#include <cstdint>
#define CRC8_INIT 0x00
#define CRC8_POLY 0x01
#define CRC16_MODBUS_POLYNOM 0xA001
#define CRC16_NRF24_POLYNOM 0x1021
uint8_t crc8(const uint8_t buf[], const uint8_t len);
uint16_t crc16(const uint8_t buf[], const uint8_t len, const uint16_t start = 0xffff);
uint16_t crc16nrf24(const uint8_t buf[], const uint16_t lenBits, const uint16_t startBit = 0, const uint16_t crcIn = 0xffff);