projects
/
bertos.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fix the bug related to the version list.
[bertos.git]
/
bertos
/
algo
/
crc.h
diff --git
a/bertos/algo/crc.h
b/bertos/algo/crc.h
index d6a1f45de21ca688c7b83615d3287b15a85a4a9a..c2553dd563166b389e4e879aa74e90eea261b036 100644
(file)
--- a/
bertos/algo/crc.h
+++ b/
bertos/algo/crc.h
@@
-27,11
+27,11
@@
* the GNU General Public License.
*
* Copyright 2003, 2004 Develer S.r.l. (http://www.develer.com/)
* the GNU General Public License.
*
* Copyright 2003, 2004 Develer S.r.l. (http://www.develer.com/)
- * Copyright 1999 Bern
ardo Innocenti <bernie@develer.com
>
+ * Copyright 1999 Bern
ie Innocenti <bernie@codewiz.org
>
*
* -->
*
*
* -->
*
- * \brief
XModem-CRC16 algorithm (interface)
+ * \brief
Cyclic Redundancy Check 16 (CRC).
*
* \note This algorithm is incompatible with the CCITT-CRC16.
*
*
* \note This algorithm is incompatible with the CCITT-CRC16.
*
@@
-44,18
+44,18
@@
* Omen Technology.
*
* \version $Id$
* Omen Technology.
*
* \version $Id$
- * \author Bernardo Innocenti <bernie@develer.com>
+ * \author Bernie Innocenti <bernie@codewiz.org>
+ *
+ * $WIZ$ module_name = "crc16"
*/
#ifndef ALGO_CRC_H
#define ALGO_CRC_H
#include <cfg/compiler.h>
*/
#ifndef ALGO_CRC_H
#define ALGO_CRC_H
#include <cfg/compiler.h>
+#include <cpu/pgm.h>
-#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
-
+EXTERN_C_BEGIN
/* CRC table */
extern const uint16_t crc16tab[256];
/* CRC table */
extern const uint16_t crc16tab[256];
@@
-70,16
+70,24
@@
extern const uint16_t crc16tab[256];
* \param c New octet (range 0-255)
* \param oldcrc Previous CRC16 value (referenced twice, beware of side effects)
*/
* \param c New octet (range 0-255)
* \param oldcrc Previous CRC16 value (referenced twice, beware of side effects)
*/
-#define UPDCRC16(c, oldcrc) (crc16tab[((oldcrc) >> 8) ^ ((unsigned char)(c))] ^ ((oldcrc) << 8))
+#if CPU_AVR
+ #define UPDCRC16(c, oldcrc) (pgm_read_uint16_t(&crc16tab[((oldcrc) >> 8) ^ ((unsigned char)(c))]) ^ ((oldcrc) << 8))
+#else
+ #define UPDCRC16(c, oldcrc) ((crc16tab[((oldcrc) >> 8) ^ ((unsigned char)(c))]) ^ ((oldcrc) << 8))
+#endif
#ifdef INLINE
/**
#ifdef INLINE
/**
- * \brief Compute the updated CRC16 value for one octet (
macro
version)
+ * \brief Compute the updated CRC16 value for one octet (
inline
version)
*/
INLINE uint16_t updcrc16(uint8_t c, uint16_t oldcrc)
{
*/
INLINE uint16_t updcrc16(uint8_t c, uint16_t oldcrc)
{
+#if CPU_AVR
+ return pgm_read_uint16_t(&crc16tab[(oldcrc >> 8) ^ c]) ^ (oldcrc << 8);
+#else
return crc16tab[(oldcrc >> 8) ^ c] ^ (oldcrc << 8);
return crc16tab[(oldcrc >> 8) ^ c] ^ (oldcrc << 8);
+#endif
}
#endif // INLINE
}
#endif // INLINE
@@
-95,8
+103,6
@@
INLINE uint16_t updcrc16(uint8_t c, uint16_t oldcrc)
*/
extern uint16_t crc16(uint16_t crc, const void *buf, size_t len);
*/
extern uint16_t crc16(uint16_t crc, const void *buf, size_t len);
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
+EXTERN_C_END
#endif /* ALGO_CRC_H */
#endif /* ALGO_CRC_H */