/**
 * \brief Reset CRC module and set source to I/O interface
 *
 * This function initializes the CRC module, and \ref crc_io_checksum_byte_add
 * can be used to add bytes to calculate checksum for. When any number of bytes
 * have been added, the \ref crc_io_checksum_byte_stop can be called to disable
 * the module and get the calculated checksum.
 *
 * \param crc_16_32 Indicator for whether CRC-32 or CRC-16 shall be used
 */
void crc_io_checksum_byte_start(enum crc_16_32_t crc_16_32)
{
	/* Initialize CRC calculations on I/O interface */
	crc_reset();
	/* Enable CRC-32 if chosen */
	if (crc_16_32 == CRC_32BIT) {
		crc_32_enable();
	}
	/* Enable CRC module using the I/O interface */
	crc_set_source(CRC_SOURCE_IO_gc);
}
Beispiel #2
0
uint32_t
calc_crc(uint32_t* ptr, int len) {
  crc_reset();
  uint32_t crc = crc_calculate_block(ptr, len);
  return crc;
}