mirror of https://github.com/ARMmbed/mbed-os.git
Updated table to be const and small fixes
parent
af0982295f
commit
b60eb1d001
|
@ -20,6 +20,13 @@
|
|||
#include "drivers/TableCRC.h"
|
||||
#include "platform/mbed_assert.h"
|
||||
|
||||
/* This is invalid warning from the compiler for below section of code
|
||||
if ((width < 8) && (NULL == _crc_table)) {
|
||||
p_crc = (uint32_t)(p_crc << (8 - width));
|
||||
}
|
||||
Compiler warns of the shift operation with width as it is width=(std::uint8_t),
|
||||
but we check for ( width < 8) before performing shift, so it should not be an issue.
|
||||
*/
|
||||
#if defined ( __CC_ARM )
|
||||
#pragma diag_suppress 62 // Shift count is negative
|
||||
#elif defined ( __GNUC__ )
|
||||
|
@ -57,7 +64,6 @@ typedef enum crc_polynomial {
|
|||
* @code
|
||||
*
|
||||
* #include "mbed.h"
|
||||
* #include "drivers/MbedCRC.h"
|
||||
*
|
||||
* int main() {
|
||||
* MbedCRC<POLY_32BIT_ANSI, 32> ct;
|
||||
|
@ -77,7 +83,6 @@ typedef enum crc_polynomial {
|
|||
* @code
|
||||
*
|
||||
* #include "mbed.h"
|
||||
* #include "drivers/MbedCRC.h"
|
||||
* int main() {
|
||||
* MbedCRC<POLY_32BIT_ANSI, 32> ct;
|
||||
*
|
||||
|
@ -263,7 +268,7 @@ private:
|
|||
*/
|
||||
uint32_t get_crc_mask(void) const
|
||||
{
|
||||
return (width < 8 ? ((1u << 8)-1) : (uint32_t)((uint64_t)(1ull << width) - 1));
|
||||
return (width < 8 ? ((1u << 8) - 1) : (uint32_t)((uint64_t)(1ull << width) - 1));
|
||||
}
|
||||
|
||||
/** Final value of CRC is reflected
|
||||
|
|
|
@ -15,12 +15,13 @@
|
|||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include "drivers/TableCRC.h"
|
||||
|
||||
namespace mbed {
|
||||
/** \addtogroup drivers */
|
||||
/** @{*/
|
||||
|
||||
uint8_t Table_CRC_7Bit_SD[256] = {
|
||||
extern const uint8_t Table_CRC_7Bit_SD[MBED_CRC_TABLE_SIZE] = {
|
||||
0x0, 0x12, 0x24, 0x36, 0x48, 0x5a, 0x6c, 0x7e, 0x90, 0x82, 0xb4, 0xa6, 0xd8, 0xca, 0xfc, 0xee,
|
||||
0x32, 0x20, 0x16, 0x4, 0x7a, 0x68, 0x5e, 0x4c, 0xa2, 0xb0, 0x86, 0x94, 0xea, 0xf8, 0xce, 0xdc,
|
||||
0x64, 0x76, 0x40, 0x52, 0x2c, 0x3e, 0x8, 0x1a, 0xf4, 0xe6, 0xd0, 0xc2, 0xbc, 0xae, 0x98, 0x8a,
|
||||
|
@ -39,7 +40,7 @@ uint8_t Table_CRC_7Bit_SD[256] = {
|
|||
0x1c, 0xe, 0x38, 0x2a, 0x54, 0x46, 0x70, 0x62, 0x8c, 0x9e, 0xa8, 0xba, 0xc4, 0xd6, 0xe0, 0xf2
|
||||
};
|
||||
|
||||
uint8_t Table_CRC_8bit_CCITT[256] = {
|
||||
extern const uint8_t Table_CRC_8bit_CCITT[MBED_CRC_TABLE_SIZE] = {
|
||||
0x0, 0x7, 0xe, 0x9, 0x1c, 0x1b, 0x12, 0x15, 0x38, 0x3f, 0x36, 0x31, 0x24, 0x23, 0x2a, 0x2d,
|
||||
0x70, 0x77, 0x7e, 0x79, 0x6c, 0x6b, 0x62, 0x65, 0x48, 0x4f, 0x46, 0x41, 0x54, 0x53, 0x5a, 0x5d,
|
||||
0xe0, 0xe7, 0xee, 0xe9, 0xfc, 0xfb, 0xf2, 0xf5, 0xd8, 0xdf, 0xd6, 0xd1, 0xc4, 0xc3, 0xca, 0xcd,
|
||||
|
@ -58,7 +59,7 @@ uint8_t Table_CRC_8bit_CCITT[256] = {
|
|||
0xde, 0xd9, 0xd0, 0xd7, 0xc2, 0xc5, 0xcc, 0xcb, 0xe6, 0xe1, 0xe8, 0xef, 0xfa, 0xfd, 0xf4, 0xf3
|
||||
};
|
||||
|
||||
uint16_t Table_CRC_16bit_CCITT[256] = {
|
||||
extern const uint16_t Table_CRC_16bit_CCITT[MBED_CRC_TABLE_SIZE] = {
|
||||
0x0, 0x1021, 0x2042, 0x3063, 0x4084, 0x50a5, 0x60c6, 0x70e7, 0x8108, 0x9129, 0xa14a, 0xb16b,
|
||||
0xc18c, 0xd1ad, 0xe1ce, 0xf1ef, 0x1231, 0x210, 0x3273, 0x2252, 0x52b5, 0x4294, 0x72f7, 0x62d6,
|
||||
0x9339, 0x8318, 0xb37b, 0xa35a, 0xd3bd, 0xc39c, 0xf3ff, 0xe3de, 0x2462, 0x3443, 0x420, 0x1401,
|
||||
|
@ -83,7 +84,7 @@ uint16_t Table_CRC_16bit_CCITT[256] = {
|
|||
0x2e93, 0x3eb2, 0x0ed1, 0x1ef0
|
||||
};
|
||||
|
||||
uint16_t Table_CRC_16bit_IBM[256] = {
|
||||
extern const uint16_t Table_CRC_16bit_IBM[MBED_CRC_TABLE_SIZE] = {
|
||||
0x0, 0x8005, 0x800f, 0xa, 0x801b, 0x1e, 0x14, 0x8011, 0x8033, 0x36, 0x3c, 0x8039,
|
||||
0x28, 0x802d, 0x8027, 0x22, 0x8063, 0x66, 0x6c, 0x8069, 0x78, 0x807d, 0x8077, 0x72,
|
||||
0x50, 0x8055, 0x805f, 0x5a, 0x804b, 0x4e, 0x44, 0x8041, 0x80c3, 0xc6, 0xcc, 0x80c9,
|
||||
|
@ -107,7 +108,7 @@ uint16_t Table_CRC_16bit_IBM[256] = {
|
|||
0x220, 0x8225, 0x822f, 0x22a, 0x823b, 0x23e, 0x234, 0x8231, 0x8213, 0x216, 0x21c, 0x8219
|
||||
};
|
||||
|
||||
uint32_t Table_CRC_32bit_ANSI[256] = {
|
||||
extern const uint32_t Table_CRC_32bit_ANSI[MBED_CRC_TABLE_SIZE] = {
|
||||
0x0, 0x4c11db7, 0x9823b6e, 0xd4326d9, 0x130476dc, 0x17c56b6b, 0x1a864db2, 0x1e475005,
|
||||
0x2608edb8, 0x22c9f00f, 0x2f8ad6d6, 0x2b4bcb61, 0x350c9b64, 0x31cd86d3, 0x3c8ea00a, 0x384fbdbd,
|
||||
0x4c11db70, 0x48d0c6c7, 0x4593e01e, 0x4152fda9, 0x5f15adac, 0x5bd4b01b, 0x569796c2, 0x52568b75,
|
||||
|
|
|
@ -23,11 +23,13 @@ namespace mbed {
|
|||
/** \addtogroup drivers */
|
||||
/** @{*/
|
||||
|
||||
extern uint8_t Table_CRC_7Bit_SD[256];
|
||||
extern uint8_t Table_CRC_8bit_CCITT[256];
|
||||
extern uint16_t Table_CRC_16bit_CCITT[256];
|
||||
extern uint16_t Table_CRC_16bit_IBM[256];
|
||||
extern uint32_t Table_CRC_32bit_ANSI[256];
|
||||
#define MBED_CRC_TABLE_SIZE 256
|
||||
|
||||
extern const uint8_t Table_CRC_7Bit_SD[MBED_CRC_TABLE_SIZE];
|
||||
extern const uint8_t Table_CRC_8bit_CCITT[MBED_CRC_TABLE_SIZE];
|
||||
extern const uint16_t Table_CRC_16bit_CCITT[MBED_CRC_TABLE_SIZE];
|
||||
extern const uint16_t Table_CRC_16bit_IBM[MBED_CRC_TABLE_SIZE];
|
||||
extern const uint32_t Table_CRC_32bit_ANSI[MBED_CRC_TABLE_SIZE];
|
||||
|
||||
/** @}*/
|
||||
} // namespace mbed
|
||||
|
|
Loading…
Reference in New Issue