| 1 | #ifndef CRC16_H |
| 2 | #define CRC16_H |
| 3 | /* |
| 4 | * Derived from CRC algorithm for JTAG ICE mkII, published in Atmel |
| 5 | * Appnote AVR067. Converted from C++ to C. |
| 6 | */ |
| 7 | /* $Id: crc16.h 110 2005-05-27 20:42:13Z joerg_wunsch $ */ |
| 8 | |
| 9 | #if defined(__cplusplus) |
| 10 | extern "C" { |
| 11 | #endif |
| 12 | unsigned short crcsum(const unsigned char* message, |
| 13 | unsigned long length, |
| 14 | unsigned short crc); |
| 15 | /* |
| 16 | * Verify that the last two bytes is a (LSB first) valid CRC of the |
| 17 | * message. |
| 18 | */ |
| 19 | int crcverify(const unsigned char* message, |
| 20 | unsigned long length); |
| 21 | /* |
| 22 | * Append a two byte CRC (LSB first) to message. length is size of |
| 23 | * message excluding crc. Space for the CRC bytes must be allocated |
| 24 | * in advance! |
| 25 | */ |
| 26 | void crcappend(unsigned char* message, |
| 27 | unsigned long length); |
| 28 | #if defined(__cplusplus) |
| 29 | } |
| 30 | #endif |
| 31 | |
| 32 | #endif |