28 lines
391 B
C
28 lines
391 B
C
|
|
||
|
#ifndef CRC_H_
|
||
|
#define CRC_H_
|
||
|
|
||
|
#include <stdint.h>
|
||
|
#include <avr/pgmspace.h>
|
||
|
#include <avr/io.h>
|
||
|
|
||
|
|
||
|
#define CRC_INIT_VALUE (0x0000)
|
||
|
#define CRC_LEN (2)
|
||
|
|
||
|
extern const uint16_t crc16_table[] PROGMEM;
|
||
|
|
||
|
|
||
|
static inline uint16_t crc_step(uint16_t old_crc, uint8_t new_byte)
|
||
|
{
|
||
|
uint16_t crc;
|
||
|
crc = (old_crc >> 8) ^ crc16_table[new_byte ^ (old_crc & 0xff)];
|
||
|
return crc;
|
||
|
}
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
#endif // CRC_H_
|