From: asterix Date: Tue, 10 Nov 2009 11:35:20 +0000 (+0000) Subject: Move crc table in ram when we using bootloader. X-Git-Tag: 2.4.0~88 X-Git-Url: https://codewiz.org/gitweb?a=commitdiff_plain;ds=sidebyside;h=d0c447e9524da37a437874a1049c524ba00e0087;p=bertos.git Move crc table in ram when we using bootloader. git-svn-id: https://src.develer.com/svnoss/bertos/trunk@3109 38d2e660-2303-0410-9eaa-f027e97ec537 --- diff --git a/bertos/algo/crc.c b/bertos/algo/crc.c index 96007add..58f6a73a 100644 --- a/bertos/algo/crc.c +++ b/bertos/algo/crc.c @@ -33,7 +33,6 @@ * * \brief CRC table and support routines * - * \version $Id$ * \author Bernie Innocenti */ @@ -42,7 +41,13 @@ /** * crctab calculated by Mark G. Mendel, Network Systems Corporation */ -const uint16_t PROGMEM crc16tab[256] = { +#if CPU_HARVARD && !(ARCH & ARCH_BOOT) + #define CRC_TABLE const uint16_t PROGMEM crc16tab[256] +#else + #define CRC_TABLE const uint16_t crc16tab[256] +#endif + +CRC_TABLE = { 0x0000, 0x1021, 0x2042, 0x3063, 0x4084, 0x50a5, 0x60c6, 0x70e7, 0x8108, 0x9129, 0xa14a, 0xb16b, 0xc18c, 0xd1ad, 0xe1ce, 0xf1ef, 0x1231, 0x0210, 0x3273, 0x2252, 0x52b5, 0x4294, 0x72f7, 0x62d6, diff --git a/bertos/algo/crc.h b/bertos/algo/crc.h index 9696e4f1..4be0602e 100644 --- a/bertos/algo/crc.h +++ b/bertos/algo/crc.h @@ -43,7 +43,6 @@ * to Stephen Satchell, Satchell Evaluations and Chuck Forsberg, * Omen Technology. * - * \version $Id$ * \author Bernie Innocenti * * $WIZ$ module_name = "crc16" @@ -52,6 +51,8 @@ #ifndef ALGO_CRC_H #define ALGO_CRC_H +#include "cfg/cfg_arch.h" + #include #include @@ -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);