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

Subversion Repositories yac

[/] [yac/] [trunk/] [test_sys/] [sw/] [src/] [crc.c] - Blame information for rev 11

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 11 feddischso
#include <stdint.h>
2
 
3
/*
4
 *  Message size up to 2^8 byte only!
5
 */
6
uint8_t crc( uint8_t *data, uint8_t l, uint8_t crc_init )
7
{
8
        uint8_t i, j;
9
        uint8_t crc = 0;
10
 
11
        for ( i = 0; i<l; i++ ) {
12
                crc ^= ( *data );
13
                for(j = 0; j<8; j++) {
14
                        if (crc & 0x80)
15
                                crc ^= 0x07;
16
                        crc <<= 1;
17
                }
18
        data++;
19
        }
20
        return (uint8_t)crc;
21
}

powered by: WebSVN 2.1.0

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