SysIo  1.9.0
Embedded Library and tools
crc.h
1 
35 #ifndef _SYSIO_CRC_H_
36 #define _SYSIO_CRC_H_
37 
38 #include <sysio/defs.h>
39 
40 #ifdef __cplusplus
41  extern "C" {
42 #endif
43 /* ========================================================================== */
44 
52 /* constants ================================================================ */
54 #define CRC_CCITT_INIT_VAL ((uint16_t)0xFFFF)
55 
56 /* internal public functions ================================================ */
66 uint16_t usCrcCcitt (uint16_t usCrc, const void *pvBuf, size_t uLen);
67 
68 /* inline public functions ================================================ */
69 
70 /* CRC table */
71 extern const uint16_t usCrcCcittTab[256];
72 
76 INLINE uint16_t
77  usCrcCcittUpdate(uint8_t c, uint16_t oldcrc) {
78 
79  return (oldcrc >> 8) ^ usCrcCcittTab[(oldcrc ^ c) & 0xff];
80 }
86 /* ========================================================================== */
87 #ifdef __cplusplus
88  }
89 #endif
90 #endif /* _SYSIO_CRC_H_ */
INLINE uint16_t usCrcCcittUpdate(uint8_t c, uint16_t oldcrc)
Compute the updated CRC-CCITT value for one octet (inline version)
Definition: crc.h:77
uint16_t usCrcCcitt(uint16_t usCrc, const void *pvBuf, size_t uLen)