Skip to content

Commit

Permalink
test for MISRA
Browse files Browse the repository at this point in the history
  • Loading branch information
Igor-Misic committed Sep 21, 2023
1 parent f762fdc commit c6125be
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
3 changes: 2 additions & 1 deletion Inc/crc/crc32_variants/crc32.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@
uint32_t Crc32(
const uint8_t* crc_data_ptr,
uint32_t crc_length,
bool final_xor
bool final_xor,
const uint32_t* last_crc_value
);

#endif /* UTILITY_CRC32_H_ */
10 changes: 8 additions & 2 deletions Src/crc/crc32_variants/crc32.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ uint32_t
Crc32(
const uint8_t* crc_data_ptr,
uint32_t crc_length,
bool final_xor) {
bool final_xor,
const uint32_t* last_crc_value) {

/* CRC32 also know as Ethernet CRC (Polynomial 0x4C11DB7) */
static const uint32_t crc_table[256] = {
Expand Down Expand Up @@ -83,11 +84,16 @@ Crc32(
0xAFB010B1U, 0xAB710D06U, 0xA6322BDFU, 0xA2F33668U, 0xBCB4666DU, 0xB8757BDAU, 0xB5365D03U, 0xB1F740B4U
};

uint32_t crc_initial_value = INITIAL_CRC32_VALUE;
if (NULL_PTR != last_crc_value) {
crc_initial_value = *last_crc_value;
}

return Crc32Base(
crc_table,
crc_data_ptr,
crc_length,
INITIAL_CRC32_VALUE,
crc_initial_value,
FINAL_XOR_VALUE,
REFLECTED_OUTPUT,
REFLECTED_INPUT,
Expand Down

0 comments on commit c6125be

Please sign in to comment.