BeRTOS
crc_ccitt.h
Go to the documentation of this file.
00001 
00042 #ifndef ALGO_CRC_CCITT_H
00043 #define ALGO_CRC_CCITT_H
00044 
00045 #include <cfg/compiler.h>
00046 #include <cpu/pgm.h>
00047 
00048 EXTERN_C_BEGIN
00049 
00050 /* CRC table */
00051 extern const uint16_t crc_ccitt_tab[256];
00052 
00056 INLINE uint16_t updcrc_ccitt(uint8_t c, uint16_t oldcrc)
00057 {
00058     return (oldcrc >> 8) ^ pgm_read16(&crc_ccitt_tab[(oldcrc ^ c) & 0xff]);
00059 }
00060 
00062 #define CRC_CCITT_INIT_VAL ((uint16_t)0xFFFF)
00063 
00064 
00074 extern uint16_t crc_ccitt(uint16_t crc, const void *buf, size_t len);
00075 
00076 EXTERN_C_END
00077 
00078 #endif /* ALGO_CRC_CCITT_H */