ESP8266 part of the f105-motor-demo project (see f105-motor-demo_stm32)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
f105-motor-demo_esp/sbmp/sbmp_checksum.h

40 lines
1.0 KiB

#ifndef SBMP_CHECKSUM_H
#define SBMP_CHECKSUM_H
/**
* Checksum functions for the SBMP framing layer.
*/
#include <stdint.h>
#include <stdbool.h>
#include "sbmp_config.h"
/** Checksum types */
typedef enum {
SBMP_CKSUM_NONE = 0, /*!< No checksum */
SBMP_CKSUM_CRC32 = 32, /*!< ISO CRC-32 */
SBMP_CKSUM_XOR = 1, /*!< Simple XOR check, good for small micros (Arduino) */
} SBMP_CksumType;
/** Get nr of bytes in a checksum */
uint8_t chksum_length(SBMP_CksumType cksum_type);
/** Start calculating a checksum. Updates scratch. */
void cksum_begin(SBMP_CksumType type, uint32_t *scratch);
/** Update the checksum calculation with an incoming byte. Updates scratch. */
void cksum_update(SBMP_CksumType type, uint32_t *scratch, uint8_t byte);
/** Stop the checksum calculation, get the result */
void cksum_end(SBMP_CksumType type, uint32_t *scratch);
/** Check if the calculated checksum matches the received one */
bool cksum_verify(SBMP_CksumType type, uint32_t *scratch, uint32_t received_cksum);
#endif /* SBMP_CHECKSUM_H */