4 * Copyright 2003,2004 Develer S.r.l. (http://www.develer.com/)
5 * Copyright 1999 Bernardo Innocenti <bernie@develer.com>
9 * \brief Definitions for CRC generator
12 * \author Bernardo Innocenti <bernie@develer.com>
17 * Revision 1.1 2004/06/03 08:58:16 bernie
26 #endif /* __cplusplus */
28 #include <stdint.h> // uint16_t
29 #include <stddef.h> // size_t
32 extern const uint16_t crc16tab[256];
36 * updcrc macro derived from article Copyright (C) 1986 Stephen Satchell.
37 * \note First argument must be in range 0 to 255.
38 * \note Second argument is referenced twice.
40 * Programmers may incorporate any or all code into their programs,
41 * giving proper credit within the source. Publication of the
42 * source routines is permitted so long as proper credit is given
43 * to Stephen Satchell, Satchell Evaluations and Chuck Forsberg,
46 #define UPDCRC16(c, oldcrc) (crc16tab[((oldcrc) >> 8) ^ ((unsigned char)(c))] ^ ((oldcrc) << 8))
49 * This function implements the CRC 16 calculation on a buffer.
51 * \param crc Current CRC16 value.
52 * \param buf The buffer to perform CRC calculation on.
53 * \param len The length of the Buffer.
55 * \return The updated CRC 16 value.
57 extern uint16_t crc16(uint16_t crc, const void *buf, size_t len);
61 #endif /* __cplusplus */