Skip to content

Commit f006002

Browse files
author
Steven Cartmell
committed
Add support for final_xor for K64F Hardware CRC
1 parent 8e14b59 commit f006002

File tree

1 file changed

+8
-1
lines changed
  • targets/TARGET_Freescale/TARGET_MCUXpresso_MCUS/TARGET_MCU_K64F

1 file changed

+8
-1
lines changed

targets/TARGET_Freescale/TARGET_MCUXpresso_MCUS/TARGET_MCU_K64F/mbed_crc_api.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#ifdef DEVICE_CRC
77

88
static crc_bits_t width;
9+
static uint32_t final_xor;
910

1011
bool hal_crc_is_supported(const crc_mbed_config_t* config)
1112
{
@@ -24,13 +25,14 @@ void hal_crc_compute_partial_start(const crc_mbed_config_t* config)
2425
return;
2526

2627
width = ((config->polynomial & 0xFFFF0000U) != 0) ? kCrcBits32 : kCrcBits16;
28+
final_xor = config->final_xor;
2729

2830
crc_config_t platform_config;
2931
platform_config.polynomial = config->polynomial;
3032
platform_config.seed = config->initial_xor;
3133
platform_config.reflectIn = config->reflect_in;
3234
platform_config.reflectOut = config->reflect_out;
33-
platform_config.complementChecksum = true;
35+
platform_config.complementChecksum = (config->final_xor == 0xFFFFFFFFU);
3436
platform_config.crcBits = width;
3537
platform_config.crcResult = kCrcFinalChecksum;
3638

@@ -50,6 +52,11 @@ void hal_crc_compute_partial(const uint8_t *data, const size_t size)
5052

5153
uint32_t hal_crc_get_result(void)
5254
{
55+
if ((final_xor != 0x00000000U) && (final_xor != 0xFFFFFFFFU))
56+
{
57+
CRC_WriteData(CRC0, (uint8_t*)&final_xor, sizeof(final_xor));
58+
}
59+
5360
switch (width)
5461
{
5562
case kCrcBits16:

0 commit comments

Comments
 (0)