src/ErriezCRC32.c
/*!
 * \brief Calculate CRC on multiple buffers.
 * \details
 *      This function is thread safe and maybe called from interrupt handlers.
 *      No buffer alignment needed.
 * \param buffer
 *      Input buffer. No alignment needed.
 * \param bufferLength
 *      Input buffer length in Bytes. No alignment needed.
 * \param crc
 *      Previous CRC value. Call with crc = CRC32_INITIAL on first calculation.
 * \return
 *      32-bit updated CRC value.
 */
\brief Calculate CRC on multiple buffers.
\details
This function is thread safe and maybe called from interrupt handlers.
No buffer alignment needed.
\param buffer
Input buffer. No alignment needed.
\param bufferLength
Input buffer length in Bytes. No alignment needed.
\param crc
Previous CRC value. Call with crc = CRC32_INITIAL on first calculation.
\return
32-bit updated CRC value.
\ brief Calculate CRC on multiple buffers . \ details This function is thread safe and maybe called from interrupt handlers . No buffer alignment needed . \ param buffer Input buffer . No alignment needed . \ param bufferLength Input buffer length in Bytes . No alignment needed . \ param crc Previous CRC value . Call with crc = CRC32_INITIAL on first calculation . \ return 32 - bit updated CRC value .
uint32_t crc32Update(const void *buffer, size_t bufferLength, uint32_t crc)
{
    size_t i;
    int8_t j;
    uint32_t mask;
    for (i = 0; i < bufferLength; i++) {
        crc ^= ((uint8_t *)buffer)[i];
        for (j = 7; j >= 0; j--) {
            mask = -(crc & 1);
            crc = (crc >> 1) ^ (CRC32_POLYNOMIAL & mask);
        }
    }
    return crc;
}
uint32_t crc32Update ( const void * buffer , size_t bufferLength , uint32_t crc ) { size_t i ; int8_t j ; uint32_t mask ; for ( i = 0 ; i < bufferLength ; i ++ ) { crc ^= ( ( uint8_t * ) buffer ) [ i ] ; for ( j = 7 ; j >= 0 ; j -- ) { mask = - ( crc & 1 ) ; crc = ( crc >> 1 ) ^ ( CRC32_POLYNOMIAL & mask ) ; } } return crc ; }
\brief Calculate CRC on multiple buffers.
\ brief Calculate CRC on multiple buffers .