crc_ccitt.h

Go to the documentation of this file.
00001 
00043 #ifndef ALGO_CRC_CCITT_H
00044 #define ALGO_CRC_CCITT_H
00045 
00046 #include <cfg/compiler.h>
00047 #include <cpu/pgm.h>
00048 
00049 EXTERN_C_BEGIN
00050 
00051 /* CRC table */
00052 extern const uint16_t crc_ccitt_tab[256];
00053 
00057 INLINE uint16_t updcrc_ccitt(uint8_t c, uint16_t oldcrc)
00058 {
00059 #if CPU_HARVARD
00060     return (oldcrc >> 8) ^ pgm_read_uint16_t(&crc_ccitt_tab[(oldcrc ^ c) & 0xff]);
00061 #else
00062     return (oldcrc >> 8) ^ crc_ccitt_tab[(oldcrc ^ c) & 0xff];
00063 #endif
00064 }
00065 
00067 #define CRC_CCITT_INIT_VAL ((uint16_t)0xFFFF)
00068 
00069 
00079 extern uint16_t crc_ccitt(uint16_t crc, const void *buf, size_t len);
00080 
00081 EXTERN_C_END
00082 
00083 #endif /* ALGO_CRC_CCITT_H */