/* Calculates a 32-bit CRC value over the specified data. 
It uses the CRC32_MPEG2 algorithm: */
uint32_t TbxChecksumCrc32Calculate(uint8_t const *data, size_t len)
/* Calculates a 32-bit CRC value over the specified data. 
It uses the CRC32_MPEG2 algorithm: */
uint32_t TbxChecksumCrc32Calculate(uint8_t const *data, size_t len)
{
  uint32_t result = 0;
  TBX_ASSERT((data != NULL) && (len > 0U));
  if ( (data != NULL) && (len > 0U) )
  {
    result = TBX_CONF_CHECKSUM_CRC32_INITIAL;
    for (size_t byteIdx = 0U; byteIdx < len; byteIdx++)
    {
      result = result ^ ((uint32_t)data[byteIdx] << 24U);
      for (uint8_t bitIdx = 0U; bitIdx <= 7U; bitIdx++)
      {
        if ((result & 0x80000000UL) != 0U)
        {
          result = ((uint32_t)(result << 1U)) ^ TBX_CONF_CHECKSUM_CRC32_POLYNOM;
        }
        else
        {
          result = (uint32_t)(result << 1U);
        }
      }
    }
  }
  return result;
}