HAL CRC: Add bit width parameter to crc_config_t

pull/6708/head
Steven Cartmell 2018-05-04 11:43:39 +01:00
parent e1ca2b32fc
commit 8e14b5977b
3 changed files with 5 additions and 1 deletions

View File

@ -203,6 +203,7 @@ public:
if (_mode == HARDWARE) {
crc_mbed_config_t config;
config.polynomial = polynomial;
config.width = width;
config.initial_xor = _initial_value;
config.final_xor = _final_xor;
config.reflect_in = _reflect_data;
@ -440,6 +441,7 @@ private:
#ifdef DEVICE_CRC
crc_mbed_config_t config;
config.polynomial = polynomial;
config.width = width;
config.initial_xor = _initial_value;
config.final_xor = _final_xor;
config.reflect_in = _reflect_data;

View File

@ -38,6 +38,8 @@ typedef enum crc_polynomial {
typedef struct crc_mbed_config {
/// CRC Polynomial. Example polynomial: 0x21 = 0010_0011 = x^5+x+1
uint32_t polynomial;
/// CRC Bit Width
uint32_t width;
/// Initial seed value for the computation.
uint32_t initial_xor;
/// Final xor value for the computation.

View File

@ -12,7 +12,7 @@ bool hal_crc_is_supported(const crc_mbed_config_t* config)
if (config == NULL)
return false;
if ((config->polynomial & 0x80008000) == 0)
if ((config->width != 32) || (config->width != 16))
return false;
return true;