void CRC16_Final( CRC16_Context *inContext, uint16_t *outResult )
{
  inContext->crc = UpdateCRC16(inContext->crc, 0);
  inContext->crc = UpdateCRC16(inContext->crc, 0);

  *outResult = inContext->crc&0xffffu;
}
/**
  * @brief  Cal CRC16 for YModem Packet
  * @param  data
  * @param  length
   * @retval None
  */
uint16_t Cal_CRC16(const uint8_t* data, uint32_t size)
{
 uint32_t crc = 0;
 const uint8_t* dataEnd = data+size;
 while(data<dataEnd)
  crc = UpdateCRC16(crc,*data++);
 
 crc = UpdateCRC16(crc,0);
 crc = UpdateCRC16(crc,0);
 return crc&0xffffu;
}
void CRC16_Update( CRC16_Context *inContext, const void *inSrc, int inLen )
{
  const uint8_t * src = (const uint8_t *) inSrc;
  const uint8_t* srcEnd = src + inLen;
  while( src < srcEnd )
    inContext->crc = UpdateCRC16(inContext->crc, *src++);
}
Beispiel #4
0
/**
  * @brief  Cal CRC16 for YModem Packet
  * @param  data
  * @param  length
  * @retval CRC value
  */
uint16_t Cal_CRC16(const uint8_t* data, uint32_t size)
{
  uint32_t crc = 0;
  const uint8_t* dataEnd = data+size;
  
#ifdef USE_CRC_PERIPH
  /* Reset CRC data register */
  CRC_ResetDR();
  while(data < dataEnd)
  {
    crc = CRC_CalcCRC16bits(__REV16(*(uint16_t *)data));
    data+=2;
  }
#else /* USE_CRC_SOFTWARE */
  while(data<dataEnd)
  {
    crc = UpdateCRC16(crc,*data++);
  }
  crc = UpdateCRC16(crc,0);
  crc = UpdateCRC16(crc,0);
#endif /* USE_CRC_PERIPH */
  return (crc&0xffffu);
}