crc.h
Go to the documentation of this file.00001
00050 #ifndef ALGO_CRC_H
00051 #define ALGO_CRC_H
00052
00053 #include <cfg/compiler.h>
00054
00055 #ifdef __cplusplus
00056 extern "C" {
00057 #endif
00058
00059
00060
00061 extern const uint16_t crc16tab[256];
00062
00063
00073 #define UPDCRC16(c, oldcrc) (crc16tab[((oldcrc) >> 8) ^ ((unsigned char)(c))] ^ ((oldcrc) << 8))
00074
00075
00076 #ifdef INLINE
00077
00080 INLINE uint16_t updcrc16(uint8_t c, uint16_t oldcrc)
00081 {
00082 return crc16tab[(oldcrc >> 8) ^ c] ^ (oldcrc << 8);
00083 }
00084 #endif // INLINE
00085
00086
00096 extern uint16_t crc16(uint16_t crc, const void *buf, size_t len);
00097
00098 #ifdef __cplusplus
00099 }
00100 #endif
00101
00102 #endif