Skip to content

Commit 8e14b59

Browse files
author
Steven Cartmell
committed
HAL CRC: Add bit width parameter to crc_config_t
1 parent e1ca2b3 commit 8e14b59

File tree

3 files changed

+5
-1
lines changed

3 files changed

+5
-1
lines changed

drivers/MbedCRC.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,7 @@ class MbedCRC
203203
if (_mode == HARDWARE) {
204204
crc_mbed_config_t config;
205205
config.polynomial = polynomial;
206+
config.width = width;
206207
config.initial_xor = _initial_value;
207208
config.final_xor = _final_xor;
208209
config.reflect_in = _reflect_data;
@@ -440,6 +441,7 @@ class MbedCRC
440441
#ifdef DEVICE_CRC
441442
crc_mbed_config_t config;
442443
config.polynomial = polynomial;
444+
config.width = width;
443445
config.initial_xor = _initial_value;
444446
config.final_xor = _final_xor;
445447
config.reflect_in = _reflect_data;

hal/crc_api.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ typedef enum crc_polynomial {
3838
typedef struct crc_mbed_config {
3939
/// CRC Polynomial. Example polynomial: 0x21 = 0010_0011 = x^5+x+1
4040
uint32_t polynomial;
41+
/// CRC Bit Width
42+
uint32_t width;
4143
/// Initial seed value for the computation.
4244
uint32_t initial_xor;
4345
/// Final xor value for the computation.

targets/TARGET_Freescale/TARGET_MCUXpresso_MCUS/TARGET_MCU_K64F/mbed_crc_api.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ bool hal_crc_is_supported(const crc_mbed_config_t* config)
1212
if (config == NULL)
1313
return false;
1414

15-
if ((config->polynomial & 0x80008000) == 0)
15+
if ((config->width != 32) || (config->width != 16))
1616
return false;
1717

1818
return true;

0 commit comments

Comments
 (0)