Skip to content

Commit

Permalink
crc16: update variants to be capable of calculation from data in chunks
Browse files Browse the repository at this point in the history
  • Loading branch information
Igor-Misic committed Sep 25, 2023
1 parent bcfa3d5 commit 7b24b5f
Show file tree
Hide file tree
Showing 49 changed files with 770 additions and 310 deletions.
2 changes: 1 addition & 1 deletion Inc/crc/crc16_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ void Crc16Base_tableCalculator(uint16_t polynomial, uint16_t crc_table[256]);
*
* @return The calculated CRC checksum.
*/
uint16_t Crc16_base(
uint16_t Crc16Base(
const uint16_t crc_table[256],
const uint8_t* crc_data_ptr,
uint32_t crc_length,
Expand Down
6 changes: 5 additions & 1 deletion Inc/crc/crc16_variants/crc16_a.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,16 @@
*
* @param[in] crc_data_ptr A pointer to the data block to calculate the checksum for.
* @param[in] crc_length The length of the data block in bytes.
* @param[in] final_crc Set the flag to 'true' if it is the last or only operation, and 'false' for data chunks.
* @param[in] last_crc_ptr Pointer to the last CRC value for data chunks. Shall be set to NULL_PTR if it is the first or only operation.
*
* @return The calculated CRC checksum.
*/
uint16_t Crc16_a(
const uint8_t* crc_data_ptr,
uint32_t crc_length
uint32_t crc_length,
bool final_crc,
const uint16_t* last_crc_ptr
);

#endif /* UTILITY_CRC16_A_H_ */
6 changes: 5 additions & 1 deletion Inc/crc/crc16_variants/crc16_arc.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,16 @@
*
* @param[in] crc_data_ptr A pointer to the data block to calculate the checksum for.
* @param[in] crc_length The length of the data block in bytes.
* @param[in] final_crc Set the flag to 'true' if it is the last or only operation, and 'false' for data chunks.
* @param[in] last_crc_ptr Pointer to the last CRC value for data chunks. Shall be set to NULL_PTR if it is the first or only operation.
*
* @return The calculated CRC checksum.
*/
uint16_t Crc16_arc(
const uint8_t* crc_data_ptr,
uint32_t crc_length
uint32_t crc_length,
bool final_crc,
const uint16_t* last_crc_ptr
);

#endif /* UTILITY_CRC16_ARC_H_ */
4 changes: 3 additions & 1 deletion Inc/crc/crc16_variants/crc16_aug_ccit.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,14 @@
*
* @param[in] crc_data_ptr A pointer to the data block to calculate the checksum for.
* @param[in] crc_length The length of the data block in bytes.
* @param[in] last_crc_ptr Pointer to the last CRC value for data chunks. Shall be set to NULL_PTR if it is the first or only operation.
*
* @return The calculated CRC checksum.
*/
uint16_t Crc16_augCcit(
const uint8_t* crc_data_ptr,
uint32_t crc_length
uint32_t crc_length,
const uint16_t* last_crc_ptr
);

#endif /* UTILITY_CRC16_AUG_CCIT_H_ */
4 changes: 3 additions & 1 deletion Inc/crc/crc16_variants/crc16_buypass.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,14 @@
*
* @param[in] crc_data_ptr A pointer to the data block to calculate the checksum for.
* @param[in] crc_length The length of the data block in bytes.
* @param[in] last_crc_ptr Pointer to the last CRC value for data chunks. Shall be set to NULL_PTR if it is the first or only operation.
*
* @return The calculated CRC checksum.
*/
uint16_t Crc16_buypass(
const uint8_t* crc_data_ptr,
uint32_t crc_length
uint32_t crc_length,
const uint16_t* last_crc_ptr
);

#endif /* UTILITY_CRC16_BUYPASS_H_ */
4 changes: 3 additions & 1 deletion Inc/crc/crc16_variants/crc16_ccit_false.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,14 @@
*
* @param[in] crc_data_ptr A pointer to the data block to calculate the checksum for.
* @param[in] crc_length The length of the data block in bytes.
* @param[in] last_crc_ptr Pointer to the last CRC value for data chunks. Shall be set to NULL_PTR if it is the first or only operation.
*
* @return The calculated CRC checksum.
*/
uint16_t Crc16_ccitFalse(
const uint8_t* crc_data_ptr,
uint32_t crc_length
uint32_t crc_length,
const uint16_t* last_crc_ptr
);

#endif /* UTILITY_CRC16_CCIT_FALSE_H_ */
4 changes: 3 additions & 1 deletion Inc/crc/crc16_variants/crc16_ccit_zero.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,14 @@
*
* @param[in] crc_data_ptr A pointer to the data block to calculate the checksum for.
* @param[in] crc_length The length of the data block in bytes.
* @param[in] last_crc_ptr Pointer to the last CRC value for data chunks. Shall be set to NULL_PTR if it is the first or only operation.
*
* @return The calculated CRC checksum.
*/
uint16_t Crc16_ccitZero(
const uint8_t* crc_data_ptr,
uint32_t crc_length
uint32_t crc_length,
const uint16_t* last_crc_ptr
);

#endif /* UTILITY_CRC16_CCIT_ZERO_H_ */
4 changes: 3 additions & 1 deletion Inc/crc/crc16_variants/crc16_cdma2000.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,14 @@
*
* @param[in] crc_data_ptr A pointer to the data block to calculate the checksum for.
* @param[in] crc_length The length of the data block in bytes.
* @param[in] last_crc_ptr Pointer to the last CRC value for data chunks. Shall be set to NULL_PTR if it is the first or only operation.
*
* @return The calculated CRC checksum.
*/
uint16_t Crc16_cdma2000(
const uint8_t* crc_data_ptr,
uint32_t crc_length
uint32_t crc_length,
const uint16_t* last_crc_ptr
);

#endif /* UTILITY_CRC16_CDMA2000_H_ */
4 changes: 3 additions & 1 deletion Inc/crc/crc16_variants/crc16_dds110.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,14 @@
*
* @param[in] crc_data_ptr A pointer to the data block to calculate the checksum for.
* @param[in] crc_length The length of the data block in bytes.
* @param[in] last_crc_ptr Pointer to the last CRC value for data chunks. Shall be set to NULL_PTR if it is the first or only operation.
*
* @return The calculated CRC checksum.
*/
uint16_t Crc16_dds110(
const uint8_t* crc_data_ptr,
uint32_t crc_length
uint32_t crc_length,
const uint16_t* last_crc_ptr
);

#endif /* UTILITY_CRC16_DDS110_H_ */
11 changes: 6 additions & 5 deletions Inc/crc/crc16_variants/crc16_dect_r.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,20 +43,21 @@
* This function calculates an 16-bit CRC checksum for the given block of data
* using polynomial 0x0589. The 'crc_data_ptr' parameter should be
* a pointer to the block of data to calculate the checksum for. The 'crc_length'
* parameter is the length of the data block in bytes. The 'final_xor' parameter
* indicates whether to perform a final XOR operation on the calculated CRC
* value before returning it. The calculation is performed using a lookup table for efficiency.
* parameter is the length of the data block in bytes.
* The calculation is performed using a lookup table for efficiency.
*
* @param[in] crc_data_ptr A pointer to the data block to calculate the checksum for.
* @param[in] crc_length The length of the data block in bytes.
* @param[in] final_xor Whether to perform a final XOR operation on the calculated CRC value.
* @param[in] final_crc Set the flag to 'true' if it is the last or only operation, and 'false' for data chunks.
* @param[in] last_crc_ptr Pointer to the last CRC value for data chunks. Shall be set to NULL_PTR if it is the first or only operation.
*
* @return The calculated CRC checksum.
*/
uint16_t Crc16_dectR(
const uint8_t* crc_data_ptr,
uint32_t crc_length,
bool final_xor
bool final_crc,
const uint16_t* last_crc_ptr
);

#endif /* UTILITY_CRC16_DECT_R_H_ */
4 changes: 3 additions & 1 deletion Inc/crc/crc16_variants/crc16_dect_x.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,14 @@
*
* @param[in] crc_data_ptr A pointer to the data block to calculate the checksum for.
* @param[in] crc_length The length of the data block in bytes.
* @param[in] last_crc_ptr Pointer to the last CRC value for data chunks. Shall be set to NULL_PTR if it is the first or only operation.
*
* @return The calculated CRC checksum.
*/
uint16_t Crc16_dectX(
const uint8_t* crc_data_ptr,
uint32_t crc_length
uint32_t crc_length,
const uint16_t* last_crc_ptr
);

#endif /* UTILITY_CRC16_DECT_X_H_ */
11 changes: 6 additions & 5 deletions Inc/crc/crc16_variants/crc16_dnp.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,20 +43,21 @@
* This function calculates an 16-bit CRC checksum for the given block of data
* using polynomial 0x3D65. The 'crc_data_ptr' parameter should be
* a pointer to the block of data to calculate the checksum for. The 'crc_length'
* parameter is the length of the data block in bytes. The 'final_xor' parameter
* indicates whether to perform a final XOR operation on the calculated CRC
* value before returning it. The calculation is performed using a lookup table for efficiency.
* parameter is the length of the data block in bytes.
* The calculation is performed using a lookup table for efficiency.
*
* @param[in] crc_data_ptr A pointer to the data block to calculate the checksum for.
* @param[in] crc_length The length of the data block in bytes.
* @param[in] final_xor Whether to perform a final XOR operation on the calculated CRC value.
* @param[in] final_crc Set the flag to 'true' if it is the last or only operation, and 'false' for data chunks.
* @param[in] last_crc_ptr Pointer to the last CRC value for data chunks. Shall be set to NULL_PTR if it is the first or only operation.
*
* @return The calculated CRC checksum.
*/
uint16_t Crc16_dnp(
const uint8_t* crc_data_ptr,
uint32_t crc_length,
bool final_xor
bool final_crc,
const uint16_t* last_crc_ptr
);

#endif /* UTILITY_CRC16_DNP_H_ */
11 changes: 6 additions & 5 deletions Inc/crc/crc16_variants/crc16_en_13757.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,20 +43,21 @@
* This function calculates an 16-bit CRC checksum for the given block of data
* using polynomial 0x3D65. The 'crc_data_ptr' parameter should be
* a pointer to the block of data to calculate the checksum for. The 'crc_length'
* parameter is the length of the data block in bytes. The 'final_xor' parameter
* indicates whether to perform a final XOR operation on the calculated CRC
* value before returning it. The calculation is performed using a lookup table for efficiency.
* parameter is the length of the data block in bytes.
* The calculation is performed using a lookup table for efficiency.
*
* @param[in] crc_data_ptr A pointer to the data block to calculate the checksum for.
* @param[in] crc_length The length of the data block in bytes.
* @param[in] final_xor Whether to perform a final XOR operation on the calculated CRC value.
* @param[in] final_crc Set the flag to 'true' if it is the last or only operation, and 'false' for data chunks.
* @param[in] last_crc_ptr Pointer to the last CRC value for data chunks. Shall be set to NULL_PTR if it is the first or only operation.
*
* @return The calculated CRC checksum.
*/
uint16_t Crc16_en13757(
const uint8_t* crc_data_ptr,
uint32_t crc_length,
bool final_xor
bool final_crc,
const uint16_t* last_crc_ptr
);

#endif /* UTILITY_CRC16_EN_13757_H_ */
11 changes: 6 additions & 5 deletions Inc/crc/crc16_variants/crc16_genibus.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,20 +43,21 @@
* This function calculates an 16-bit CRC checksum for the given block of data
* using polynomial 0x1021. The 'crc_data_ptr' parameter should be
* a pointer to the block of data to calculate the checksum for. The 'crc_length'
* parameter is the length of the data block in bytes. The 'final_xor' parameter
* indicates whether to perform a final XOR operation on the calculated CRC
* value before returning it. The calculation is performed using a lookup table for efficiency.
* parameter is the length of the data block in bytes.
* The calculation is performed using a lookup table for efficiency.
*
* @param[in] crc_data_ptr A pointer to the data block to calculate the checksum for.
* @param[in] crc_length The length of the data block in bytes.
* @param[in] final_xor Whether to perform a final XOR operation on the calculated CRC value.
* @param[in] final_crc Set the flag to 'true' if it is the last or only operation, and 'false' for data chunks.
* @param[in] last_crc_ptr Pointer to the last CRC value for data chunks. Shall be set to NULL_PTR if it is the first or only operation.
*
* @return The calculated CRC checksum.
*/
uint16_t Crc16_genibus(
const uint8_t* crc_data_ptr,
uint32_t crc_length,
bool final_xor
bool final_crc,
const uint16_t* last_crc_ptr
);

#endif /* UTILITY_CRC16_GENIBUS_H_ */
6 changes: 5 additions & 1 deletion Inc/crc/crc16_variants/crc16_kermit.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,16 @@
*
* @param[in] crc_data_ptr A pointer to the data block to calculate the checksum for.
* @param[in] crc_length The length of the data block in bytes.
* @param[in] final_crc Set the flag to 'true' if it is the last or only operation, and 'false' for data chunks.
* @param[in] last_crc_ptr Pointer to the last CRC value for data chunks. Shall be set to NULL_PTR if it is the first or only operation.
*
* @return The calculated CRC checksum.
*/
uint16_t Crc16_kermit(
const uint8_t* crc_data_ptr,
uint32_t crc_length
uint32_t crc_length,
bool final_crc,
const uint16_t* last_crc_ptr
);

#endif /* UTILITY_CRC16_KERMIT_H_ */
11 changes: 6 additions & 5 deletions Inc/crc/crc16_variants/crc16_maxim.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,20 +43,21 @@
* This function calculates an 16-bit CRC checksum for the given block of data
* using polynomial 0x8005. The 'crc_data_ptr' parameter should be
* a pointer to the block of data to calculate the checksum for. The 'crc_length'
* parameter is the length of the data block in bytes. The 'final_xor' parameter
* indicates whether to perform a final XOR operation on the calculated CRC
* value before returning it. The calculation is performed using a lookup table for efficiency.
* parameter is the length of the data block in bytes.
* The calculation is performed using a lookup table for efficiency.
*
* @param[in] crc_data_ptr A pointer to the data block to calculate the checksum for.
* @param[in] crc_length The length of the data block in bytes.
* @param[in] final_xor Whether to perform a final XOR operation on the calculated CRC value.
* @param[in] final_crc Set the flag to 'true' if it is the last or only operation, and 'false' for data chunks.
* @param[in] last_crc_ptr Pointer to the last CRC value for data chunks. Shall be set to NULL_PTR if it is the first or only operation.
*
* @return The calculated CRC checksum.
*/
uint16_t Crc16_maxim(
const uint8_t* crc_data_ptr,
uint32_t crc_length,
bool final_xor
bool final_crc,
const uint16_t* last_crc_ptr
);

#endif /* UTILITY_CRC16_MAXIM_H_ */
6 changes: 5 additions & 1 deletion Inc/crc/crc16_variants/crc16_mcrf4xx.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,16 @@
*
* @param[in] crc_data_ptr A pointer to the data block to calculate the checksum for.
* @param[in] crc_length The length of the data block in bytes.
* @param[in] final_crc Set the flag to 'true' if it is the last or only operation, and 'false' for data chunks.
* @param[in] last_crc_ptr Pointer to the last CRC value for data chunks. Shall be set to NULL_PTR if it is the first or only operation.
*
* @return The calculated CRC checksum.
*/
uint16_t Crc16_mcrf4xx(
const uint8_t* crc_data_ptr,
uint32_t crc_length
uint32_t crc_length,
bool final_crc,
const uint16_t* last_crc_ptr
);

#endif /* UTILITY_CRC16_MCRF4XX_H_ */
6 changes: 5 additions & 1 deletion Inc/crc/crc16_variants/crc16_modbus.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,16 @@
*
* @param[in] crc_data_ptr A pointer to the data block to calculate the checksum for.
* @param[in] crc_length The length of the data block in bytes.
* @param[in] final_crc Set the flag to 'true' if it is the last or only operation, and 'false' for data chunks.
* @param[in] last_crc_ptr Pointer to the last CRC value for data chunks. Shall be set to NULL_PTR if it is the first or only operation.
*
* @return The calculated CRC checksum.
*/
uint16_t Crc16_modbus(
const uint8_t* crc_data_ptr,
uint32_t crc_length
uint32_t crc_length,
bool final_crc,
const uint16_t* last_crc_ptr
);

#endif /* UTILITY_CRC16_MODBUS_H_ */
6 changes: 5 additions & 1 deletion Inc/crc/crc16_variants/crc16_riello.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,16 @@
*
* @param[in] crc_data_ptr A pointer to the data block to calculate the checksum for.
* @param[in] crc_length The length of the data block in bytes.
* @param[in] final_crc Set the flag to 'true' if it is the last or only operation, and 'false' for data chunks.
* @param[in] last_crc_ptr Pointer to the last CRC value for data chunks. Shall be set to NULL_PTR if it is the first or only operation.
*
* @return The calculated CRC checksum.
*/
uint16_t Crc16_riello(
const uint8_t* crc_data_ptr,
uint32_t crc_length
uint32_t crc_length,
bool final_crc,
const uint16_t* last_crc_ptr
);

#endif /* UTILITY_CRC16_RIELLO_H_ */
4 changes: 3 additions & 1 deletion Inc/crc/crc16_variants/crc16_t10_dif.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,14 @@
*
* @param[in] crc_data_ptr A pointer to the data block to calculate the checksum for.
* @param[in] crc_length The length of the data block in bytes.
* @param[in] last_crc_ptr Pointer to the last CRC value for data chunks. Shall be set to NULL_PTR if it is the first or only operation.
*
* @return The calculated CRC checksum.
*/
uint16_t Crc16_t10Dif(
const uint8_t* crc_data_ptr,
uint32_t crc_length
uint32_t crc_length,
const uint16_t* last_crc_ptr
);

#endif /* UTILITY_CRC16_T10_DIF_H_ */
4 changes: 3 additions & 1 deletion Inc/crc/crc16_variants/crc16_teledisk.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,14 @@
*
* @param[in] crc_data_ptr A pointer to the data block to calculate the checksum for.
* @param[in] crc_length The length of the data block in bytes.
* @param[in] last_crc_ptr Pointer to the last CRC value for data chunks. Shall be set to NULL_PTR if it is the first or only operation.
*
* @return The calculated CRC checksum.
*/
uint16_t Crc16_teledisk(
const uint8_t* crc_data_ptr,
uint32_t crc_length
uint32_t crc_length,
const uint16_t* last_crc_ptr
);

#endif /* UTILITY_CRC16_TELEDISK_H_ */
Loading

0 comments on commit 7b24b5f

Please sign in to comment.