OpenCores
URL https://opencores.org/ocsvn/yac/yac/trunk

Subversion Repositories yac

[/] [yac/] [trunk/] [test_sys/] [sw/] [src/] [crc.c] - Rev 11

Compare with Previous | Blame | View Log

#include <stdint.h>
 
/* 
 *  Message size up to 2^8 byte only!
 */
uint8_t crc( uint8_t *data, uint8_t l, uint8_t crc_init )
{
	uint8_t i, j;
	uint8_t crc = 0;
 
	for ( i = 0; i<l; i++ ) {
		crc ^= ( *data );
		for(j = 0; j<8; j++) {
			if (crc & 0x80)
				crc ^= 0x07;
			crc <<= 1;
		}
        data++;
	}
	return (uint8_t)crc;
}
 

Compare with Previous | Blame | View Log

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.