50 lines
1.0 KiB
C
50 lines
1.0 KiB
C
#ifndef __XC_SOFTWARE_CRC_H__
|
|
#define __XC_SOFTWARE_CRC_H__
|
|
|
|
#include <stdint.h>
|
|
#define TELINK_MODE
|
|
|
|
#define SUPPLEMENTARY_DATA 0x50
|
|
#ifdef TELINK_MODE
|
|
#define SURPLUS_UNIT 1
|
|
#define NUMBER 0x1
|
|
#endif
|
|
|
|
#ifdef BEKEN_MODE
|
|
#define SURPLUS_UNIT 1
|
|
#define NUMBER 0x1
|
|
#endif
|
|
|
|
#ifdef PANCHIP_MODE
|
|
#define SURPLUS_UNIT 2
|
|
#define NUMBER 0x3
|
|
#endif
|
|
|
|
typedef struct
|
|
{
|
|
uint8_t preamble[3];
|
|
uint8_t addr_buff[5];
|
|
uint16_t contorl;
|
|
uint8_t data_buff[32];
|
|
uint8_t crc_data[2];
|
|
} packet_t;
|
|
|
|
typedef struct
|
|
{
|
|
packet_t packt;
|
|
uint8_t crc_dat[64];
|
|
} sf_crc_t;
|
|
|
|
#define DATA_NUM 32
|
|
|
|
uint16_t crc16_ccitt_false(uint8_t *crc_data, uint8_t data_len);
|
|
uint16_t crc16_ccitt_false_d(uint8_t *crc_data, uint8_t data_len);
|
|
uint8_t crc8_rohc(uint8_t *crc_data, uint8_t data_len);
|
|
uint8_t bit_negation(uint8_t data);
|
|
void byte_bigandsmallend(uint8_t data);
|
|
void buff_bigandsmallend(uint8_t *buff, uint8_t buff_len);
|
|
void whiten_shift(uint8_t *shifter);
|
|
uint8_t whiten_data(uint8_t *whiten_data_in, uint8_t data_in_len);
|
|
|
|
#endif //__XC_SOFTWARE_CRC_H__
|