Move crc table in ram when we using bootloader.
[bertos.git] / bertos / algo / crc.h
index 9696e4f1606679d5ab53f8ad304edba209c4d72a..4be0602e94273bc3c5b6a93c11bf3d75be4b0971 100644 (file)
@@ -43,7 +43,6 @@
  * to Stephen Satchell, Satchell Evaluations and Chuck Forsberg,
  * Omen Technology.
  *
- * \version $Id$
  * \author Bernie Innocenti <bernie@codewiz.org>
  *
  * $WIZ$ module_name = "crc16"
@@ -52,6 +51,8 @@
 #ifndef ALGO_CRC_H
 #define ALGO_CRC_H
 
+#include "cfg/cfg_arch.h"
+
 #include <cfg/compiler.h>
 #include <cpu/pgm.h>
 
@@ -70,7 +71,7 @@ extern const uint16_t crc16tab[256];
  * \param c New octet (range 0-255)
  * \param oldcrc Previous CRC16 value (referenced twice, beware of side effects)
  */
-#if CPU_HARVARD
+#if CPU_HARVARD && !(ARCH & ARCH_BOOT)
        #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))
@@ -85,7 +86,7 @@ extern const uint16_t crc16tab[256];
  */
 INLINE uint16_t updcrc16(uint8_t c, uint16_t oldcrc)
 {
-#if CPU_HARVARD
+#if CPU_HARVARD  && !(ARCH & ARCH_BOOT)
        return pgm_read_uint16_t(&crc16tab[(oldcrc >> 8) ^ c]) ^ (oldcrc << 8);
 #else
        return crc16tab[(oldcrc >> 8) ^ c] ^ (oldcrc << 8);