mirror of https://github.com/ARMmbed/mbed-os.git
Merge pull request #7793 from deepikabhavnani/crc_template_fix
Template specialization didnt work after addition of default constructorpull/7890/head
commit
0d0402dcec
|
@ -24,46 +24,6 @@ namespace mbed {
|
||||||
|
|
||||||
/* Default values for different types of polynomials
|
/* Default values for different types of polynomials
|
||||||
*/
|
*/
|
||||||
template<>
|
|
||||||
MbedCRC<POLY_32BIT_ANSI, 32>::MbedCRC(uint32_t initial_xor, uint32_t final_xor, bool reflect_data, bool reflect_remainder):
|
|
||||||
_initial_value(initial_xor), _final_xor(final_xor), _reflect_data(reflect_data), _reflect_remainder(reflect_remainder),
|
|
||||||
_crc_table((uint32_t *)Table_CRC_32bit_ANSI)
|
|
||||||
{
|
|
||||||
mbed_crc_ctor();
|
|
||||||
}
|
|
||||||
|
|
||||||
template<>
|
|
||||||
MbedCRC<POLY_8BIT_CCITT, 8>::MbedCRC(uint32_t initial_xor, uint32_t final_xor, bool reflect_data, bool reflect_remainder):
|
|
||||||
_initial_value(initial_xor), _final_xor(final_xor), _reflect_data(reflect_data), _reflect_remainder(reflect_remainder),
|
|
||||||
_crc_table((uint32_t *)Table_CRC_8bit_CCITT)
|
|
||||||
{
|
|
||||||
mbed_crc_ctor();
|
|
||||||
}
|
|
||||||
|
|
||||||
template<>
|
|
||||||
MbedCRC<POLY_7BIT_SD, 7>::MbedCRC(uint32_t initial_xor, uint32_t final_xor, bool reflect_data, bool reflect_remainder):
|
|
||||||
_initial_value(initial_xor), _final_xor(final_xor), _reflect_data(reflect_data), _reflect_remainder(reflect_remainder),
|
|
||||||
_crc_table((uint32_t *)Table_CRC_7Bit_SD)
|
|
||||||
{
|
|
||||||
mbed_crc_ctor();
|
|
||||||
}
|
|
||||||
|
|
||||||
template<>
|
|
||||||
MbedCRC<POLY_16BIT_CCITT, 16>::MbedCRC(uint32_t initial_xor, uint32_t final_xor, bool reflect_data, bool reflect_remainder):
|
|
||||||
_initial_value(initial_xor), _final_xor(final_xor), _reflect_data(reflect_data), _reflect_remainder(reflect_remainder),
|
|
||||||
_crc_table((uint32_t *)Table_CRC_16bit_CCITT)
|
|
||||||
{
|
|
||||||
mbed_crc_ctor();
|
|
||||||
}
|
|
||||||
|
|
||||||
template<>
|
|
||||||
MbedCRC<POLY_16BIT_IBM, 16>::MbedCRC(uint32_t initial_xor, uint32_t final_xor, bool reflect_data, bool reflect_remainder):
|
|
||||||
_initial_value(initial_xor), _final_xor(final_xor), _reflect_data(reflect_data), _reflect_remainder(reflect_remainder),
|
|
||||||
_crc_table((uint32_t *)Table_CRC_16bit_IBM)
|
|
||||||
{
|
|
||||||
mbed_crc_ctor();
|
|
||||||
}
|
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
MbedCRC<POLY_32BIT_ANSI, 32>::MbedCRC():
|
MbedCRC<POLY_32BIT_ANSI, 32>::MbedCRC():
|
||||||
_initial_value(~(0x0)), _final_xor(~(0x0)), _reflect_data(true), _reflect_remainder(true),
|
_initial_value(~(0x0)), _final_xor(~(0x0)), _reflect_data(true), _reflect_remainder(true),
|
||||||
|
|
|
@ -124,7 +124,7 @@ public:
|
||||||
*/
|
*/
|
||||||
MbedCRC(uint32_t initial_xor, uint32_t final_xor, bool reflect_data, bool reflect_remainder) :
|
MbedCRC(uint32_t initial_xor, uint32_t final_xor, bool reflect_data, bool reflect_remainder) :
|
||||||
_initial_value(initial_xor), _final_xor(final_xor), _reflect_data(reflect_data),
|
_initial_value(initial_xor), _final_xor(final_xor), _reflect_data(reflect_data),
|
||||||
_reflect_remainder(reflect_remainder), _crc_table(NULL)
|
_reflect_remainder(reflect_remainder)
|
||||||
{
|
{
|
||||||
mbed_crc_ctor();
|
mbed_crc_ctor();
|
||||||
}
|
}
|
||||||
|
@ -445,8 +445,6 @@ private:
|
||||||
{
|
{
|
||||||
MBED_STATIC_ASSERT(width <= 32, "Max 32-bit CRC supported");
|
MBED_STATIC_ASSERT(width <= 32, "Max 32-bit CRC supported");
|
||||||
|
|
||||||
_mode = (_crc_table != NULL) ? TABLE : BITWISE;
|
|
||||||
|
|
||||||
#ifdef DEVICE_CRC
|
#ifdef DEVICE_CRC
|
||||||
crc_mbed_config_t config;
|
crc_mbed_config_t config;
|
||||||
config.polynomial = polynomial;
|
config.polynomial = polynomial;
|
||||||
|
@ -458,8 +456,30 @@ private:
|
||||||
|
|
||||||
if (hal_crc_is_supported(&config)) {
|
if (hal_crc_is_supported(&config)) {
|
||||||
_mode = HARDWARE;
|
_mode = HARDWARE;
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
switch (polynomial) {
|
||||||
|
case POLY_32BIT_ANSI:
|
||||||
|
_crc_table = (uint32_t *)Table_CRC_32bit_ANSI;
|
||||||
|
break;
|
||||||
|
case POLY_8BIT_CCITT:
|
||||||
|
_crc_table = (uint32_t *)Table_CRC_8bit_CCITT;
|
||||||
|
break;
|
||||||
|
case POLY_7BIT_SD:
|
||||||
|
_crc_table = (uint32_t *)Table_CRC_7Bit_SD;
|
||||||
|
break;
|
||||||
|
case POLY_16BIT_CCITT:
|
||||||
|
_crc_table = (uint32_t *)Table_CRC_16bit_CCITT;
|
||||||
|
break;
|
||||||
|
case POLY_16BIT_IBM:
|
||||||
|
_crc_table = (uint32_t *)Table_CRC_16bit_IBM;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
_crc_table = NULL;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
_mode = (_crc_table != NULL) ? TABLE : BITWISE;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue