Code to replace CRC32 included in existing library

0

I'm trying to CRC32 with STM32L151. I wrote the code with an existing library. But I don't want to use the CRC32 code included in the existing library. I want to create my own. How can I derive the correct code from this code?

I didn't look up the CRC32 calculations on the data sheet. Let me know if you know how to calculate.

uint16_t Checksum(uint8_t *check_buffer, uint8_t buffer_legnth) {
  uint8_t i;
  uint16_t crc_result = 0;

  LL_CRC_ResetCRCCalculationUnit(CRC);

  for (i = 0; i < buffer_legnth; i++) {
    LL_CRC_FeedData32(CRC, check_buffer[i]);
  }

  crc_result = (LL_CRC_ReadData32(CRC) & 0x0000FFFF);

  // printf("CRC : %X \r\n", crc_result);

  return crc_result;
}

union Crc_Data {
  uint8_t Crc_Data_8[2];
  uint16_t Crc_Data_16;
}

void main() {
  union Crc_Data Crc_Data;
  uint8_t test_packet[8] = {0x10, 0x20, 0x30, 0xB9, 0x53, 0x23, 0xA3};
  Crc_Data.Crc_Data_16 = xcrc32((uint8_t *)&test_packet, 7);
  printf("CRC = %02x %02x \r\n", Crc_Data.Crc_Data_8[0],
         Crc_Data.Crc_Data_8[1]);
}
stm32
crc32
asked on Stack Overflow Oct 22, 2019 by 김강일 • edited Oct 22, 2019 by Tarick Welling

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0